Ensure that FK constraints are dumped after primary/unique constraints,
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 28 Aug 2003 18:59:06 +0000 (18:59 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 28 Aug 2003 18:59:06 +0000 (18:59 +0000)
rather than relying on OID order of pg_constraint entries.  Per gripe
from Greg Stark.

src/bin/pg_dump/pg_dump.c

index 976081f55aebcb8677231d5f5886855cb705178d..0a369a9561b772a4cb99c93733488a1d1b24e0a3 100644 (file)
@@ -588,6 +588,7 @@ main(int argc, char **argv)
        MoveToEnd(g_fout, "BLOBS");
        MoveToEnd(g_fout, "INDEX");
        MoveToEnd(g_fout, "CONSTRAINT");
+       MoveToEnd(g_fout, "FK CONSTRAINT");
        MoveToEnd(g_fout, "TRIGGER");
        MoveToEnd(g_fout, "RULE");
        MoveToEnd(g_fout, "SEQUENCE SET");
@@ -6039,6 +6040,8 @@ dumpOneSequence(Archive *fout, TableInfo *tbinfo,
  *
  * Dump out constraints after all table creation statements in
  * an alter table format.  Currently handles foreign keys only.
+ * (Unique and primary key constraints are handled with indexes,
+ * while check constraints are merged into the table definition.)
  *
  * XXX Potentially wrap in a 'SET CONSTRAINTS OFF' block so that
  * the current table data is not processed
@@ -6130,7 +6133,7 @@ dumpConstraints(Archive *fout, TableInfo *tblinfo, int numTables)
                                                 conName,
                                                 tbinfo->relnamespace->nspname,
                                                 tbinfo->usename,
-                                                "CONSTRAINT", NULL,
+                                                "FK CONSTRAINT", NULL,
                                                 query->data, delqry->data,
                                                 NULL, NULL, NULL);