@@ -99,7 +99,10 @@ const char *lockWaitTimeout;
99
99
/* subquery used to convert user ID (eg, datdba) to user name */
100
100
static const char * username_subquery ;
101
101
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
+ */
103
106
static Oid g_last_builtin_oid ; /* value of the last builtin oid */
104
107
105
108
/*
@@ -697,17 +700,24 @@ main(int argc, char **argv)
697
700
"Run with --no-synchronized-snapshots instead if you do not need\n"
698
701
"synchronized snapshots.\n" );
699
702
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 )
702
709
{
703
710
if (fout -> remoteVersion >= 70100 )
704
711
g_last_builtin_oid = findLastBuiltinOid_V71 (fout ,
705
712
PQdb (GetConnection (fout )));
706
713
else
707
714
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 );
710
715
}
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 );
711
721
712
722
/* Expand schema selection patterns into OID lists */
713
723
if (schema_include_patterns .head != NULL )
@@ -1419,7 +1429,7 @@ selectDumpableCast(CastInfo *cast)
1419
1429
if (checkExtensionMembership (& cast -> dobj ))
1420
1430
return ; /* extension membership overrides all else */
1421
1431
1422
- if (cast -> dobj .catId .oid < (Oid ) FirstNormalObjectId )
1432
+ if (cast -> dobj .catId .oid <= (Oid ) g_last_builtin_oid )
1423
1433
cast -> dobj .dump = false;
1424
1434
else
1425
1435
cast -> dobj .dump = include_everything ;
@@ -1439,7 +1449,7 @@ selectDumpableProcLang(ProcLangInfo *plang)
1439
1449
if (checkExtensionMembership (& plang -> dobj ))
1440
1450
return ; /* extension membership overrides all else */
1441
1451
1442
- if (plang -> dobj .catId .oid < (Oid ) FirstNormalObjectId )
1452
+ if (plang -> dobj .catId .oid <= (Oid ) g_last_builtin_oid )
1443
1453
plang -> dobj .dump = false;
1444
1454
else
1445
1455
plang -> dobj .dump = include_everything ;
@@ -1458,7 +1468,7 @@ selectDumpableProcLang(ProcLangInfo *plang)
1458
1468
static void
1459
1469
selectDumpableExtension (ExtensionInfo * extinfo )
1460
1470
{
1461
- if (binary_upgrade && extinfo -> dobj .catId .oid < (Oid ) FirstNormalObjectId )
1471
+ if (binary_upgrade && extinfo -> dobj .catId .oid <= (Oid ) g_last_builtin_oid )
1462
1472
extinfo -> dobj .dump = false;
1463
1473
else
1464
1474
extinfo -> dobj .dump = include_everything ;
@@ -8032,8 +8042,8 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
8032
8042
/*
8033
8043
* We unconditionally create the extension, so we must drop it if it
8034
8044
* exists. This could happen if the user deleted 'plpgsql' and then
8035
- * readded it, causing its oid to be greater than FirstNormalObjectId .
8036
- * The FirstNormalObjectId test was kept to avoid repeatedly dropping
8045
+ * readded it, causing its oid to be greater than g_last_builtin_oid .
8046
+ * The g_last_builtin_oid test was kept to avoid repeatedly dropping
8037
8047
* and recreating extensions like 'plpgsql'.
8038
8048
*/
8039
8049
appendPQExpBuffer (q , "DROP EXTENSION IF EXISTS %s;\n" , qextname );
@@ -13920,10 +13930,10 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
13920
13930
}
13921
13931
13922
13932
/*
13923
- * findLastBuiltInOid -
13933
+ * findLastBuiltinOid -
13924
13934
* find the last built in oid
13925
13935
*
13926
- * For 7.1 and 7.2 , we do this by retrieving datlastsysoid from the
13936
+ * For 7.1 through 8.0 , we do this by retrieving datlastsysoid from the
13927
13937
* pg_database entry for the current database
13928
13938
*/
13929
13939
static Oid
@@ -13945,7 +13955,7 @@ findLastBuiltinOid_V71(Archive *fout, const char *dbname)
13945
13955
}
13946
13956
13947
13957
/*
13948
- * findLastBuiltInOid -
13958
+ * findLastBuiltinOid -
13949
13959
* find the last built in oid
13950
13960
*
13951
13961
* For 7.0, we do this by assuming that the last thing that initdb does is to
0 commit comments