Commit ed8aa971 authored by Peter Eisentraut's avatar Peter Eisentraut

Remove references to NAMEDATALEN and INDEX_MAX_KEYS from pg_dump. Handles

any size now.
parent 8889eb09
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.254 2002/04/24 02:44:19 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.255 2002/04/24 22:39:49 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1802,10 +1802,12 @@ clearIndInfo(IndInfo *ind, int numIndexes) ...@@ -1802,10 +1802,12 @@ clearIndInfo(IndInfo *ind, int numIndexes)
free(ind[i].indexdef); free(ind[i].indexdef);
if (ind[i].indisprimary) if (ind[i].indisprimary)
free(ind[i].indisprimary); free(ind[i].indisprimary);
for (a = 0; a < INDEX_MAX_KEYS; ++a) if (ind[i].indkey)
{ {
if (ind[i].indkey[a]) for (a = 0; a < ind[i].indnkeys; ++a)
free(ind[i].indkey[a]); if (ind[i].indkey[a])
free(ind[i].indkey[a]);
free(ind[i].indkey);
} }
} }
free(ind); free(ind);
...@@ -3020,6 +3022,7 @@ getIndexes(int *numIndexes) ...@@ -3020,6 +3022,7 @@ getIndexes(int *numIndexes)
int i_indrelname; int i_indrelname;
int i_indexdef; int i_indexdef;
int i_indisprimary; int i_indisprimary;
int i_indnkeys;
int i_indkey; int i_indkey;
/* /*
...@@ -3033,11 +3036,14 @@ getIndexes(int *numIndexes) ...@@ -3033,11 +3036,14 @@ getIndexes(int *numIndexes)
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT i.indexrelid as indexreloid, " "SELECT i.indexrelid as indexreloid, "
"i.indrelid as indreloid, " "i.indrelid as indreloid, "
"t1.relname as indexrelname, t2.relname as indrelname, " "t1.relname as indexrelname, t2.relname as indrelname, "
"pg_get_indexdef(i.indexrelid) as indexdef, " "pg_get_indexdef(i.indexrelid) as indexdef, "
"i.indisprimary, i.indkey " "i.indisprimary, i.indkey, "
"from pg_index i, pg_class t1, pg_class t2 " "CASE WHEN regproctooid(i.indproc) <> 0 "
"WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid " " THEN (SELECT pronargs FROM pg_proc WHERE pg_proc.oid = regproctooid(i.indproc)) "
" ELSE t1.relnatts END as indnkeys "
"FROM pg_index i, pg_class t1, pg_class t2 "
"WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
"and i.indexrelid > '%u'::oid " "and i.indexrelid > '%u'::oid "
"and t2.relname !~ '^pg_' ", "and t2.relname !~ '^pg_' ",
g_last_builtin_oid); g_last_builtin_oid);
...@@ -3067,6 +3073,7 @@ getIndexes(int *numIndexes) ...@@ -3067,6 +3073,7 @@ getIndexes(int *numIndexes)
i_indrelname = PQfnumber(res, "indrelname"); i_indrelname = PQfnumber(res, "indrelname");
i_indexdef = PQfnumber(res, "indexdef"); i_indexdef = PQfnumber(res, "indexdef");
i_indisprimary = PQfnumber(res, "indisprimary"); i_indisprimary = PQfnumber(res, "indisprimary");
i_indnkeys = PQfnumber(res, "indnkeys");
i_indkey = PQfnumber(res, "indkey"); i_indkey = PQfnumber(res, "indkey");
for (i = 0; i < ntups; i++) for (i = 0; i < ntups; i++)
...@@ -3077,9 +3084,11 @@ getIndexes(int *numIndexes) ...@@ -3077,9 +3084,11 @@ getIndexes(int *numIndexes)
indinfo[i].indrelname = strdup(PQgetvalue(res, i, i_indrelname)); indinfo[i].indrelname = strdup(PQgetvalue(res, i, i_indrelname));
indinfo[i].indexdef = strdup(PQgetvalue(res, i, i_indexdef)); indinfo[i].indexdef = strdup(PQgetvalue(res, i, i_indexdef));
indinfo[i].indisprimary = strdup(PQgetvalue(res, i, i_indisprimary)); indinfo[i].indisprimary = strdup(PQgetvalue(res, i, i_indisprimary));
indinfo[i].indnkeys = atoi(PQgetvalue(res, i, i_indnkeys));
indinfo[i].indkey = malloc(indinfo[i].indnkeys * sizeof(indinfo[i].indkey[0]));
parseNumericArray(PQgetvalue(res, i, i_indkey), parseNumericArray(PQgetvalue(res, i, i_indkey),
indinfo[i].indkey, indinfo[i].indkey,
INDEX_MAX_KEYS); indinfo[i].indnkeys);
} }
PQclear(res); PQclear(res);
...@@ -3577,7 +3586,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i, ...@@ -3577,7 +3586,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
PQExpBuffer delqry = createPQExpBuffer(); PQExpBuffer delqry = createPQExpBuffer();
PQExpBuffer fnlist = createPQExpBuffer(); PQExpBuffer fnlist = createPQExpBuffer();
PQExpBuffer asPart = createPQExpBuffer(); PQExpBuffer asPart = createPQExpBuffer();
char func_lang[NAMEDATALEN + 1]; char *func_lang = NULL;
PGresult *res; PGresult *res;
int nlangs; int nlangs;
int j; int j;
...@@ -3638,7 +3647,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i, ...@@ -3638,7 +3647,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
} }
} }
strcpy(func_lang, PQgetvalue(res, 0, i_lanname)); func_lang = strdup(PQgetvalue(res, 0, i_lanname));
PQclear(res); PQclear(res);
...@@ -3749,6 +3758,7 @@ done: ...@@ -3749,6 +3758,7 @@ done:
destroyPQExpBuffer(delqry); destroyPQExpBuffer(delqry);
destroyPQExpBuffer(fnlist); destroyPQExpBuffer(fnlist);
destroyPQExpBuffer(asPart); destroyPQExpBuffer(asPart);
free(func_lang);
} }
/* /*
...@@ -4515,7 +4525,7 @@ getPKconstraint(TableInfo *tblInfo, IndInfo *indInfo) ...@@ -4515,7 +4525,7 @@ getPKconstraint(TableInfo *tblInfo, IndInfo *indInfo)
appendPQExpBuffer(pkBuf, "Constraint %s Primary Key (", appendPQExpBuffer(pkBuf, "Constraint %s Primary Key (",
tblInfo->primary_key_name); tblInfo->primary_key_name);
for (k = 0; k < INDEX_MAX_KEYS; k++) for (k = 0; k < indInfo->indnkeys; k++)
{ {
int indkey; int indkey;
const char *attname; const char *attname;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_dump.h,v 1.83 2002/04/24 02:44:19 momjian Exp $ * $Id: pg_dump.h,v 1.84 2002/04/24 22:39:49 petere Exp $
* *
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
* *
...@@ -148,8 +148,9 @@ typedef struct _indInfo ...@@ -148,8 +148,9 @@ typedef struct _indInfo
char *indrelname; /* name of the indexed table */ char *indrelname; /* name of the indexed table */
char *indexdef; /* index definitional command */ char *indexdef; /* index definitional command */
char *indisprimary; /* is this a PK index? */ char *indisprimary; /* is this a PK index? */
char *indkey[INDEX_MAX_KEYS]; /* attribute numbers of the key int indnkeys; /* number of keys in index */
* attributes */ char **indkey; /* attribute numbers of the key
* attributes */
} IndInfo; } IndInfo;
typedef struct _aggInfo typedef struct _aggInfo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment