Skip to content

Commit e724b96

Browse files
committed
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.
1 parent 53434c6 commit e724b96

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,14 +3516,13 @@ getTables(int *numTables)
35163516
* owning column, if any (note this dependency is AUTO as of 8.2)
35173517
*/
35183518
appendPQExpBuffer(query,
3519-
"SELECT c.tableoid, c.oid, relname, "
3520-
"relacl, relkind, relnamespace, "
3521-
"(%s relowner) AS rolname, "
3522-
"relchecks, (reltriggers <> 0) AS relhastriggers, "
3523-
"relhasindex, relhasrules, relhasoids, "
3524-
"relfrozenxid, "
3525-
"0 AS toid, "
3526-
"0 AS tfrozenxid, "
3519+
"SELECT c.tableoid, c.oid, c.relname, "
3520+
"c.relacl, c.relkind, c.relnamespace, "
3521+
"(%s c.relowner) AS rolname, "
3522+
"c.relchecks, (c.reltriggers <> 0) AS relhastriggers, "
3523+
"c.relhasindex, c.relhasrules, c.relhasoids, "
3524+
"c.relfrozenxid, tc.oid AS toid, "
3525+
"tc.relfrozenxid AS tfrozenxid, "
35273526
"NULL AS reloftype, "
35283527
"d.refobjid AS owning_tab, "
35293528
"d.refobjsubid AS owning_col, "
@@ -3536,7 +3535,8 @@ getTables(int *numTables)
35363535
"d.classid = c.tableoid AND d.objid = c.oid AND "
35373536
"d.objsubid = 0 AND "
35383537
"d.refclassid = c.tableoid AND d.deptype = 'a') "
3539-
"WHERE relkind in ('%c', '%c', '%c', '%c') "
3538+
"LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid) "
3539+
"WHERE c.relkind in ('%c', '%c', '%c', '%c') "
35403540
"ORDER BY c.oid",
35413541
username_subquery,
35423542
RELKIND_SEQUENCE,

0 commit comments

Comments
 (0)