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

Commit4374699

Browse files
committed
Fix brown paper bag bug inbbe08b8.
We must issue the TRUNCATE command first and update relfrozenxidand relminmxid afterward; otherwise, TRUNCATE overwrites thepreviously-set values.Add a test case like I should have done the first time.Per buildfarm report from TestUpgradeXversion.pm, by way of TomLane.
1 parent283129e commit4374699

File tree

2 files changed

+55
-9
lines changed

2 files changed

+55
-9
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,7 +3141,7 @@ dumpDatabase(Archive *fout)
31413141
PGresult *lo_res;
31423142
PQExpBuffer loFrozenQry = createPQExpBuffer();
31433143
PQExpBuffer loOutQry = createPQExpBuffer();
3144-
PQExpBufferloVacQry = createPQExpBuffer();
3144+
PQExpBufferloHorizonQry = createPQExpBuffer();
31453145
inti_relfrozenxid,
31463146
i_relfilenode,
31473147
i_oid,
@@ -3168,14 +3168,14 @@ dumpDatabase(Archive *fout)
31683168
i_relfilenode = PQfnumber(lo_res, "relfilenode");
31693169
i_oid = PQfnumber(lo_res, "oid");
31703170

3171-
appendPQExpBufferStr(loOutQry, "\n-- For binary upgrade, set pg_largeobject relfrozenxid and relminmxid\n");
3172-
appendPQExpBufferStr(loVacQry, "\n-- For binary upgrade, preserve pg_largeobject and index relfilenodes\n");
3171+
appendPQExpBufferStr(loHorizonQry, "\n-- For binary upgrade, set pg_largeobject relfrozenxid and relminmxid\n");
3172+
appendPQExpBufferStr(loOutQry, "\n-- For binary upgrade, preserve pg_largeobject and index relfilenodes\n");
31733173
for (int i = 0; i < PQntuples(lo_res); ++i)
31743174
{
31753175
Oidoid;
31763176
RelFileNumberrelfilenumber;
31773177

3178-
appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
3178+
appendPQExpBuffer(loHorizonQry, "UPDATE pg_catalog.pg_class\n"
31793179
"SET relfrozenxid = '%u', relminmxid = '%u'\n"
31803180
"WHERE oid = %u;\n",
31813181
atooid(PQgetvalue(lo_res, i, i_relfrozenxid)),
@@ -3186,18 +3186,18 @@ dumpDatabase(Archive *fout)
31863186
relfilenumber = atooid(PQgetvalue(lo_res, i, i_relfilenode));
31873187

31883188
if (oid == LargeObjectRelationId)
3189-
appendPQExpBuffer(loVacQry,
3189+
appendPQExpBuffer(loOutQry,
31903190
"SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
31913191
relfilenumber);
31923192
else if (oid == LargeObjectLOidPNIndexId)
3193-
appendPQExpBuffer(loVacQry,
3193+
appendPQExpBuffer(loOutQry,
31943194
"SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
31953195
relfilenumber);
31963196
}
31973197

3198-
appendPQExpBufferStr(loVacQry,
3198+
appendPQExpBufferStr(loOutQry,
31993199
"TRUNCATE pg_catalog.pg_largeobject;\n");
3200-
appendPQExpBufferStr(loOutQry,loVacQry->data);
3200+
appendPQExpBufferStr(loOutQry,loHorizonQry->data);
32013201

32023202
ArchiveEntry(fout, nilCatalogId, createDumpId(),
32033203
ARCHIVE_OPTS(.tag = "pg_largeobject",
@@ -3208,8 +3208,8 @@ dumpDatabase(Archive *fout)
32083208
PQclear(lo_res);
32093209

32103210
destroyPQExpBuffer(loFrozenQry);
3211+
destroyPQExpBuffer(loHorizonQry);
32113212
destroyPQExpBuffer(loOutQry);
3212-
destroyPQExpBuffer(loVacQry);
32133213
}
32143214

32153215
PQclear(res);

‎src/bin/pg_upgrade/t/002_pg_upgrade.pl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,27 @@ sub generate_db
161161
],
162162
'dump before running pg_upgrade');
163163

164+
# Also record the relfrozenxid and relminmxid horizons.
165+
my$horizon_query =<<EOM;
166+
SELECT
167+
c.oid::regclass, c.relfrozenxid, c.relminmxid
168+
FROM
169+
pg_class c, pg_namespace n
170+
WHERE
171+
c.relnamespace = n.oid AND
172+
((n.nspname !~ '^pg_temp_' AND n.nspname !~ '^pg_toast_temp_' AND
173+
n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade',
174+
'pg_toast'))
175+
OR (n.nspname = 'pg_catalog' AND relname IN ('pg_largeobject')))
176+
EOM
177+
$horizon_query =~s/\s+//g;# run it together on one line
178+
$newnode->command_ok(
179+
[
180+
'psql','-At','-d',$oldnode->connstr('postgres'),
181+
'-o',"$tempdir/horizon1.txt",'-c',$horizon_query,
182+
],
183+
'horizons before running pg_upgrade');
184+
164185
# After dumping, update references to the old source tree's regress.so
165186
# to point to the new tree.
166187
if (defined($ENV{oldinstall}))
@@ -294,6 +315,14 @@ sub generate_db
294315
],
295316
'dump after running pg_upgrade');
296317

318+
# And second record of horizons as well.
319+
$newnode->command_ok(
320+
[
321+
'psql','-At','-d',$newnode->connstr('postgres'),
322+
'-o',"$tempdir/horizon2.txt",'-c',$horizon_query,
323+
],
324+
'horizons after running pg_upgrade');
325+
297326
# Compare the two dumps, there should be no differences.
298327
my$compare_res = compare("$tempdir/dump1.sql","$tempdir/dump2.sql");
299328
is($compare_res, 0,'old and new dumps match after pg_upgrade');
@@ -311,4 +340,21 @@ sub generate_db
311340
print"=== EOF ===\n";
312341
}
313342

343+
# Compare the horizons, there should be no differences.
344+
$compare_res = compare("$tempdir/horizon1.txt","$tempdir/horizon2.txt");
345+
is($compare_res, 0,'old and new horizons match after pg_upgrade');
346+
347+
# Provide more context if the horizons do not match.
348+
if ($compare_res != 0)
349+
{
350+
my ($stdout,$stderr) =
351+
run_command(['diff',"$tempdir/horizon1.txt","$tempdir/horizon2.txt" ]);
352+
print"=== diff of$tempdir/horizon1.txt and$tempdir/horizon2.txt\n";
353+
print"=== stdout ===\n";
354+
print$stdout;
355+
print"=== stderr ===\n";
356+
print$stderr;
357+
print"=== EOF ===\n";
358+
}
359+
314360
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp