Skip to content

Commit 82a4f37

Browse files
committed
Preserve pg_largeobject_metadata.relfrozenxid in pg_upgrade.
This is needed only in 9.1 because only 9.0 had this and no one is upgrading from a 9.0 beta to 9.0 anymore. We basically don't backpatch 9.0 beta fixes at this point.
1 parent e69d321 commit 82a4f37

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "catalog/pg_class.h"
5151
#include "catalog/pg_default_acl.h"
5252
#include "catalog/pg_largeobject.h"
53+
#include "catalog/pg_largeobject_metadata.h"
5354
#include "catalog/pg_proc.h"
5455
#include "catalog/pg_trigger.h"
5556
#include "catalog/pg_type.h"
@@ -1920,8 +1921,8 @@ dumpDatabase(Archive *AH)
19201921
NULL); /* Dumper Arg */
19211922

19221923
/*
1923-
* pg_largeobject comes from the old system intact, so set its
1924-
* relfrozenxid.
1924+
* pg_largeobject and pg_largeobject_metadata come from the old system
1925+
* intact, so set their relfrozenxids.
19251926
*/
19261927
if (binary_upgrade)
19271928
{
@@ -1930,6 +1931,9 @@ dumpDatabase(Archive *AH)
19301931
PQExpBuffer loOutQry = createPQExpBuffer();
19311932
int i_relfrozenxid;
19321933

1934+
/*
1935+
* pg_largeobject
1936+
*/
19331937
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid\n"
19341938
"FROM pg_catalog.pg_class\n"
19351939
"WHERE oid = %u;\n",
@@ -1946,7 +1950,7 @@ dumpDatabase(Archive *AH)
19461950

19471951
i_relfrozenxid = PQfnumber(lo_res, "relfrozenxid");
19481952

1949-
appendPQExpBuffer(loOutQry, "\n-- For binary upgrade, set pg_largeobject relfrozenxid.\n");
1953+
appendPQExpBuffer(loOutQry, "\n-- For binary upgrade, set pg_largeobject.relfrozenxid\n");
19501954
appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
19511955
"SET relfrozenxid = '%u'\n"
19521956
"WHERE oid = %u;\n",
@@ -1960,6 +1964,47 @@ dumpDatabase(Archive *AH)
19601964
NULL, NULL);
19611965

19621966
PQclear(lo_res);
1967+
1968+
/*
1969+
* pg_largeobject_metadata
1970+
*/
1971+
if (g_fout->remoteVersion >= 90000)
1972+
{
1973+
resetPQExpBuffer(loFrozenQry);
1974+
resetPQExpBuffer(loOutQry);
1975+
1976+
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid\n"
1977+
"FROM pg_catalog.pg_class\n"
1978+
"WHERE oid = %u;\n",
1979+
LargeObjectMetadataRelationId);
1980+
1981+
lo_res = PQexec(g_conn, loFrozenQry->data);
1982+
check_sql_result(lo_res, g_conn, loFrozenQry->data, PGRES_TUPLES_OK);
1983+
1984+
if (PQntuples(lo_res) != 1)
1985+
{
1986+
write_msg(NULL, "dumpDatabase(): could not find pg_largeobject_metadata.relfrozenxid\n");
1987+
exit_nicely();
1988+
}
1989+
1990+
i_relfrozenxid = PQfnumber(lo_res, "relfrozenxid");
1991+
1992+
appendPQExpBuffer(loOutQry, "\n-- For binary upgrade, set pg_largeobject_metadata.relfrozenxid\n");
1993+
appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
1994+
"SET relfrozenxid = '%u'\n"
1995+
"WHERE oid = %u;\n",
1996+
atoi(PQgetvalue(lo_res, 0, i_relfrozenxid)),
1997+
LargeObjectMetadataRelationId);
1998+
ArchiveEntry(AH, nilCatalogId, createDumpId(),
1999+
"pg_largeobject_metadata", NULL, NULL, "",
2000+
false, "pg_largeobject_metadata", SECTION_PRE_DATA,
2001+
loOutQry->data, "", NULL,
2002+
NULL, 0,
2003+
NULL, NULL);
2004+
2005+
PQclear(lo_res);
2006+
}
2007+
19632008
destroyPQExpBuffer(loFrozenQry);
19642009
destroyPQExpBuffer(loOutQry);
19652010
}
@@ -12176,7 +12221,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1217612221
}
1217712222
}
1217812223

12179-
appendPQExpBuffer(q, "\n-- For binary upgrade, set relfrozenxid.\n");
12224+
appendPQExpBuffer(q, "\n-- For binary upgrade, set relfrozenxid\n");
1218012225
appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n"
1218112226
"SET relfrozenxid = '%u'\n"
1218212227
"WHERE oid = ",

0 commit comments

Comments
 (0)