*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
free(ind[i].indexdef);
if (ind[i].indisprimary)
free(ind[i].indisprimary);
- for (a = 0; a < INDEX_MAX_KEYS; ++a)
+ if (ind[i].indkey)
{
- if (ind[i].indkey[a])
- free(ind[i].indkey[a]);
+ for (a = 0; a < ind[i].indnkeys; ++a)
+ if (ind[i].indkey[a])
+ free(ind[i].indkey[a]);
+ free(ind[i].indkey);
}
}
free(ind);
int i_indrelname;
int i_indexdef;
int i_indisprimary;
+ int i_indnkeys;
int i_indkey;
/*
appendPQExpBuffer(query,
"SELECT i.indexrelid as indexreloid, "
"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, "
- "i.indisprimary, i.indkey "
- "from pg_index i, pg_class t1, pg_class t2 "
- "WHERE t1.oid = i.indexrelid and t2.oid = i.indrelid "
+ "i.indisprimary, i.indkey, "
+ "CASE WHEN regproctooid(i.indproc) <> 0 "
+ " 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 t2.relname !~ '^pg_' ",
g_last_builtin_oid);
i_indrelname = PQfnumber(res, "indrelname");
i_indexdef = PQfnumber(res, "indexdef");
i_indisprimary = PQfnumber(res, "indisprimary");
+ i_indnkeys = PQfnumber(res, "indnkeys");
i_indkey = PQfnumber(res, "indkey");
for (i = 0; i < ntups; i++)
indinfo[i].indrelname = strdup(PQgetvalue(res, i, i_indrelname));
indinfo[i].indexdef = strdup(PQgetvalue(res, i, i_indexdef));
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),
indinfo[i].indkey,
- INDEX_MAX_KEYS);
+ indinfo[i].indnkeys);
}
PQclear(res);
PQExpBuffer delqry = createPQExpBuffer();
PQExpBuffer fnlist = createPQExpBuffer();
PQExpBuffer asPart = createPQExpBuffer();
- char func_lang[NAMEDATALEN + 1];
+ char *func_lang = NULL;
PGresult *res;
int nlangs;
int j;
}
}
- strcpy(func_lang, PQgetvalue(res, 0, i_lanname));
+ func_lang = strdup(PQgetvalue(res, 0, i_lanname));
PQclear(res);
destroyPQExpBuffer(delqry);
destroyPQExpBuffer(fnlist);
destroyPQExpBuffer(asPart);
+ free(func_lang);
}
/*
appendPQExpBuffer(pkBuf, "Constraint %s Primary Key (",
tblInfo->primary_key_name);
- for (k = 0; k < INDEX_MAX_KEYS; k++)
+ for (k = 0; k < indInfo->indnkeys; k++)
{
int indkey;
const char *attname;
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* 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
*
char *indrelname; /* name of the indexed table */
char *indexdef; /* index definitional command */
char *indisprimary; /* is this a PK index? */
- char *indkey[INDEX_MAX_KEYS]; /* attribute numbers of the key
- * attributes */
+ int indnkeys; /* number of keys in index */
+ char **indkey; /* attribute numbers of the key
+ * attributes */
} IndInfo;
typedef struct _aggInfo