summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r--src/bin/pg_dump/pg_dump.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index f9c51d1e679..25742a0e2ad 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -3141,6 +3141,7 @@ dumpDatabase(Archive *fout)
PGresult *lo_res;
PQExpBuffer loFrozenQry = createPQExpBuffer();
PQExpBuffer loOutQry = createPQExpBuffer();
+ PQExpBuffer loVacQry = createPQExpBuffer();
int i_relfrozenxid,
i_relfilenode,
i_oid,
@@ -3167,15 +3168,36 @@ dumpDatabase(Archive *fout)
i_relfilenode = PQfnumber(lo_res, "relfilenode");
i_oid = PQfnumber(lo_res, "oid");
- appendPQExpBufferStr(loOutQry, "\n-- For binary upgrade, preserve values for pg_largeobject and its index\n");
+ appendPQExpBufferStr(loOutQry, "\n-- For binary upgrade, set pg_largeobject relfrozenxid and relminmxid\n");
+ appendPQExpBufferStr(loVacQry, "\n-- For binary upgrade, preserve pg_largeobject and index relfilenodes\n");
for (int i = 0; i < PQntuples(lo_res); ++i)
+ {
+ Oid oid;
+ RelFileNumber relfilenumber;
+
appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
- "SET relfrozenxid = '%u', relminmxid = '%u', relfilenode = '%u'\n"
+ "SET relfrozenxid = '%u', relminmxid = '%u'\n"
"WHERE oid = %u;\n",
atooid(PQgetvalue(lo_res, i, i_relfrozenxid)),
atooid(PQgetvalue(lo_res, i, i_relminmxid)),
- atooid(PQgetvalue(lo_res, i, i_relfilenode)),
- atooid(PQgetvalue(lo_res, i, i_oid)));
+ atooid(PQgetvalue(lo_res, i, i_relfilenode)));
+
+ oid = atooid(PQgetvalue(lo_res, i, i_oid));
+ relfilenumber = atooid(PQgetvalue(lo_res, i, i_relfilenode));
+
+ if (oid == LargeObjectRelationId)
+ appendPQExpBuffer(loVacQry,
+ "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
+ relfilenumber);
+ else if (oid == LargeObjectLOidPNIndexId)
+ appendPQExpBuffer(loVacQry,
+ "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
+ relfilenumber);
+ }
+
+ appendPQExpBufferStr(loVacQry,
+ "TRUNCATE pg_catalog.pg_largeobject;\n");
+ appendPQExpBufferStr(loOutQry, loVacQry->data);
ArchiveEntry(fout, nilCatalogId, createDumpId(),
ARCHIVE_OPTS(.tag = "pg_largeobject",
@@ -3187,6 +3209,7 @@ dumpDatabase(Archive *fout)
destroyPQExpBuffer(loFrozenQry);
destroyPQExpBuffer(loOutQry);
+ destroyPQExpBuffer(loVacQry);
}
PQclear(res);