aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/Gen_fmgrtab.pl28
-rw-r--r--src/backend/utils/fmgr/fmgr.c4
-rw-r--r--src/include/utils/fmgrtab.h8
3 files changed, 19 insertions, 21 deletions
diff --git a/src/backend/utils/Gen_fmgrtab.pl b/src/backend/utils/Gen_fmgrtab.pl
index cafe40806fd..f9709405e75 100644
--- a/src/backend/utils/Gen_fmgrtab.pl
+++ b/src/backend/utils/Gen_fmgrtab.pl
@@ -80,11 +80,6 @@ foreach my $datfile (@input_files)
$catalog_data{$catname} = Catalog::ParseData($datfile, $schema, 0);
}
-# Fetch some values for later.
-my $FirstGenbkiObjectId =
- Catalog::FindDefinedSymbol('access/transam.h', $include_path,
- 'FirstGenbkiObjectId');
-
# Collect certain fields from pg_proc.dat.
my @fmgr = ();
@@ -225,6 +220,7 @@ my %bmap;
$bmap{'t'} = 'true';
$bmap{'f'} = 'false';
my @fmgr_builtin_oid_index;
+my $last_builtin_oid = 0;
my $fmgr_count = 0;
foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
{
@@ -232,6 +228,7 @@ foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
" { $s->{oid}, $s->{nargs}, $bmap{$s->{strict}}, $bmap{$s->{retset}}, \"$s->{prosrc}\", $s->{prosrc} }";
$fmgr_builtin_oid_index[ $s->{oid} ] = $fmgr_count++;
+ $last_builtin_oid = $s->{oid};
if ($fmgr_count <= $#fmgr)
{
@@ -244,31 +241,30 @@ foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
}
print $tfh "};\n";
-print $tfh qq|
+printf $tfh qq|
const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin));
-|;
+
+const Oid fmgr_last_builtin_oid = %u;
+|, $last_builtin_oid;
# Create fmgr_builtins_oid_index table.
-#
-# 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.
-print $tfh qq|
-const uint16 fmgr_builtin_oid_index[FirstGenbkiObjectId] = {
-|;
+printf $tfh qq|
+const uint16 fmgr_builtin_oid_index[%u] = {
+|, $last_builtin_oid + 1;
-for (my $i = 0; $i < $FirstGenbkiObjectId; $i++)
+for (my $i = 0; $i <= $last_builtin_oid; $i++)
{
my $oid = $fmgr_builtin_oid_index[$i];
- # fmgr_builtin_oid_index is sparse, map nonexistant functions to
+ # fmgr_builtin_oid_index is sparse, map nonexistent functions to
# InvalidOidBuiltinMapping
if (not defined $oid)
{
$oid = 'InvalidOidBuiltinMapping';
}
- if ($i + 1 == $FirstGenbkiObjectId)
+ if ($i == $last_builtin_oid)
{
print $tfh " $oid\n";
}
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index b41649fb0f0..506eeef01c3 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -75,12 +75,12 @@ fmgr_isbuiltin(Oid id)
uint16 index;
/* fast lookup only possible if original oid still assigned */
- if (id >= FirstGenbkiObjectId)
+ if (id > fmgr_last_builtin_oid)
return NULL;
/*
* Lookup function data. If there's a miss in that range it's likely a
- * nonexistant function, returning NULL here will trigger an ERROR later.
+ * nonexistent function, returning NULL here will trigger an ERROR later.
*/
index = fmgr_builtin_oid_index[id];
if (index == InvalidOidBuiltinMapping)
diff --git a/src/include/utils/fmgrtab.h b/src/include/utils/fmgrtab.h
index a778f880a6a..e981f349347 100644
--- a/src/include/utils/fmgrtab.h
+++ b/src/include/utils/fmgrtab.h
@@ -36,11 +36,13 @@ extern const FmgrBuiltin fmgr_builtins[];
extern const int fmgr_nbuiltins; /* number of entries in table */
+extern const Oid fmgr_last_builtin_oid; /* highest function OID in table */
+
/*
- * Mapping from a builtin function's oid to the index in the fmgr_builtins
- * array.
+ * Mapping from a builtin function's OID to its index in the fmgr_builtins
+ * array. This is indexed from 0 through fmgr_last_builtin_oid.
*/
#define InvalidOidBuiltinMapping PG_UINT16_MAX
-extern const uint16 fmgr_builtin_oid_index[FirstGenbkiObjectId];
+extern const uint16 fmgr_builtin_oid_index[];
#endif /* FMGRTAB_H */