Fix pg_upgrade to preserve toast relfrozenxids for old 8.3 servers.

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.
This commit is contained in:
Bruce Momjian 2011-08-31 21:49:58 -04:00
parent 97930cf578
commit 7971a57fd4

View File

@ -3978,14 +3978,13 @@ getTables(int *numTables)
* owning column, if any (note this dependency is AUTO as of 8.2) * owning column, if any (note this dependency is AUTO as of 8.2)
*/ */
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT c.tableoid, c.oid, relname, " "SELECT c.tableoid, c.oid, c.relname, "
"relacl, relkind, relnamespace, " "c.relacl, c.relkind, c.relnamespace, "
"(%s relowner) AS rolname, " "(%s c.relowner) AS rolname, "
"relchecks, (reltriggers <> 0) AS relhastriggers, " "c.relchecks, (c.reltriggers <> 0) AS relhastriggers, "
"relhasindex, relhasrules, relhasoids, " "c.relhasindex, c.relhasrules, c.relhasoids, "
"relfrozenxid, " "c.relfrozenxid, tc.oid AS toid, "
"0 AS toid, " "tc.relfrozenxid AS tfrozenxid, "
"0 AS tfrozenxid, "
"'p' AS relpersistence, " "'p' AS relpersistence, "
"NULL AS reloftype, " "NULL AS reloftype, "
"d.refobjid AS owning_tab, " "d.refobjid AS owning_tab, "
@ -3999,7 +3998,8 @@ getTables(int *numTables)
"d.classid = c.tableoid AND d.objid = c.oid AND " "d.classid = c.tableoid AND d.objid = c.oid AND "
"d.objsubid = 0 AND " "d.objsubid = 0 AND "
"d.refclassid = c.tableoid AND d.deptype = 'a') " "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", "ORDER BY c.oid",
username_subquery, username_subquery,
RELKIND_SEQUENCE, RELKIND_SEQUENCE,