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

Commite45319b

Browse files
committed
For 8.0 servers, get last built-in oid from pg_database
We didn't start ensuring that all built-in objects had OIDs less than16384 until 8.1, so for 8.0 servers we still need to query the value outof pg_database. We need this, in particular, to distinguish which castswere built-in and which were user-defined.For HEAD, we only worry about going back to 8.0, for the back-branches,we also ensure that 7.0-7.4 work.Discussion:https://www.postgresql.org/message-id/flat/20160504183952.GE10850%40tamriel.snowman.net
1 parenta46ee6b commite45319b

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ boolg_verbose;/* User wants verbose narration of our
9696
/* subquery used to convert user ID (eg, datdba) to user name */
9797
static const char *username_subquery;
9898

99-
/* obsolete as of 7.3: */
99+
/*
100+
* For 8.0 and earlier servers, pulled from pg_database, for 8.1+ we use
101+
* FirstNormalObjectId - 1.
102+
*/
100103
static Oidg_last_builtin_oid; /* value of the last builtin oid */
101104

102105
/* The specified names/patterns should to match at least one entity */
@@ -683,17 +686,24 @@ main(int argc, char **argv)
683686
exit_horribly(NULL,
684687
"Exported snapshots are not supported by this server version.\n");
685688

686-
/* Find the last built-in OID, if needed */
687-
if (fout->remoteVersion < 70300)
689+
/*
690+
* Find the last built-in OID, if needed (prior to 8.1)
691+
*
692+
* With 8.1 and above, we can just use FirstNormalObjectId - 1.
693+
*/
694+
if (fout->remoteVersion < 80100)
688695
{
689696
if (fout->remoteVersion >= 70100)
690697
g_last_builtin_oid = findLastBuiltinOid_V71(fout,
691698
PQdb(GetConnection(fout)));
692699
else
693700
g_last_builtin_oid = findLastBuiltinOid_V70(fout);
694-
if (g_verbose)
695-
write_msg(NULL, "last built-in OID is %u\n", g_last_builtin_oid);
696701
}
702+
else
703+
g_last_builtin_oid = FirstNormalObjectId - 1;
704+
705+
if (g_verbose)
706+
write_msg(NULL, "last built-in OID is %u\n", g_last_builtin_oid);
697707

698708
/* Expand schema selection patterns into OID lists */
699709
if (schema_include_patterns.head != NULL)
@@ -1507,7 +1517,7 @@ selectDumpableCast(CastInfo *cast, Archive *fout)
15071517
* This would be DUMP_COMPONENT_ACL for from-initdb casts, but they do not
15081518
* support ACLs currently.
15091519
*/
1510-
if (cast->dobj.catId.oid < (Oid)FirstNormalObjectId)
1520+
if (cast->dobj.catId.oid <= (Oid)g_last_builtin_oid)
15111521
cast->dobj.dump = DUMP_COMPONENT_NONE;
15121522
else
15131523
cast->dobj.dump = fout->dopt->include_everything ?
@@ -1539,7 +1549,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
15391549
plang->dobj.dump = DUMP_COMPONENT_NONE;
15401550
else
15411551
{
1542-
if (plang->dobj.catId.oid < (Oid)FirstNormalObjectId)
1552+
if (plang->dobj.catId.oid <= (Oid)g_last_builtin_oid)
15431553
plang->dobj.dump = fout->remoteVersion < 90600 ?
15441554
DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
15451555
else
@@ -1565,7 +1575,7 @@ selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
15651575
* This would be DUMP_COMPONENT_ACL for from-initdb access methods, but
15661576
* they do not support ACLs currently.
15671577
*/
1568-
if (method->dobj.catId.oid < (Oid)FirstNormalObjectId)
1578+
if (method->dobj.catId.oid <= (Oid)g_last_builtin_oid)
15691579
method->dobj.dump = DUMP_COMPONENT_NONE;
15701580
else
15711581
method->dobj.dump = fout->dopt->include_everything ?
@@ -1590,7 +1600,7 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
15901600
* change permissions on those objects, if they wish to, and have those
15911601
* changes preserved.
15921602
*/
1593-
if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid)FirstNormalObjectId)
1603+
if (dopt->binary_upgrade && extinfo->dobj.catId.oid <= (Oid)g_last_builtin_oid)
15941604
extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_ACL;
15951605
else
15961606
extinfo->dobj.dump = extinfo->dobj.dump_contains =
@@ -9571,8 +9581,8 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
95719581
/*
95729582
* We unconditionally create the extension, so we must drop it if it
95739583
* exists. This could happen if the user deleted 'plpgsql' and then
9574-
* readded it, causing its oid to be greater thanFirstNormalObjectId.
9575-
* TheFirstNormalObjectId test was kept to avoid repeatedly dropping
9584+
* readded it, causing its oid to be greater thang_last_builtin_oid.
9585+
* Theg_last_builtin_oid test was kept to avoid repeatedly dropping
95769586
* and recreating extensions like 'plpgsql'.
95779587
*/
95789588
appendPQExpBuffer(q, "DROP EXTENSION IF EXISTS %s;\n", qextname);
@@ -16284,10 +16294,10 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
1628416294
}
1628516295

1628616296
/*
16287-
*findLastBuiltInOid -
16297+
*findLastBuiltinOid -
1628816298
* find the last built in oid
1628916299
*
16290-
* For 7.1and 7.2, we do this by retrieving datlastsysoid from the
16300+
* For 7.1through 8.0, we do this by retrieving datlastsysoid from the
1629116301
* pg_database entry for the current database
1629216302
*/
1629316303
static Oid
@@ -16309,7 +16319,7 @@ findLastBuiltinOid_V71(Archive *fout, const char *dbname)
1630916319
}
1631016320

1631116321
/*
16312-
*findLastBuiltInOid -
16322+
*findLastBuiltinOid -
1631316323
* find the last built in oid
1631416324
*
1631516325
* For 7.0, we do this by assuming that the last thing that initdb does is to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp