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

Commitfc03f7d

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 parente71fe84 commitfc03f7d

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ const char *lockWaitTimeout;
9999
/* subquery used to convert user ID (eg, datdba) to user name */
100100
staticconstchar*username_subquery;
101101

102-
/* obsolete as of 7.3: */
102+
/*
103+
* For 8.0 and earlier servers, pulled from pg_database, for 8.1+ we use
104+
* FirstNormalObjectId - 1.
105+
*/
103106
staticOidg_last_builtin_oid;/* value of the last builtin oid */
104107

105108
/*
@@ -697,17 +700,24 @@ main(int argc, char **argv)
697700
"Run with --no-synchronized-snapshots instead if you do not need\n"
698701
"synchronized snapshots.\n");
699702

700-
/* Find the last built-in OID, if needed */
701-
if (fout->remoteVersion<70300)
703+
/*
704+
* Find the last built-in OID, if needed (prior to 8.1)
705+
*
706+
* With 8.1 and above, we can just use FirstNormalObjectId - 1.
707+
*/
708+
if (fout->remoteVersion<80100)
702709
{
703710
if (fout->remoteVersion >=70100)
704711
g_last_builtin_oid=findLastBuiltinOid_V71(fout,
705712
PQdb(GetConnection(fout)));
706713
else
707714
g_last_builtin_oid=findLastBuiltinOid_V70(fout);
708-
if (g_verbose)
709-
write_msg(NULL,"last built-in OID is %u\n",g_last_builtin_oid);
710715
}
716+
else
717+
g_last_builtin_oid=FirstNormalObjectId-1;
718+
719+
if (g_verbose)
720+
write_msg(NULL,"last built-in OID is %u\n",g_last_builtin_oid);
711721

712722
/* Expand schema selection patterns into OID lists */
713723
if (schema_include_patterns.head!=NULL)
@@ -1419,7 +1429,7 @@ selectDumpableCast(CastInfo *cast)
14191429
if (checkExtensionMembership(&cast->dobj))
14201430
return;/* extension membership overrides all else */
14211431

1422-
if (cast->dobj.catId.oid< (Oid)FirstNormalObjectId)
1432+
if (cast->dobj.catId.oid <= (Oid)g_last_builtin_oid)
14231433
cast->dobj.dump= false;
14241434
else
14251435
cast->dobj.dump=include_everything;
@@ -1439,7 +1449,7 @@ selectDumpableProcLang(ProcLangInfo *plang)
14391449
if (checkExtensionMembership(&plang->dobj))
14401450
return;/* extension membership overrides all else */
14411451

1442-
if (plang->dobj.catId.oid< (Oid)FirstNormalObjectId)
1452+
if (plang->dobj.catId.oid <= (Oid)g_last_builtin_oid)
14431453
plang->dobj.dump= false;
14441454
else
14451455
plang->dobj.dump=include_everything;
@@ -1458,7 +1468,7 @@ selectDumpableProcLang(ProcLangInfo *plang)
14581468
staticvoid
14591469
selectDumpableExtension(ExtensionInfo*extinfo)
14601470
{
1461-
if (binary_upgrade&&extinfo->dobj.catId.oid< (Oid)FirstNormalObjectId)
1471+
if (binary_upgrade&&extinfo->dobj.catId.oid <= (Oid)g_last_builtin_oid)
14621472
extinfo->dobj.dump= false;
14631473
else
14641474
extinfo->dobj.dump=include_everything;
@@ -8032,8 +8042,8 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
80328042
/*
80338043
* We unconditionally create the extension, so we must drop it if it
80348044
* exists. This could happen if the user deleted 'plpgsql' and then
8035-
* readded it, causing its oid to be greater thanFirstNormalObjectId.
8036-
* TheFirstNormalObjectId test was kept to avoid repeatedly dropping
8045+
* readded it, causing its oid to be greater thang_last_builtin_oid.
8046+
* Theg_last_builtin_oid test was kept to avoid repeatedly dropping
80378047
* and recreating extensions like 'plpgsql'.
80388048
*/
80398049
appendPQExpBuffer(q,"DROP EXTENSION IF EXISTS %s;\n",qextname);
@@ -13920,10 +13930,10 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
1392013930
}
1392113931

1392213932
/*
13923-
*findLastBuiltInOid -
13933+
*findLastBuiltinOid -
1392413934
* find the last built in oid
1392513935
*
13926-
* For 7.1and 7.2, we do this by retrieving datlastsysoid from the
13936+
* For 7.1through 8.0, we do this by retrieving datlastsysoid from the
1392713937
* pg_database entry for the current database
1392813938
*/
1392913939
staticOid
@@ -13945,7 +13955,7 @@ findLastBuiltinOid_V71(Archive *fout, const char *dbname)
1394513955
}
1394613956

1394713957
/*
13948-
*findLastBuiltInOid -
13958+
*findLastBuiltinOid -
1394913959
* find the last built in oid
1395013960
*
1395113961
* 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