@@ -4354,14 +4354,20 @@ binary_upgrade_set_type_oids_by_rel_oid(Archive *fout,
4354
4354
Oid pg_type_oid;
4355
4355
bool toast_set = false;
4356
4356
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
+ */
4358
4364
appendPQExpBuffer(upgrade_query,
4359
4365
"SELECT c.reltype AS crel, t.reltype AS trel "
4360
4366
"FROM pg_catalog.pg_class c "
4361
4367
"LEFT JOIN pg_catalog.pg_class t ON "
4362
- " (c.reltoastrelid = t.oid) "
4368
+ " (c.reltoastrelid = t.oid AND c.relkind <> '%c' ) "
4363
4369
"WHERE c.oid = '%u'::pg_catalog.oid;",
4364
- pg_rel_oid);
4370
+ RELKIND_PARTITIONED_TABLE, pg_rel_oid);
4365
4371
4366
4372
upgrade_res = ExecuteSqlQueryForSingleRow(fout, upgrade_query->data);
4367
4373
@@ -5953,6 +5959,10 @@ getTables(Archive *fout, int *numTables)
5953
5959
* information about each table, basically just enough to decide if it is
5954
5960
* interesting. We must fetch all tables in this phase because otherwise
5955
5961
* 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.
5956
5966
*/
5957
5967
5958
5968
if (fout->remoteVersion >= 90600)
@@ -6049,7 +6059,7 @@ getTables(Archive *fout, int *numTables)
6049
6059
"d.classid = c.tableoid AND d.objid = c.oid AND "
6050
6060
"d.objsubid = 0 AND "
6051
6061
"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' ) "
6053
6063
"LEFT JOIN pg_am am ON (c.relam = am.oid) "
6054
6064
"LEFT JOIN pg_init_privs pip ON "
6055
6065
"(c.oid = pip.objoid "
@@ -6072,6 +6082,7 @@ getTables(Archive *fout, int *numTables)
6072
6082
ispartition,
6073
6083
partbound,
6074
6084
RELKIND_SEQUENCE,
6085
+ RELKIND_PARTITIONED_TABLE,
6075
6086
RELKIND_RELATION, RELKIND_SEQUENCE,
6076
6087
RELKIND_VIEW, RELKIND_COMPOSITE_TYPE,
6077
6088
RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE,
0 commit comments