* by PostgreSQL
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.346 2003/08/28 20:21:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.347 2003/09/19 23:15:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
int i_indexrelname;
int i_indexdef;
int i_contype;
+ int i_conoid;
int i_indkey;
int i_indisclustered;
int i_indnkeys;
"pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, "
"i.indkey, i.indisclustered, "
"t.relnatts as indnkeys, "
- "coalesce(c.contype, '0') as contype "
+ "coalesce(c.contype, '0') as contype, "
+ "coalesce(c.oid, '0') as conoid "
"FROM pg_catalog.pg_index i "
"JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
"LEFT JOIN pg_catalog.pg_depend d "
"i.indkey, false as indisclustered, "
"t.relnatts as indnkeys, "
"CASE WHEN i.indisprimary THEN 'p'::char "
- "ELSE '0'::char END as contype "
+ "ELSE '0'::char END as contype, "
+ "0::oid as conoid "
"FROM pg_index i, pg_class t "
"WHERE t.oid = i.indexrelid "
"AND i.indrelid = '%s'::oid "
i_indexrelname = PQfnumber(res, "indexrelname");
i_indexdef = PQfnumber(res, "indexdef");
i_contype = PQfnumber(res, "contype");
+ i_conoid = PQfnumber(res, "conoid");
i_indkey = PQfnumber(res, "indkey");
i_indisclustered = PQfnumber(res, "indisclustered");
i_indnkeys = PQfnumber(res, "indnkeys");
const char *indexrelname = PQgetvalue(res, j, i_indexrelname);
const char *indexdef = PQgetvalue(res, j, i_indexdef);
char contype = *(PQgetvalue(res, j, i_contype));
+ const char *conoid = PQgetvalue(res, j, i_conoid);
bool indisclustered = (PQgetvalue(res, j, i_indisclustered)[0] == 't');
resetPQExpBuffer(q);
appendPQExpBuffer(q, ");\n");
+ /* If the index is clustered, we need to record that. */
+ if (indisclustered)
+ {
+ appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
+ fmtId(tbinfo->relname));
+ appendPQExpBuffer(q, " ON %s;\n",
+ fmtId(indexrelname));
+ }
+
/*
* DROP must be fully qualified in case same name appears
* in pg_catalog
fmtId(tbinfo->relname));
appendPQExpBuffer(delq, "DROP CONSTRAINT %s;\n",
fmtId(indexrelname));
- /* If the index is clustered, we need to record that. */
- if (indisclustered)
- {
- appendPQExpBuffer(q, "\nALTER TABLE %s CLUSTER",
- fmtId(tbinfo->relname));
- appendPQExpBuffer(q, " ON %s;\n",
- fmtId(indexrelname));
- }
ArchiveEntry(fout, indexreloid,
indexrelname,
for (k = 0; k < indnkeys; k++)
free(indkeys[k]);
free(indkeys);
+
+ /* Dump Constraint Comments */
+ resetPQExpBuffer(q);
+ appendPQExpBuffer(q, "CONSTRAINT %s ",
+ fmtId(indexrelname));
+ appendPQExpBuffer(q, "ON %s",
+ fmtId(tbinfo->relname));
+ dumpComment(fout, q->data,
+ tbinfo->relnamespace->nspname,
+ tbinfo->usename,
+ conoid, "pg_constraint", 0, NULL);
}
else
{