Skip to content

Commit 401b87a

Browse files
committed
Sync commentary in transam.h and bki.sgml.
Commit a641707 missed updating some comments in transam.h about reservation of high OIDs for development purposes. Also tamp down an over-optimistic comment there about how easy it'd be to change FirstNormalObjectId. Earlier, commit 09568ec failed to update bki.sgml for the split between genbki.pl-assigned OIDs and those assigned during initdb. Also fix genbki.pl so that it will complain if it overruns that split. It's possible that doing so would have no very bad consequences, but that's no excuse for not detecting it.
1 parent 364298b commit 401b87a

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

doc/src/sgml/bki.sgml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,19 +422,21 @@
422422
</para>
423423

424424
<para>
425-
The OID counter starts at 10000 at the beginning of a bootstrap run.
426-
If a row from a source other than <filename>postgres.bki</filename>
427-
is inserted into a table that requires OIDs, then it will receive an
428-
OID of 10000 or above. For example, objects created while running
429-
the <filename>information_schema.sql</filename> script receive such
430-
OIDs.
425+
If <filename>genbki.pl</filename> needs to assign an OID to a catalog
426+
entry that does not have a manually-assigned OID, it will use a value in
427+
the range 10000&mdash;11999. The server's OID counter is set to 12000
428+
at the start of a bootstrap run. Thus objects created by regular SQL
429+
commands during the later phases of bootstrap, such as objects created
430+
while running the <filename>information_schema.sql</filename> script,
431+
receive OIDs of 12000 or above.
431432
</para>
432433

433434
<para>
434435
OIDs assigned during normal database operation are constrained to be
435-
16384 or higher. This leaves the range 10000&mdash;16383 available
436-
for OIDs assigned automatically during bootstrap. These OIDs are not
437-
considered stable, and may change from one installation to another.
436+
16384 or higher. This ensures that the range 10000&mdash;16383 is free
437+
for OIDs assigned automatically by <filename>genbki.pl</filename> or
438+
during bootstrap. These automatically-assigned OIDs are not considered
439+
stable, and may change from one installation to another.
438440
</para>
439441
</sect2>
440442

src/backend/catalog/genbki.pl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@
138138

139139

140140
# Oids not specified in the input files are automatically assigned,
141-
# starting at FirstGenbkiObjectId.
141+
# starting at FirstGenbkiObjectId, extending up to FirstBootstrapObjectId.
142142
my $FirstGenbkiObjectId =
143143
Catalog::FindDefinedSymbol('access/transam.h', $include_path,
144144
'FirstGenbkiObjectId');
145+
my $FirstBootstrapObjectId =
146+
Catalog::FindDefinedSymbol('access/transam.h', $include_path,
147+
'FirstBootstrapObjectId');
145148
my $GenbkiNextOid = $FirstGenbkiObjectId;
146149

147150

@@ -625,6 +628,11 @@
625628
# last command in the BKI file: build the indexes declared above
626629
print $bki "build indices\n";
627630

631+
# check that we didn't overrun available OIDs
632+
die
633+
"genbki OID counter reached $GenbkiNextOid, overrunning FirstBootstrapObjectId\n"
634+
if $GenbkiNextOid > $FirstBootstrapObjectId;
635+
628636

629637
# Now generate schemapg.h
630638

src/include/access/transam.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@
7272
* Object ID (OID) zero is InvalidOid.
7373
*
7474
* OIDs 1-9999 are reserved for manual assignment (see .dat files in
75-
* src/include/catalog/), with 9000-9999 tentatively reserved for forks.
75+
* src/include/catalog/). Of these, 8000-9999 are reserved for
76+
* development purposes (such as in-progress patches and forks);
77+
* they should not appear in released versions.
7678
*
77-
* OIDs 10000-11999 are reserved for assignment by genbki.pl, when the
78-
* .dat files in src/include/catalog/ do not specify oids.
79+
* OIDs 10000-11999 are reserved for assignment by genbki.pl, for use
80+
* when the .dat files in src/include/catalog/ do not specify an OID
81+
* for a catalog entry that requires one.
7982
*
8083
* OIDS 12000-16383 are reserved for assignment during initdb
8184
* using the OID generator. (We start the generator at 12000.)
@@ -84,9 +87,13 @@
8487
* during normal multiuser operation. (We force the generator up to
8588
* 16384 as soon as we are in normal operation.)
8689
*
87-
* The choices of 10000, 12000 and 16384 are completely arbitrary, and can be
88-
* moved if we run low on OIDs in either category. Changing the macros below
89-
* should be sufficient to do this.
90+
* The choices of 8000, 10000 and 12000 are completely arbitrary, and can be
91+
* moved if we run low on OIDs in any category. Changing the macros below,
92+
* and updating relevant documentation (see bki.sgml and RELEASE_CHANGES),
93+
* should be sufficient to do this. Moving the 16384 boundary between
94+
* initdb-assigned OIDs and user-defined objects would be substantially
95+
* more painful, however, since some user-defined OIDs will appear in
96+
* on-disk data; such a change would probably break pg_upgrade.
9097
*
9198
* NOTE: if the OID generator wraps around, we skip over OIDs 0-16383
9299
* and resume with 16384. This minimizes the odds of OID conflict, by not

0 commit comments

Comments
 (0)