Fix broken pg_dump for 9.0 and 9.1 caused by the MV patch.
authorKevin Grittner <kgrittn@postgresql.org>
Wed, 6 Mar 2013 15:51:49 +0000 (09:51 -0600)
committerKevin Grittner <kgrittn@postgresql.org>
Wed, 6 Mar 2013 15:51:49 +0000 (09:51 -0600)
Per report and suggestion from Bernd Helmle

src/bin/pg_dump/pg_dump.c

index e6c85ac0aedf11aa6f292e2823006144f78a64ca..840445832d47749c9fb0e31a9b1ea2cc679ec1a6 100644 (file)
@@ -4141,7 +4141,7 @@ getTables(Archive *fout, int *numTables)
     * we cannot correctly identify inherited columns, owned sequences, etc.
     */
 
-   if (fout->remoteVersion >= 90100)
+   if (fout->remoteVersion >= 90300)
    {
        /*
         * Left join to pick up dependency info linking sequences to their
@@ -4177,6 +4177,42 @@ getTables(Archive *fout, int *numTables)
                          RELKIND_VIEW, RELKIND_COMPOSITE_TYPE,
                          RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE);
    }
+   else if (fout->remoteVersion >= 90100)
+   {
+       /*
+        * Left join to pick up dependency info linking sequences to their
+        * owning column, if any (note this dependency is AUTO as of 8.2)
+        */
+       appendPQExpBuffer(query,
+                         "SELECT c.tableoid, c.oid, c.relname, "
+                         "c.relacl, c.relkind, c.relnamespace, "
+                         "(%s c.relowner) AS rolname, "
+                         "c.relchecks, c.relhastriggers, "
+                         "c.relhasindex, c.relhasrules, c.relhasoids, "
+                         "c.relfrozenxid, tc.oid AS toid, "
+                         "tc.relfrozenxid AS tfrozenxid, "
+                         "c.relpersistence, 't'::bool as isscannable, "
+                         "CASE WHEN c.reloftype <> 0 THEN c.reloftype::pg_catalog.regtype ELSE NULL END AS reloftype, "
+                         "d.refobjid AS owning_tab, "
+                         "d.refobjsubid AS owning_col, "
+                         "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
+                       "array_to_string(c.reloptions, ', ') AS reloptions, "
+                         "array_to_string(array(SELECT 'toast.' || x FROM unnest(tc.reloptions) x), ', ') AS toast_reloptions "
+                         "FROM pg_class c "
+                         "LEFT JOIN pg_depend d ON "
+                         "(c.relkind = '%c' AND "
+                         "d.classid = c.tableoid AND d.objid = c.oid AND "
+                         "d.objsubid = 0 AND "
+                         "d.refclassid = c.tableoid AND d.deptype = 'a') "
+                      "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid) "
+                         "WHERE c.relkind in ('%c', '%c', '%c', '%c', '%c', '%c') "
+                         "ORDER BY c.oid",
+                         username_subquery,
+                         RELKIND_SEQUENCE,
+                         RELKIND_RELATION, RELKIND_SEQUENCE,
+                         RELKIND_VIEW, RELKIND_COMPOSITE_TYPE,
+                         RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE);
+   }
    else if (fout->remoteVersion >= 90000)
    {
        /*