Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit203749a

Browse files
committed
pg_upgrade: Ignore TOAST for partitioned tables
Since partitioned tables in pg12 do not have toast tables, trying to setthe toast OID confuses pg_upgrade. Have pg_dump omit those values toavoid the problem.Per Andres Freund and buildfarm members crake and snapperDiscussion:https://postgr.es/m/20190306204104.yle5jfbnqkcwykni@alap3.anarazel.de
1 parentf2e4038 commit203749a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,14 +4354,20 @@ binary_upgrade_set_type_oids_by_rel_oid(Archive *fout,
43544354
Oidpg_type_oid;
43554355
booltoast_set = false;
43564356

4357-
/* we only support old >= 8.3 for binary upgrades */
4357+
/*
4358+
* We only support old >= 8.3 for binary upgrades.
4359+
*
4360+
* We purposefully ignore toast OIDs for partitioned tables; the reason is
4361+
* that versions 10 and 11 have them, but 12 does not, so emitting them
4362+
* causes the upgrade to fail.
4363+
*/
43584364
appendPQExpBuffer(upgrade_query,
43594365
"SELECT c.reltype AS crel, t.reltype AS trel "
43604366
"FROM pg_catalog.pg_class c "
43614367
"LEFT JOIN pg_catalog.pg_class t ON "
4362-
" (c.reltoastrelid = t.oid) "
4368+
" (c.reltoastrelid = t.oid AND c.relkind <> '%c') "
43634369
"WHERE c.oid = '%u'::pg_catalog.oid;",
4364-
pg_rel_oid);
4370+
RELKIND_PARTITIONED_TABLE,pg_rel_oid);
43654371

43664372
upgrade_res = ExecuteSqlQueryForSingleRow(fout, upgrade_query->data);
43674373

@@ -5953,6 +5959,10 @@ getTables(Archive *fout, int *numTables)
59535959
* information about each table, basically just enough to decide if it is
59545960
* interesting. We must fetch all tables in this phase because otherwise
59555961
* we cannot correctly identify inherited columns, owned sequences, etc.
5962+
*
5963+
* We purposefully ignore toast OIDs for partitioned tables; the reason is
5964+
* that versions 10 and 11 have them, but 12 does not, so emitting them
5965+
* causes the upgrade to fail.
59565966
*/
59575967

59585968
if (fout->remoteVersion >= 90600)
@@ -6049,7 +6059,7 @@ getTables(Archive *fout, int *numTables)
60496059
"d.classid = c.tableoid AND d.objid = c.oid AND "
60506060
"d.objsubid = 0 AND "
60516061
"d.refclassid = c.tableoid AND d.deptype IN ('a', 'i')) "
6052-
"LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid) "
6062+
"LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid AND c.relkind <> '%c') "
60536063
"LEFT JOIN pg_am am ON (c.relam = am.oid) "
60546064
"LEFT JOIN pg_init_privs pip ON "
60556065
"(c.oid = pip.objoid "
@@ -6072,6 +6082,7 @@ getTables(Archive *fout, int *numTables)
60726082
ispartition,
60736083
partbound,
60746084
RELKIND_SEQUENCE,
6085+
RELKIND_PARTITIONED_TABLE,
60756086
RELKIND_RELATION, RELKIND_SEQUENCE,
60766087
RELKIND_VIEW, RELKIND_COMPOSITE_TYPE,
60776088
RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp