mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Create a separate oid range for oids assigned by genbki.pl.
The changes I made in 578b229718
assigned oids below
FirstBootstrapObjectId to objects in include/catalog/*.dat files that
did not have an oid assigned, starting at the max oid explicitly
assigned. 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, but
assigned by genbki.pl. For now 1-9999 is for explicitly assigned oids,
FirstGenbkiObjectId (10000) to FirstBootstrapObjectId (1200) -1 is for
genbki.pl assigned oids, and < FirstNormalObjectId (16384) is for oids
assigned during bootstrap. It's possible that we'll have to adjust
these boundaries, but there's some headroom for now.
Add a note suggesting that oids in forks should be assigned in the
9000-9999 range.
Catversion bump for obvious reasons.
Per complaint from Tom Lane.
Author: Andres Freund
Discussion: https://postgr.es/m/16845.1544393682@sss.pgh.pa.us
This commit is contained in:
@ -137,7 +137,7 @@ lookup_shippable(Oid objectId, Oid classId, PgFdwRelationInfo *fpinfo)
|
|||||||
/*
|
/*
|
||||||
* Return true if given object is one of PostgreSQL's built-in objects.
|
* Return true if given object is one of PostgreSQL's built-in objects.
|
||||||
*
|
*
|
||||||
* We use FirstBootstrapObjectId as the cutoff, so that we only consider
|
* We use FirstGenbkiObjectId as the cutoff, so that we only consider
|
||||||
* objects with hand-assigned OIDs to be "built in", not for instance any
|
* objects with hand-assigned OIDs to be "built in", not for instance any
|
||||||
* function or type defined in the information_schema.
|
* function or type defined in the information_schema.
|
||||||
*
|
*
|
||||||
@ -154,7 +154,7 @@ lookup_shippable(Oid objectId, Oid classId, PgFdwRelationInfo *fpinfo)
|
|||||||
bool
|
bool
|
||||||
is_builtin(Oid objectId)
|
is_builtin(Oid objectId)
|
||||||
{
|
{
|
||||||
return (objectId < FirstBootstrapObjectId);
|
return (objectId < FirstGenbkiObjectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -88,7 +88,9 @@ generated-header-symlinks: $(top_builddir)/src/include/catalog/header-stamp
|
|||||||
# instead is cheating a bit, but it will achieve the goal of updating the
|
# instead is cheating a bit, but it will achieve the goal of updating the
|
||||||
# version number when it changes.
|
# version number when it changes.
|
||||||
bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.in
|
bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.in
|
||||||
$(PERL) -I $(catalogdir) $< --set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
|
$(PERL) -I $(catalogdir) $< \
|
||||||
|
-I $(top_srcdir)/src/include/ --set-version=$(MAJORVERSION) \
|
||||||
|
$(POSTGRES_BKI_SRCS)
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
# The generated headers must all be symlinked into builddir/src/include/,
|
# The generated headers must all be symlinked into builddir/src/include/,
|
||||||
|
@ -22,6 +22,7 @@ use warnings;
|
|||||||
my @input_files;
|
my @input_files;
|
||||||
my $output_path = '';
|
my $output_path = '';
|
||||||
my $major_version;
|
my $major_version;
|
||||||
|
my $include_path;
|
||||||
|
|
||||||
# Process command line switches.
|
# Process command line switches.
|
||||||
while (@ARGV)
|
while (@ARGV)
|
||||||
@ -31,6 +32,10 @@ while (@ARGV)
|
|||||||
{
|
{
|
||||||
push @input_files, $arg;
|
push @input_files, $arg;
|
||||||
}
|
}
|
||||||
|
elsif ($arg =~ /^-I/)
|
||||||
|
{
|
||||||
|
$include_path = length($arg) > 2 ? substr($arg, 2) : shift @ARGV;
|
||||||
|
}
|
||||||
elsif ($arg =~ /^-o/)
|
elsif ($arg =~ /^-o/)
|
||||||
{
|
{
|
||||||
$output_path = length($arg) > 2 ? substr($arg, 2) : shift @ARGV;
|
$output_path = length($arg) > 2 ? substr($arg, 2) : shift @ARGV;
|
||||||
@ -50,6 +55,7 @@ while (@ARGV)
|
|||||||
# Sanity check arguments.
|
# Sanity check arguments.
|
||||||
die "No input files.\n" if !@input_files;
|
die "No input files.\n" if !@input_files;
|
||||||
die "--set-version must be specified.\n" if !defined $major_version;
|
die "--set-version must be specified.\n" if !defined $major_version;
|
||||||
|
die "-I, the header include path, must be specified.\n" if !$include_path;
|
||||||
|
|
||||||
# Make sure output_path ends in a slash.
|
# Make sure output_path ends in a slash.
|
||||||
if ($output_path ne '' && substr($output_path, -1) ne '/')
|
if ($output_path ne '' && substr($output_path, -1) ne '/')
|
||||||
@ -133,17 +139,9 @@ foreach my $header (@input_files)
|
|||||||
# While duplicate OIDs would only cause a failure if they appear in
|
# While duplicate OIDs would only cause a failure if they appear in
|
||||||
# the same catalog, our project policy is that manually assigned OIDs
|
# the same catalog, our project policy is that manually assigned OIDs
|
||||||
# should be globally unique, to avoid confusion.
|
# should be globally unique, to avoid confusion.
|
||||||
#
|
|
||||||
# Also use the loop to determine the maximum explicitly assigned oid
|
|
||||||
# found in the data file, we'll use that for default oid assignments.
|
|
||||||
my $found = 0;
|
my $found = 0;
|
||||||
my $maxoid = 0;
|
|
||||||
foreach my $oid (keys %oidcounts)
|
foreach my $oid (keys %oidcounts)
|
||||||
{
|
{
|
||||||
if ($oid > $maxoid)
|
|
||||||
{
|
|
||||||
$maxoid = $oid;
|
|
||||||
}
|
|
||||||
next unless $oidcounts{$oid} > 1;
|
next unless $oidcounts{$oid} > 1;
|
||||||
print STDERR "Duplicate OIDs detected:\n" if !$found;
|
print STDERR "Duplicate OIDs detected:\n" if !$found;
|
||||||
print STDERR "$oid\n";
|
print STDERR "$oid\n";
|
||||||
@ -151,6 +149,15 @@ foreach my $oid (keys %oidcounts)
|
|||||||
}
|
}
|
||||||
die "found $found duplicate OID(s) in catalog data\n" if $found;
|
die "found $found duplicate OID(s) in catalog data\n" if $found;
|
||||||
|
|
||||||
|
|
||||||
|
# Oids not specified in the input files are automatically assigned,
|
||||||
|
# starting at FirstGenbkiObjectId.
|
||||||
|
my $FirstGenbkiObjectId =
|
||||||
|
Catalog::FindDefinedSymbol('access/transam.h', $include_path,
|
||||||
|
'FirstGenbkiObjectId');
|
||||||
|
my $GenbkiNextOid = $FirstGenbkiObjectId;
|
||||||
|
|
||||||
|
|
||||||
# Fetch some special data that we will substitute into the output file.
|
# Fetch some special data that we will substitute into the output file.
|
||||||
# CAUTION: be wary about what symbols you substitute into the .bki file here!
|
# CAUTION: be wary about what symbols you substitute into the .bki file here!
|
||||||
# It's okay to substitute things that are expected to be really constant
|
# It's okay to substitute things that are expected to be really constant
|
||||||
@ -418,8 +425,8 @@ EOM
|
|||||||
# Assign oid if oid column exists and no explicit assignment in row
|
# Assign oid if oid column exists and no explicit assignment in row
|
||||||
if ($attname eq "oid" and not defined $bki_values{$attname})
|
if ($attname eq "oid" and not defined $bki_values{$attname})
|
||||||
{
|
{
|
||||||
$bki_values{$attname} = $maxoid;
|
$bki_values{$attname} = $GenbkiNextOid;
|
||||||
$maxoid++;
|
$GenbkiNextOid++;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Substitute constant values we acquired above.
|
# Substitute constant values we acquired above.
|
||||||
@ -858,6 +865,7 @@ sub usage
|
|||||||
Usage: genbki.pl [options] header...
|
Usage: genbki.pl [options] header...
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
-I include path
|
||||||
-o output path
|
-o output path
|
||||||
--set-version PostgreSQL version number for initdb cross-check
|
--set-version PostgreSQL version number for initdb cross-check
|
||||||
|
|
||||||
|
@ -79,9 +79,9 @@ foreach my $datfile (@input_files)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Fetch some values for later.
|
# Fetch some values for later.
|
||||||
my $FirstBootstrapObjectId =
|
my $FirstGenbkiObjectId =
|
||||||
Catalog::FindDefinedSymbol('access/transam.h', $include_path,
|
Catalog::FindDefinedSymbol('access/transam.h', $include_path,
|
||||||
'FirstBootstrapObjectId');
|
'FirstGenbkiObjectId');
|
||||||
my $INTERNALlanguageId =
|
my $INTERNALlanguageId =
|
||||||
Catalog::FindDefinedSymbolFromData($catalog_data{pg_language},
|
Catalog::FindDefinedSymbolFromData($catalog_data{pg_language},
|
||||||
'INTERNALlanguageId');
|
'INTERNALlanguageId');
|
||||||
@ -252,13 +252,13 @@ const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin));
|
|||||||
|
|
||||||
# Create fmgr_builtins_oid_index table.
|
# Create fmgr_builtins_oid_index table.
|
||||||
#
|
#
|
||||||
# Note that the array has to be filled up to FirstBootstrapObjectId,
|
# Note that the array has to be filled up to FirstGenbkiObjectId,
|
||||||
# as we can't rely on zero initialization as 0 is a valid mapping.
|
# as we can't rely on zero initialization as 0 is a valid mapping.
|
||||||
print $tfh qq|
|
print $tfh qq|
|
||||||
const uint16 fmgr_builtin_oid_index[FirstBootstrapObjectId] = {
|
const uint16 fmgr_builtin_oid_index[FirstGenbkiObjectId] = {
|
||||||
|;
|
|;
|
||||||
|
|
||||||
for (my $i = 0; $i < $FirstBootstrapObjectId; $i++)
|
for (my $i = 0; $i < $FirstGenbkiObjectId; $i++)
|
||||||
{
|
{
|
||||||
my $oid = $fmgr_builtin_oid_index[$i];
|
my $oid = $fmgr_builtin_oid_index[$i];
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ for (my $i = 0; $i < $FirstBootstrapObjectId; $i++)
|
|||||||
$oid = 'InvalidOidBuiltinMapping';
|
$oid = 'InvalidOidBuiltinMapping';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i + 1 == $FirstBootstrapObjectId)
|
if ($i + 1 == $FirstGenbkiObjectId)
|
||||||
{
|
{
|
||||||
print $tfh " $oid\n";
|
print $tfh " $oid\n";
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ fmgr_isbuiltin(Oid id)
|
|||||||
uint16 index;
|
uint16 index;
|
||||||
|
|
||||||
/* fast lookup only possible if original oid still assigned */
|
/* fast lookup only possible if original oid still assigned */
|
||||||
if (id >= FirstBootstrapObjectId)
|
if (id >= FirstGenbkiObjectId)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -71,18 +71,21 @@
|
|||||||
/* ----------
|
/* ----------
|
||||||
* Object ID (OID) zero is InvalidOid.
|
* Object ID (OID) zero is InvalidOid.
|
||||||
*
|
*
|
||||||
* OIDs 1-9999 are reserved for manual assignment (see the files
|
* OIDs 1-9999 are reserved for manual assignment (see .dat files in
|
||||||
* in src/include/catalog/).
|
* src/include/catalog/), with 9000-9999 tentatively reserved for forks.
|
||||||
*
|
*
|
||||||
* OIDS 10000-16383 are reserved for assignment during initdb
|
* OIDs 10000-12000 are reserved for assignment by genbki.pl, when the
|
||||||
* using the OID generator. (We start the generator at 10000.)
|
* .dat files in src/include/catalog/ do not specify oids.
|
||||||
|
*
|
||||||
|
* 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
|
* OIDs beginning at 16384 are assigned from the OID generator
|
||||||
* during normal multiuser operation. (We force the generator up to
|
* during normal multiuser operation. (We force the generator up to
|
||||||
* 16384 as soon as we are in normal operation.)
|
* 16384 as soon as we are in normal operation.)
|
||||||
*
|
*
|
||||||
* The choices of 10000 and 16384 are completely arbitrary, and can be moved
|
* The choices of 10000, 12000 and 16384 are completely arbitrary, and can be
|
||||||
* if we run low on OIDs in either category. Changing the macros below
|
* moved if we run low on OIDs in either category. Changing the macros below
|
||||||
* should be sufficient to do this.
|
* should be sufficient to do this.
|
||||||
*
|
*
|
||||||
* NOTE: if the OID generator wraps around, we skip over OIDs 0-16383
|
* NOTE: if the OID generator wraps around, we skip over OIDs 0-16383
|
||||||
@ -90,7 +93,8 @@
|
|||||||
* reassigning OIDs that might have been assigned during initdb.
|
* reassigning OIDs that might have been assigned during initdb.
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
#define FirstBootstrapObjectId 10000
|
#define FirstGenbkiObjectId 10000
|
||||||
|
#define FirstBootstrapObjectId 12000
|
||||||
#define FirstNormalObjectId 16384
|
#define FirstNormalObjectId 16384
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -32,11 +32,11 @@ my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
|
|||||||
|
|
||||||
my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
|
my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
|
||||||
|
|
||||||
# Also push FirstBootstrapObjectId to serve as a terminator for the last gap.
|
# Also push FirstGenbkiObjectId to serve as a terminator for the last gap.
|
||||||
my $FirstBootstrapObjectId =
|
my $FirstGenbkiObjectId =
|
||||||
Catalog::FindDefinedSymbol('access/transam.h', '..',
|
Catalog::FindDefinedSymbol('access/transam.h', '..',
|
||||||
'FirstBootstrapObjectId');
|
'FirstGenbkiObjectId');
|
||||||
push @{$oids}, $FirstBootstrapObjectId;
|
push @{$oids}, $FirstGenbkiObjectId;
|
||||||
|
|
||||||
my $prev_oid = 0;
|
my $prev_oid = 0;
|
||||||
foreach my $oid (sort { $a <=> $b } @{$oids})
|
foreach my $oid (sort { $a <=> $b } @{$oids})
|
||||||
|
@ -41,6 +41,6 @@ extern const int fmgr_nbuiltins; /* number of entries in table */
|
|||||||
* array.
|
* array.
|
||||||
*/
|
*/
|
||||||
#define InvalidOidBuiltinMapping PG_UINT16_MAX
|
#define InvalidOidBuiltinMapping PG_UINT16_MAX
|
||||||
extern const uint16 fmgr_builtin_oid_index[FirstBootstrapObjectId];
|
extern const uint16 fmgr_builtin_oid_index[FirstGenbkiObjectId];
|
||||||
|
|
||||||
#endif /* FMGRTAB_H */
|
#endif /* FMGRTAB_H */
|
||||||
|
@ -493,7 +493,7 @@ EOF
|
|||||||
{
|
{
|
||||||
chdir('src/backend/catalog');
|
chdir('src/backend/catalog');
|
||||||
my $bki_srcs = join(' ../../../src/include/catalog/', @bki_srcs);
|
my $bki_srcs = join(' ../../../src/include/catalog/', @bki_srcs);
|
||||||
system("perl genbki.pl --set-version=$self->{majorver} $bki_srcs");
|
system("perl genbki.pl -I../../../src/include/ --set-version=$self->{majorver} $bki_srcs");
|
||||||
open(my $f, '>', 'bki-stamp')
|
open(my $f, '>', 'bki-stamp')
|
||||||
|| confess "Could not touch bki-stamp";
|
|| confess "Could not touch bki-stamp";
|
||||||
close($f);
|
close($f);
|
||||||
|
Reference in New Issue
Block a user