Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4390ab

Browse files
committed
Reduce the range of OIDs reserved for genbki.pl.
Commitab59610 increased FirstBootstrapObjectId from 12000 to 13000,but we've had some push-back about that. It's worrisome to reduce thedaylight between there and FirstNormalObjectId, because the number ofOIDs consumed during initdb for collation objects is hard to predict.We can improve the situation by abandoning the assumption that theseOIDs must be globally unique. It should be sufficient for them to beunique per-catalog. (Any code that's unhappy about that is brokenanyway, since no more than per-catalog uniqueness can be guaranteedonce the OID counter wraps around.) With that change, the largest OIDassigned during genbki.pl (starting from a base of 10000) is a bitunder 11000. This allows reverting FirstBootstrapObjectId to 12000with reasonable confidence that that will be sufficient for many yearsto come.We are not, at this time, abandoning the expectation thathand-assigned OIDs (below 10000) are globally unique. Someday that'lllikely be necessary, but the need seems years away still.This is late for v14, but it seems worth doing it now so thatdownstream software doesn't have to deal with the consequences ofa change in FirstBootstrapObjectId. In any case, we alreadybought into forcing an initdb for beta2, so another catversionbump won't hurt.Discussion:https://postgr.es/m/1665197.1622065382@sss.pgh.pa.us
1 parente6241d8 commita4390ab

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

‎doc/src/sgml/bki.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,11 @@
418418
<para>
419419
If <filename>genbki.pl</filename> needs to assign an OID to a catalog
420420
entry that does not have a manually-assigned OID, it will use a value in
421-
the range 10000&mdash;12999. The server's OID counter is set to13000
421+
the range 10000&mdash;11999. The server's OID counter is set to12000
422422
at the start of a bootstrap run. Thus objects created by regular SQL
423423
commands during the later phases of bootstrap, such as objects created
424424
while running the <filename>information_schema.sql</filename> script,
425-
receive OIDs of13000 or above.
425+
receive OIDs of12000 or above.
426426
</para>
427427

428428
<para>

‎src/backend/catalog/genbki.pl

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,17 @@
167167
die"found$found duplicate OID(s) in catalog data\n"if$found;
168168

169169

170-
#Oids not specified in the input files are automatically assigned,
170+
#OIDs not specified in the input files are automatically assigned,
171171
# starting at FirstGenbkiObjectId, extending up to FirstBootstrapObjectId.
172+
# We allow such OIDs to be assigned independently within each catalog.
172173
my$FirstGenbkiObjectId =
173174
Catalog::FindDefinedSymbol('access/transam.h',$include_path,
174175
'FirstGenbkiObjectId');
175176
my$FirstBootstrapObjectId =
176177
Catalog::FindDefinedSymbol('access/transam.h',$include_path,
177178
'FirstBootstrapObjectId');
178-
my$GenbkiNextOid =$FirstGenbkiObjectId;
179+
# Hash of next available OID, indexed by catalog name.
180+
my%GenbkiNextOids;
179181

180182

181183
# Fetch some special data that we will substitute into the output file.
@@ -563,8 +565,7 @@
563565
# Assign oid if oid column exists and no explicit assignment in row
564566
if ($attname eq "oid" and not defined$bki_values{$attname})
565567
{
566-
$bki_values{$attname} =$GenbkiNextOid;
567-
$GenbkiNextOid++;
568+
$bki_values{$attname} = assign_next_oid($catname);
568569
}
569570
570571
# Replace OID synonyms with OIDs per the appropriate lookup rule.
@@ -669,11 +670,6 @@
669670
# last command in the BKI file: build the indexes declared above
670671
print$bki"build indices\n";
671672

672-
# check that we didn't overrun available OIDs
673-
die
674-
"genbki OID counter reached$GenbkiNextOid, overrunning FirstBootstrapObjectId\n"
675-
if$GenbkiNextOid >$FirstBootstrapObjectId;
676-
677673
# Now generate system_constraints.sql
678674

679675
foreachmy$c (@system_constraints)
@@ -1079,6 +1075,25 @@ sub form_pg_type_symbol
10791075
return$name .$arraystr .'OID';
10801076
}
10811077

1078+
# Assign an unused OID within the specified catalog.
1079+
subassign_next_oid
1080+
{
1081+
my$catname =shift;
1082+
1083+
# Initialize, if no previous request for this catalog.
1084+
$GenbkiNextOids{$catname} =$FirstGenbkiObjectId
1085+
if !defined($GenbkiNextOids{$catname});
1086+
1087+
my$result =$GenbkiNextOids{$catname}++;
1088+
1089+
# Check that we didn't overrun available OIDs
1090+
die
1091+
"genbki OID counter for$catname reached$result, overrunning FirstBootstrapObjectId\n"
1092+
if$result >=$FirstBootstrapObjectId;
1093+
1094+
return$result;
1095+
}
1096+
10821097
subusage
10831098
{
10841099
die<<EOM;

‎src/include/access/transam.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,20 @@ FullTransactionIdAdvance(FullTransactionId *dest)
161161
*development purposes (such as in-progress patches and forks);
162162
*they should not appear in released versions.
163163
*
164-
*OIDs 10000-12999 are reserved for assignment by genbki.pl, for use
164+
*OIDs 10000-11999 are reserved for assignment by genbki.pl, for use
165165
*when the .dat files in src/include/catalog/ do not specify an OID
166-
*for a catalog entry that requires one.
166+
*for a catalog entry that requires one. Note that genbki.pl assigns
167+
*these OIDs independently in each catalog, so they're not guaranteed
168+
*to be globally unique.
167169
*
168-
*OIDS13000-16383 are reserved for assignment during initdb
169-
*using the OID generator. (We start the generator at13000.)
170+
*OIDS12000-16383 are reserved for assignment during initdb
171+
*using the OID generator. (We start the generator at12000.)
170172
*
171173
*OIDs beginning at 16384 are assigned from the OID generator
172174
*during normal multiuser operation. (We force the generator up to
173175
*16384 as soon as we are in normal operation.)
174176
*
175-
* The choices of 8000, 10000 and13000 are completely arbitrary, and can be
177+
* The choices of 8000, 10000 and12000 are completely arbitrary, and can be
176178
* moved if we run low on OIDs in any category. Changing the macros below,
177179
* and updating relevant documentation (see bki.sgml and RELEASE_CHANGES),
178180
* should be sufficient to do this. Moving the 16384 boundary between
@@ -186,7 +188,7 @@ FullTransactionIdAdvance(FullTransactionId *dest)
186188
* ----------
187189
*/
188190
#defineFirstGenbkiObjectId10000
189-
#defineFirstBootstrapObjectId13000
191+
#defineFirstBootstrapObjectId12000
190192
#defineFirstNormalObjectId16384
191193

192194
/*

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO202105271
56+
#defineCATALOG_VERSION_NO202105272
5757

5858
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp