@@ -96,7 +96,10 @@ bool g_verbose; /* User wants verbose narration of our
96
96
/* subquery used to convert user ID (eg, datdba) to user name */
97
97
static const char *username_subquery;
98
98
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
+ */
100
103
static Oid g_last_builtin_oid; /* value of the last builtin oid */
101
104
102
105
/* The specified names/patterns should to match at least one entity */
@@ -683,17 +686,24 @@ main(int argc, char **argv)
683
686
exit_horribly(NULL,
684
687
"Exported snapshots are not supported by this server version.\n");
685
688
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)
688
695
{
689
696
if (fout->remoteVersion >= 70100)
690
697
g_last_builtin_oid = findLastBuiltinOid_V71(fout,
691
698
PQdb(GetConnection(fout)));
692
699
else
693
700
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);
696
701
}
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);
697
707
698
708
/* Expand schema selection patterns into OID lists */
699
709
if (schema_include_patterns.head != NULL)
@@ -1507,7 +1517,7 @@ selectDumpableCast(CastInfo *cast, Archive *fout)
1507
1517
* This would be DUMP_COMPONENT_ACL for from-initdb casts, but they do not
1508
1518
* support ACLs currently.
1509
1519
*/
1510
- if (cast->dobj.catId.oid < (Oid) FirstNormalObjectId )
1520
+ if (cast->dobj.catId.oid <= (Oid) g_last_builtin_oid )
1511
1521
cast->dobj.dump = DUMP_COMPONENT_NONE;
1512
1522
else
1513
1523
cast->dobj.dump = fout->dopt->include_everything ?
@@ -1539,7 +1549,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
1539
1549
plang->dobj.dump = DUMP_COMPONENT_NONE;
1540
1550
else
1541
1551
{
1542
- if (plang->dobj.catId.oid < (Oid) FirstNormalObjectId )
1552
+ if (plang->dobj.catId.oid <= (Oid) g_last_builtin_oid )
1543
1553
plang->dobj.dump = fout->remoteVersion < 90600 ?
1544
1554
DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
1545
1555
else
@@ -1565,7 +1575,7 @@ selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
1565
1575
* This would be DUMP_COMPONENT_ACL for from-initdb access methods, but
1566
1576
* they do not support ACLs currently.
1567
1577
*/
1568
- if (method->dobj.catId.oid < (Oid) FirstNormalObjectId )
1578
+ if (method->dobj.catId.oid <= (Oid) g_last_builtin_oid )
1569
1579
method->dobj.dump = DUMP_COMPONENT_NONE;
1570
1580
else
1571
1581
method->dobj.dump = fout->dopt->include_everything ?
@@ -1590,7 +1600,7 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
1590
1600
* change permissions on those objects, if they wish to, and have those
1591
1601
* changes preserved.
1592
1602
*/
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 )
1594
1604
extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_ACL;
1595
1605
else
1596
1606
extinfo->dobj.dump = extinfo->dobj.dump_contains =
@@ -9571,8 +9581,8 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
9571
9581
/*
9572
9582
* We unconditionally create the extension, so we must drop it if it
9573
9583
* exists. This could happen if the user deleted 'plpgsql' and then
9574
- * readded it, causing its oid to be greater than FirstNormalObjectId .
9575
- * The FirstNormalObjectId test was kept to avoid repeatedly dropping
9584
+ * readded it, causing its oid to be greater than g_last_builtin_oid .
9585
+ * The g_last_builtin_oid test was kept to avoid repeatedly dropping
9576
9586
* and recreating extensions like 'plpgsql'.
9577
9587
*/
9578
9588
appendPQExpBuffer(q, "DROP EXTENSION IF EXISTS %s;\n", qextname);
@@ -16284,10 +16294,10 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
16284
16294
}
16285
16295
16286
16296
/*
16287
- * findLastBuiltInOid -
16297
+ * findLastBuiltinOid -
16288
16298
* find the last built in oid
16289
16299
*
16290
- * For 7.1 and 7.2 , we do this by retrieving datlastsysoid from the
16300
+ * For 7.1 through 8.0 , we do this by retrieving datlastsysoid from the
16291
16301
* pg_database entry for the current database
16292
16302
*/
16293
16303
static Oid
@@ -16309,7 +16319,7 @@ findLastBuiltinOid_V71(Archive *fout, const char *dbname)
16309
16319
}
16310
16320
16311
16321
/*
16312
- * findLastBuiltInOid -
16322
+ * findLastBuiltinOid -
16313
16323
* find the last built in oid
16314
16324
*
16315
16325
* For 7.0, we do this by assuming that the last thing that initdb does is to
0 commit comments