aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 03531405e02..5b9f5751e47 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -94,7 +94,10 @@ bool g_verbose; /* User wants verbose narration of our
/* subquery used to convert user ID (eg, datdba) to user name */
static const char *username_subquery;
-/* obsolete as of 7.3: */
+/*
+ * For 8.0 and earlier servers, pulled from pg_database, for 8.1+ we use
+ * FirstNormalObjectId - 1.
+ */
static Oid g_last_builtin_oid; /* value of the last builtin oid */
/*
@@ -673,17 +676,24 @@ main(int argc, char **argv)
exit_horribly(NULL,
"Exported snapshots are not supported by this server version.\n");
- /* Find the last built-in OID, if needed */
- if (fout->remoteVersion < 70300)
+ /*
+ * Find the last built-in OID, if needed (prior to 8.1)
+ *
+ * With 8.1 and above, we can just use FirstNormalObjectId - 1.
+ */
+ if (fout->remoteVersion < 80100)
{
if (fout->remoteVersion >= 70100)
g_last_builtin_oid = findLastBuiltinOid_V71(fout,
PQdb(GetConnection(fout)));
else
g_last_builtin_oid = findLastBuiltinOid_V70(fout);
- if (g_verbose)
- write_msg(NULL, "last built-in OID is %u\n", g_last_builtin_oid);
}
+ else
+ g_last_builtin_oid = FirstNormalObjectId - 1;
+
+ if (g_verbose)
+ write_msg(NULL, "last built-in OID is %u\n", g_last_builtin_oid);
/* Expand schema selection patterns into OID lists */
if (schema_include_patterns.head != NULL)
@@ -1440,7 +1450,7 @@ selectDumpableCast(CastInfo *cast, DumpOptions *dopt)
if (checkExtensionMembership(&cast->dobj, dopt))
return; /* extension membership overrides all else */
- if (cast->dobj.catId.oid < (Oid) FirstNormalObjectId)
+ if (cast->dobj.catId.oid <= (Oid) g_last_builtin_oid)
cast->dobj.dump = false;
else
cast->dobj.dump = dopt->include_everything;
@@ -1460,7 +1470,7 @@ selectDumpableProcLang(ProcLangInfo *plang, DumpOptions *dopt)
if (checkExtensionMembership(&plang->dobj, dopt))
return; /* extension membership overrides all else */
- if (plang->dobj.catId.oid < (Oid) FirstNormalObjectId)
+ if (plang->dobj.catId.oid <= (Oid) g_last_builtin_oid)
plang->dobj.dump = false;
else
plang->dobj.dump = dopt->include_everything;
@@ -1479,7 +1489,7 @@ selectDumpableProcLang(ProcLangInfo *plang, DumpOptions *dopt)
static void
selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
{
- if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
+ if (dopt->binary_upgrade && extinfo->dobj.catId.oid <= (Oid) g_last_builtin_oid)
extinfo->dobj.dump = false;
else
extinfo->dobj.dump = dopt->include_everything;
@@ -8630,8 +8640,8 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
/*
* We unconditionally create the extension, so we must drop it if it
* exists. This could happen if the user deleted 'plpgsql' and then
- * readded it, causing its oid to be greater than FirstNormalObjectId.
- * The FirstNormalObjectId test was kept to avoid repeatedly dropping
+ * readded it, causing its oid to be greater than g_last_builtin_oid.
+ * The g_last_builtin_oid test was kept to avoid repeatedly dropping
* and recreating extensions like 'plpgsql'.
*/
appendPQExpBuffer(q, "DROP EXTENSION IF EXISTS %s;\n", qextname);
@@ -14946,10 +14956,10 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
}
/*
- * findLastBuiltInOid -
+ * findLastBuiltinOid -
* find the last built in oid
*
- * For 7.1 and 7.2, we do this by retrieving datlastsysoid from the
+ * For 7.1 through 8.0, we do this by retrieving datlastsysoid from the
* pg_database entry for the current database
*/
static Oid
@@ -14971,7 +14981,7 @@ findLastBuiltinOid_V71(Archive *fout, const char *dbname)
}
/*
- * findLastBuiltInOid -
+ * findLastBuiltinOid -
* find the last built in oid
*
* For 7.0, we do this by assuming that the last thing that initdb does is to