Fix pg_upgrade to preserve toast relfrozenxids for old 8.3 servers.
authorBruce Momjian <[email protected]>
Thu, 1 Sep 2011 02:00:22 +0000 (22:00 -0400)
committerBruce Momjian <[email protected]>
Thu, 1 Sep 2011 02:00:22 +0000 (22:00 -0400)
This fixes a pg_upgrade bug that could lead to query errors when
clog files are improperly removed.

Backpatch to 8.4, 9.0, 9.1.

src/bin/pg_dump/pg_dump.c

index b00e19b8b6f1902e44faeb9c496427840fb35d96..c5816aed0e6fe89963887a5ca63fe270f1ea7186 100644 (file)
@@ -3256,14 +3256,13 @@ getTables(int *numTables)
                 * owning column, if any (note this dependency is AUTO as of 8.2)
                 */
                appendPQExpBuffer(query,
-                                                 "SELECT c.tableoid, c.oid, relname, "
-                                                 "relacl, relkind, relnamespace, "
-                                                 "(%s relowner) AS rolname, "
-                                                 "relchecks, (reltriggers <> 0) AS relhastriggers, "
-                                                 "relhasindex, relhasrules, relhasoids, "
-                                                 "relfrozenxid, "
-                                                 "0 AS toid, "
-                                                 "0 AS tfrozenxid, "
+                                                 "SELECT c.tableoid, c.oid, c.relname, "
+                                                 "c.relacl, c.relkind, c.relnamespace, "
+                                                 "(%s c.relowner) AS rolname, "
+                                                 "c.relchecks, (c.reltriggers <> 0) AS relhastriggers, "
+                                                 "c.relhasindex, c.relhasrules, c.relhasoids, "
+                                                 "c.relfrozenxid, tc.oid AS toid, "
+                                                 "tc.relfrozenxid AS tfrozenxid, "
                                                  "d.refobjid AS owning_tab, "
                                                  "d.refobjsubid AS owning_col, "
                                                  "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
@@ -3275,7 +3274,8 @@ getTables(int *numTables)
                                                  "d.classid = c.tableoid AND d.objid = c.oid AND "
                                                  "d.objsubid = 0 AND "
                                                  "d.refclassid = c.tableoid AND d.deptype = 'a') "
-                                                 "WHERE relkind in ('%c', '%c', '%c', '%c') "
+                                          "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid) "
+                                                 "WHERE c.relkind in ('%c', '%c', '%c', '%c') "
                                                  "ORDER BY c.oid",
                                                  username_subquery,
                                                  RELKIND_SEQUENCE,