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

Commit12a53c7

Browse files
committed
Fix pg_upgrade for oid removal.
pg_upgrade previously copied pg_largeobject_metadata over from the oldcluster. That doesn't work, because the table has oids before578b229. I missed that.As most pieces of metadata for large objects already were dumped asDDL (except for comments overwritten by pg_upgrade, due to the copy ofpg_largeobject_metadata) it seems reasonable to just also dump grantsfor large objects. If we ever consider this a relevant performanceproblem, we'd need to fix the rest of the already emitted DDLtoo.There's still an open discussion about whether we'll want to force aspecific ordering for the dumped objects, as currentlypg_largeobjects_metadata potentially has a different orderingbefore/after pg_upgrade, which can make automated testing a bitharder.Reported-By: Andrew DunstanAuthor: Andres FreundDiscussion:https://postgr.es/m/91a8a980-41bc-412b-fba2-2ba71a141c2b@2ndQuadrant.com
1 parent70d7e50 commit12a53c7

File tree

4 files changed

+15
-62
lines changed

4 files changed

+15
-62
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,8 +2866,8 @@ dumpDatabase(Archive *fout)
28662866
NULL, NULL);
28672867

28682868
/*
2869-
* pg_largeobjectand pg_largeobject_metadata comefrom the old system
2870-
*intact, so set theirrelfrozenxids and relminmxids.
2869+
* pg_largeobjectcomesfrom the old system intact, so set its
2870+
* relfrozenxids and relminmxids.
28712871
*/
28722872
if (dopt->binary_upgrade)
28732873
{
@@ -2912,47 +2912,6 @@ dumpDatabase(Archive *fout)
29122912

29132913
PQclear(lo_res);
29142914

2915-
/*
2916-
* pg_largeobject_metadata
2917-
*/
2918-
if (fout->remoteVersion >= 90000)
2919-
{
2920-
resetPQExpBuffer(loFrozenQry);
2921-
resetPQExpBuffer(loOutQry);
2922-
2923-
if (fout->remoteVersion >= 90300)
2924-
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, relminmxid\n"
2925-
"FROM pg_catalog.pg_class\n"
2926-
"WHERE oid = %u;\n",
2927-
LargeObjectMetadataRelationId);
2928-
else
2929-
appendPQExpBuffer(loFrozenQry, "SELECT relfrozenxid, 0 AS relminmxid\n"
2930-
"FROM pg_catalog.pg_class\n"
2931-
"WHERE oid = %u;\n",
2932-
LargeObjectMetadataRelationId);
2933-
2934-
lo_res = ExecuteSqlQueryForSingleRow(fout, loFrozenQry->data);
2935-
2936-
i_relfrozenxid = PQfnumber(lo_res, "relfrozenxid");
2937-
i_relminmxid = PQfnumber(lo_res, "relminmxid");
2938-
2939-
appendPQExpBufferStr(loOutQry, "\n-- For binary upgrade, set pg_largeobject_metadata relfrozenxid and relminmxid\n");
2940-
appendPQExpBuffer(loOutQry, "UPDATE pg_catalog.pg_class\n"
2941-
"SET relfrozenxid = '%u', relminmxid = '%u'\n"
2942-
"WHERE oid = %u;\n",
2943-
atooid(PQgetvalue(lo_res, 0, i_relfrozenxid)),
2944-
atooid(PQgetvalue(lo_res, 0, i_relminmxid)),
2945-
LargeObjectMetadataRelationId);
2946-
ArchiveEntry(fout, nilCatalogId, createDumpId(),
2947-
"pg_largeobject_metadata", NULL, NULL, "",
2948-
"pg_largeobject_metadata", SECTION_PRE_DATA,
2949-
loOutQry->data, "", NULL,
2950-
NULL, 0,
2951-
NULL, NULL);
2952-
2953-
PQclear(lo_res);
2954-
}
2955-
29562915
destroyPQExpBuffer(loFrozenQry);
29572916
destroyPQExpBuffer(loOutQry);
29582917
}
@@ -3266,18 +3225,14 @@ getBlobs(Archive *fout)
32663225
binfo[i].dobj.dump &= ~DUMP_COMPONENT_ACL;
32673226

32683227
/*
3269-
* In binary-upgrade mode for blobs, we do *not* dump out the data or
3270-
* the ACLs, should any exist. The data and ACL (if any) will be
3271-
* copied by pg_upgrade, which simply copies the pg_largeobject and
3272-
* pg_largeobject_metadata tables.
3273-
*
3274-
* We *do* dump out the definition of the blob because we need that to
3275-
* make the restoration of the comments, and anything else, work since
3276-
* pg_upgrade copies the files behind pg_largeobject and
3277-
* pg_largeobject_metadata after the dump is restored.
3228+
* In binary-upgrade mode for blobs, we do *not* dump out the blob
3229+
* data, as it will be copied by pg_upgrade, which simply copies the
3230+
* pg_largeobject table. We *do* however dump out anything but the
3231+
* data, as pg_upgrade copies just pg_largeobject, but not
3232+
* pg_largeobject_metadata, after the dump is restored.
32783233
*/
32793234
if (dopt->binary_upgrade)
3280-
binfo[i].dobj.dump &= ~(DUMP_COMPONENT_DATA | DUMP_COMPONENT_ACL);
3235+
binfo[i].dobj.dump &= ~DUMP_COMPONENT_DATA;
32813236
}
32823237

32833238
/*

‎src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2791,9 +2791,9 @@
27912791
data_only => 1,
27922792
section_pre_data => 1,
27932793
test_schema_plus_blobs => 1,
2794+
binary_upgrade => 1,
27942795
},
27952796
unlike => {
2796-
binary_upgrade => 1,
27972797
no_blobs => 1,
27982798
no_privs => 1,
27992799
schema_only => 1,

‎src/bin/pg_upgrade/info.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
441441
*
442442
* pg_largeobject contains user data that does not appear in pg_dump
443443
* output, so we have to copy that system table. It's easiest to do that
444-
* by treating it as a user table. Likewise for pg_largeobject_metadata,
445-
* if it exists.
444+
* by treating it as a user table.
446445
*/
447446
snprintf(query+strlen(query),sizeof(query)-strlen(query),
448447
"WITH regular_heap (reloid, indtable, toastheap) AS ( "
@@ -458,10 +457,8 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
458457
" 'binary_upgrade', 'pg_toast') AND "
459458
" c.oid >= %u::pg_catalog.oid) OR "
460459
" (n.nspname = 'pg_catalog' AND "
461-
" relname IN ('pg_largeobject'%s) ))), ",
462-
FirstNormalObjectId,
463-
(GET_MAJOR_VERSION(old_cluster.major_version) >=900) ?
464-
", 'pg_largeobject_metadata'" :"");
460+
" relname IN ('pg_largeobject') ))), ",
461+
FirstNormalObjectId);
465462

466463
/*
467464
* Add a CTE that collects OIDs of toast tables belonging to the tables

‎src/bin/pg_upgrade/pg_upgrade.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
*We control all assignments of pg_enum.oid because these oids are stored
2929
*in user tables as enum values.
3030
*
31-
*We control all assignments of pg_authid.oid because these oids are stored
32-
*in pg_largeobject_metadata.
31+
*We control all assignments of pg_authid.oid for historical reasons (the
32+
*oids used to be stored in pg_largeobject_metadata, which is now copied via
33+
*SQL commands), that might change at some point in the future.
3334
*/
3435

3536

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp