Skip to content

Commit 4e03b82

Browse files
committed
Properly restore pg_largeobject.relfozenxid in binary upgrade mode.
Backpatch to 8.4.X.
1 parent 396a493 commit 4e03b82

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.540 2009/07/02 21:34:32 tgl Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.541 2009/07/20 20:53:40 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -34,6 +34,7 @@
3434
#include "access/sysattr.h"
3535
#include "catalog/pg_cast.h"
3636
#include "catalog/pg_class.h"
37+
#include "catalog/pg_largeobject.h"
3738
#include "catalog/pg_proc.h"
3839
#include "catalog/pg_trigger.h"
3940
#include "catalog/pg_type.h"
@@ -1739,6 +1740,7 @@ dumpDatabase(Archive *AH)
17391740
frozenxid);
17401741
appendStringLiteralAH(creaQry, datname, AH);
17411742
appendPQExpBuffer(creaQry, ";\n");
1743+
17421744
}
17431745

17441746
appendPQExpBuffer(delQry, "DROP DATABASE %s;\n",
@@ -1764,6 +1766,51 @@ dumpDatabase(Archive *AH)
17641766
NULL, /* Dumper */
17651767
NULL); /* Dumper Arg */
17661768

1769+
/*
1770+
* pg_largeobject comes from the old system intact, so set
1771+
* its relfrozenxid.
1772+
*/
1773+
if (binary_upgrade)
1774+
{
1775+
PGresult *lo_res;
1776+
PQExpBuffer loFrozenQry = createPQExpBuffer();
1777+
PQExpBuffer loOutQry = createPQExpBuffer();
1778+
int i_relfrozenxid;
1779+
1780+
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid\n"
1781+
"FROM pg_catalog.pg_class\n"
1782+
"WHERE oid = %d;\n",
1783+
LargeObjectRelationId);
1784+
1785+
lo_res = PQexec(g_conn, loFrozenQry->data);
1786+
check_sql_result(lo_res, g_conn, loFrozenQry->data, PGRES_TUPLES_OK);
1787+
1788+
if (PQntuples(lo_res) != 1)
1789+
{
1790+
write_msg(NULL, "dumpDatabase(): could not find pg_largeobject.relfrozenxid\n");
1791+
exit_nicely();
1792+
}
1793+
1794+
i_relfrozenxid = PQfnumber(lo_res, "relfrozenxid");
1795+
1796+
appendPQExpBuffer(loOutQry, "\n-- For binary upgrade, set pg_largeobject relfrozenxid.\n");
1797+
appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
1798+
"SET relfrozenxid = '%u'\n"
1799+
"WHERE oid = %d;\n",
1800+
atoi(PQgetvalue(lo_res, 0, i_relfrozenxid)),
1801+
LargeObjectRelationId);
1802+
ArchiveEntry(AH, nilCatalogId, createDumpId(),
1803+
"pg_largeobject", NULL, NULL, "",
1804+
false, "pg_largeobject", SECTION_PRE_DATA,
1805+
loOutQry->data, "", NULL,
1806+
NULL, 0,
1807+
NULL, NULL);
1808+
1809+
PQclear(lo_res);
1810+
destroyPQExpBuffer(loFrozenQry);
1811+
destroyPQExpBuffer(loOutQry);
1812+
}
1813+
17671814
/* Dump DB comment if any */
17681815
if (g_fout->remoteVersion >= 80200)
17691816
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy