aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/genbki.pl33
-rw-r--r--src/include/access/transam.h14
-rw-r--r--src/include/catalog/catversion.h2
3 files changed, 33 insertions, 16 deletions
diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index f893ae4f453..81363a0710d 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -167,15 +167,17 @@ foreach my $oid (keys %oidcounts)
die "found $found duplicate OID(s) in catalog data\n" if $found;
-# Oids not specified in the input files are automatically assigned,
+# OIDs not specified in the input files are automatically assigned,
# starting at FirstGenbkiObjectId, extending up to FirstBootstrapObjectId.
+# We allow such OIDs to be assigned independently within each catalog.
my $FirstGenbkiObjectId =
Catalog::FindDefinedSymbol('access/transam.h', $include_path,
'FirstGenbkiObjectId');
my $FirstBootstrapObjectId =
Catalog::FindDefinedSymbol('access/transam.h', $include_path,
'FirstBootstrapObjectId');
-my $GenbkiNextOid = $FirstGenbkiObjectId;
+# Hash of next available OID, indexed by catalog name.
+my %GenbkiNextOids;
# Fetch some special data that we will substitute into the output file.
@@ -563,8 +565,7 @@ EOM
# Assign oid if oid column exists and no explicit assignment in row
if ($attname eq "oid" and not defined $bki_values{$attname})
{
- $bki_values{$attname} = $GenbkiNextOid;
- $GenbkiNextOid++;
+ $bki_values{$attname} = assign_next_oid($catname);
}
# Replace OID synonyms with OIDs per the appropriate lookup rule.
@@ -669,11 +670,6 @@ foreach my $declaration (@index_decls)
# last command in the BKI file: build the indexes declared above
print $bki "build indices\n";
-# check that we didn't overrun available OIDs
-die
- "genbki OID counter reached $GenbkiNextOid, overrunning FirstBootstrapObjectId\n"
- if $GenbkiNextOid > $FirstBootstrapObjectId;
-
# Now generate system_constraints.sql
foreach my $c (@system_constraints)
@@ -1079,6 +1075,25 @@ sub form_pg_type_symbol
return $name . $arraystr . 'OID';
}
+# Assign an unused OID within the specified catalog.
+sub assign_next_oid
+{
+ my $catname = shift;
+
+ # Initialize, if no previous request for this catalog.
+ $GenbkiNextOids{$catname} = $FirstGenbkiObjectId
+ if !defined($GenbkiNextOids{$catname});
+
+ my $result = $GenbkiNextOids{$catname}++;
+
+ # Check that we didn't overrun available OIDs
+ die
+ "genbki OID counter for $catname reached $result, overrunning FirstBootstrapObjectId\n"
+ if $result >= $FirstBootstrapObjectId;
+
+ return $result;
+}
+
sub usage
{
die <<EOM;
diff --git a/src/include/access/transam.h b/src/include/access/transam.h
index 05c6fbffe44..2fe8a591105 100644
--- a/src/include/access/transam.h
+++ b/src/include/access/transam.h
@@ -161,18 +161,20 @@ FullTransactionIdAdvance(FullTransactionId *dest)
* development purposes (such as in-progress patches and forks);
* they should not appear in released versions.
*
- * OIDs 10000-12999 are reserved for assignment by genbki.pl, for use
+ * OIDs 10000-11999 are reserved for assignment by genbki.pl, for use
* when the .dat files in src/include/catalog/ do not specify an OID
- * for a catalog entry that requires one.
+ * for a catalog entry that requires one. Note that genbki.pl assigns
+ * these OIDs independently in each catalog, so they're not guaranteed
+ * to be globally unique.
*
- * OIDS 13000-16383 are reserved for assignment during initdb
- * using the OID generator. (We start the generator at 13000.)
+ * OIDS 12000-16383 are reserved for assignment during initdb
+ * using the OID generator. (We start the generator at 12000.)
*
* OIDs beginning at 16384 are assigned from the OID generator
* during normal multiuser operation. (We force the generator up to
* 16384 as soon as we are in normal operation.)
*
- * The choices of 8000, 10000 and 13000 are completely arbitrary, and can be
+ * The choices of 8000, 10000 and 12000 are completely arbitrary, and can be
* moved if we run low on OIDs in any category. Changing the macros below,
* and updating relevant documentation (see bki.sgml and RELEASE_CHANGES),
* should be sufficient to do this. Moving the 16384 boundary between
@@ -186,7 +188,7 @@ FullTransactionIdAdvance(FullTransactionId *dest)
* ----------
*/
#define FirstGenbkiObjectId 10000
-#define FirstBootstrapObjectId 13000
+#define FirstBootstrapObjectId 12000
#define FirstNormalObjectId 16384
/*
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 9fe49fa2911..1fa30abb298 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202105271
+#define CATALOG_VERSION_NO 202105272
#endif