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

Commit09568ec

Browse files
committed
Create a separate oid range for oids assigned by genbki.pl.
The changes I made in578b229 assigned oids belowFirstBootstrapObjectId to objects in include/catalog/*.dat files thatdid not have an oid assigned, starting at the max oid explicitlyassigned. Tom criticized that for mainly two reasons:1) It's not clear which values are manually and which explicitly assigned.2) The space below FirstBootstrapObjectId gets pretty crowded, and some PostgreSQL forks have used oids >= 9000 for their own objects, to avoid conflicting.Thus create a new range for objects not assigned explicit oids, butassigned by genbki.pl. For now 1-9999 is for explicitly assigned oids,FirstGenbkiObjectId (10000) to FirstBootstrapObjectId (1200) -1 is forgenbki.pl assigned oids, and < FirstNormalObjectId (16384) is for oidsassigned during bootstrap. It's possible that we'll have to adjustthese boundaries, but there's some headroom for now.Add a note suggesting that oids in forks should be assigned in the9000-9999 range.Catversion bump for obvious reasons.Per complaint from Tom Lane.Author: Andres FreundDiscussion:https://postgr.es/m/16845.1544393682@sss.pgh.pa.us
1 parent84d5148 commit09568ec

File tree

9 files changed

+47
-33
lines changed

9 files changed

+47
-33
lines changed

‎contrib/postgres_fdw/shippable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ lookup_shippable(Oid objectId, Oid classId, PgFdwRelationInfo *fpinfo)
137137
/*
138138
* Return true if given object is one of PostgreSQL's built-in objects.
139139
*
140-
* We useFirstBootstrapObjectId as the cutoff, so that we only consider
140+
* We useFirstGenbkiObjectId as the cutoff, so that we only consider
141141
* objects with hand-assigned OIDs to be "built in", not for instance any
142142
* function or type defined in the information_schema.
143143
*
@@ -154,7 +154,7 @@ lookup_shippable(Oid objectId, Oid classId, PgFdwRelationInfo *fpinfo)
154154
bool
155155
is_builtin(OidobjectId)
156156
{
157-
return (objectId<FirstBootstrapObjectId);
157+
return (objectId<FirstGenbkiObjectId);
158158
}
159159

160160
/*

‎src/backend/catalog/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ generated-header-symlinks: $(top_builddir)/src/include/catalog/header-stamp
8888
# instead is cheating a bit, but it will achieve the goal of updating the
8989
# version number when it changes.
9090
bki-stamp: genbki.pl Catalog.pm$(POSTGRES_BKI_SRCS)$(POSTGRES_BKI_DATA)$(top_srcdir)/configure.in
91-
$(PERL) -I$(catalogdir)$< --set-version=$(MAJORVERSION)$(POSTGRES_BKI_SRCS)
91+
$(PERL) -I$(catalogdir)$<\
92+
-I$(top_srcdir)/src/include/ --set-version=$(MAJORVERSION)\
93+
$(POSTGRES_BKI_SRCS)
9294
touch$@
9395

9496
# The generated headers must all be symlinked into builddir/src/include/,

‎src/backend/catalog/genbki.pl

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
my@input_files;
2323
my$output_path ='';
2424
my$major_version;
25+
my$include_path;
2526

2627
# Process command line switches.
2728
while (@ARGV)
@@ -31,6 +32,10 @@
3132
{
3233
push@input_files,$arg;
3334
}
35+
elsif ($arg =~/^-I/)
36+
{
37+
$include_path =length($arg) > 2 ?substr($arg, 2) :shift@ARGV;
38+
}
3439
elsif ($arg =~/^-o/)
3540
{
3641
$output_path =length($arg) > 2 ?substr($arg, 2) :shift@ARGV;
@@ -50,6 +55,7 @@
5055
# Sanity check arguments.
5156
die"No input files.\n"if !@input_files;
5257
die"--set-version must be specified.\n"if !defined$major_version;
58+
die"-I, the header include path, must be specified.\n"if !$include_path;
5359

5460
# Make sure output_path ends in a slash.
5561
if ($output_pathne'' &&substr($output_path, -1)ne'/')
@@ -133,24 +139,25 @@
133139
# While duplicate OIDs would only cause a failure if they appear in
134140
# the same catalog, our project policy is that manually assigned OIDs
135141
# should be globally unique, to avoid confusion.
136-
#
137-
# Also use the loop to determine the maximum explicitly assigned oid
138-
# found in the data file, we'll use that for default oid assignments.
139142
my$found = 0;
140-
my$maxoid = 0;
141143
foreachmy$oid (keys%oidcounts)
142144
{
143-
if ($oid >$maxoid)
144-
{
145-
$maxoid =$oid;
146-
}
147145
nextunless$oidcounts{$oid} > 1;
148146
printSTDERR"Duplicate OIDs detected:\n"if !$found;
149147
printSTDERR"$oid\n";
150148
$found++;
151149
}
152150
die"found$found duplicate OID(s) in catalog data\n"if$found;
153151

152+
153+
# Oids not specified in the input files are automatically assigned,
154+
# starting at FirstGenbkiObjectId.
155+
my$FirstGenbkiObjectId =
156+
Catalog::FindDefinedSymbol('access/transam.h',$include_path,
157+
'FirstGenbkiObjectId');
158+
my$GenbkiNextOid =$FirstGenbkiObjectId;
159+
160+
154161
# Fetch some special data that we will substitute into the output file.
155162
# CAUTION: be wary about what symbols you substitute into the .bki file here!
156163
# It's okay to substitute things that are expected to be really constant
@@ -418,8 +425,8 @@
418425
# Assign oid if oid column exists and no explicit assignment in row
419426
if ($attnameeq"oid"andnotdefined$bki_values{$attname})
420427
{
421-
$bki_values{$attname} =$maxoid;
422-
$maxoid++;
428+
$bki_values{$attname} =$GenbkiNextOid;
429+
$GenbkiNextOid++;
423430
}
424431

425432
# Substitute constant values we acquired above.
@@ -858,6 +865,7 @@ sub usage
858865
Usage: genbki.pl [options] header...
859866
860867
Options:
868+
-I include path
861869
-o output path
862870
--set-version PostgreSQL version number for initdb cross-check
863871

‎src/backend/utils/Gen_fmgrtab.pl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@
7979
}
8080

8181
# Fetch some values for later.
82-
my$FirstBootstrapObjectId =
82+
my$FirstGenbkiObjectId =
8383
Catalog::FindDefinedSymbol('access/transam.h',$include_path,
84-
'FirstBootstrapObjectId');
84+
'FirstGenbkiObjectId');
8585
my$INTERNALlanguageId =
8686
Catalog::FindDefinedSymbolFromData($catalog_data{pg_language},
8787
'INTERNALlanguageId');
@@ -252,13 +252,13 @@
252252

253253
# Create fmgr_builtins_oid_index table.
254254
#
255-
# Note that the array has to be filled up toFirstBootstrapObjectId,
255+
# Note that the array has to be filled up toFirstGenbkiObjectId,
256256
# as we can't rely on zero initialization as 0 is a valid mapping.
257257
print$tfhqq|
258-
const uint16 fmgr_builtin_oid_index[FirstBootstrapObjectId] = {
258+
const uint16 fmgr_builtin_oid_index[FirstGenbkiObjectId] = {
259259
|;
260260

261-
for (my$i = 0;$i <$FirstBootstrapObjectId;$i++)
261+
for (my$i = 0;$i <$FirstGenbkiObjectId;$i++)
262262
{
263263
my$oid =$fmgr_builtin_oid_index[$i];
264264

@@ -269,7 +269,7 @@
269269
$oid ='InvalidOidBuiltinMapping';
270270
}
271271

272-
if ($i + 1 ==$FirstBootstrapObjectId)
272+
if ($i + 1 ==$FirstGenbkiObjectId)
273273
{
274274
print$tfh"$oid\n";
275275
}

‎src/backend/utils/fmgr/fmgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fmgr_isbuiltin(Oid id)
7575
uint16index;
7676

7777
/* fast lookup only possible if original oid still assigned */
78-
if (id >=FirstBootstrapObjectId)
78+
if (id >=FirstGenbkiObjectId)
7979
returnNULL;
8080

8181
/*

‎src/include/access/transam.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,30 @@
7171
/* ----------
7272
*Object ID (OID) zero is InvalidOid.
7373
*
74-
*OIDs 1-9999 are reserved for manual assignment (seethe files
75-
*insrc/include/catalog/).
74+
*OIDs 1-9999 are reserved for manual assignment (see.dat files in
75+
*src/include/catalog/), with 9000-9999 tentatively reserved for forks.
7676
*
77-
*OIDS 10000-16383 are reserved for assignment during initdb
78-
*using the OID generator. (We start the generator at 10000.)
77+
*OIDs 10000-12000 are reserved for assignment by genbki.pl, when the
78+
*.dat files in src/include/catalog/ do not specify oids.
79+
*
80+
*OIDS 12000-16383 are reserved for assignment during initdb
81+
*using the OID generator. (We start the generator at 12000.)
7982
*
8083
*OIDs beginning at 16384 are assigned from the OID generator
8184
*during normal multiuser operation. (We force the generator up to
8285
*16384 as soon as we are in normal operation.)
8386
*
84-
* The choices of 10000and 16384 are completely arbitrary, and can be moved
85-
* if we run low on OIDs in either category. Changing the macros below
87+
* The choices of 10000, 12000and 16384 are completely arbitrary, and can be
88+
*movedif we run low on OIDs in either category. Changing the macros below
8689
* should be sufficient to do this.
8790
*
8891
* NOTE: if the OID generator wraps around, we skip over OIDs 0-16383
8992
* and resume with 16384. This minimizes the odds of OID conflict, by not
9093
* reassigning OIDs that might have been assigned during initdb.
9194
* ----------
9295
*/
93-
#defineFirstBootstrapObjectId10000
96+
#defineFirstGenbkiObjectId10000
97+
#defineFirstBootstrapObjectId12000
9498
#defineFirstNormalObjectId16384
9599

96100
/*

‎src/include/catalog/unused_oids

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
3232

3333
my$oids = Catalog::FindAllOidsFromHeaders(@input_files);
3434

35-
# Also pushFirstBootstrapObjectId to serve as a terminator for the last gap.
36-
my$FirstBootstrapObjectId =
35+
# Also pushFirstGenbkiObjectId to serve as a terminator for the last gap.
36+
my$FirstGenbkiObjectId =
3737
Catalog::FindDefinedSymbol('access/transam.h','..',
38-
'FirstBootstrapObjectId');
39-
push @{$oids},$FirstBootstrapObjectId;
38+
'FirstGenbkiObjectId');
39+
push @{$oids},$FirstGenbkiObjectId;
4040

4141
my$prev_oid = 0;
4242
foreachmy$oid (sort {$a<=>$b } @{$oids})

‎src/include/utils/fmgrtab.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ extern const int fmgr_nbuiltins;/* number of entries in table */
4141
* array.
4242
*/
4343
#defineInvalidOidBuiltinMapping PG_UINT16_MAX
44-
externconstuint16fmgr_builtin_oid_index[FirstBootstrapObjectId];
44+
externconstuint16fmgr_builtin_oid_index[FirstGenbkiObjectId];
4545

4646
#endif/* FMGRTAB_H */

‎src/tools/msvc/Solution.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ EOF
493493
{
494494
chdir('src/backend/catalog');
495495
my$bki_srcs =join(' ../../../src/include/catalog/',@bki_srcs);
496-
system("perl genbki.pl --set-version=$self->{majorver}$bki_srcs");
496+
system("perl genbki.pl -I../../../src/include/--set-version=$self->{majorver}$bki_srcs");
497497
open(my$f,'>','bki-stamp')
498498
|| confess"Could not touch bki-stamp";
499499
close($f);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp