Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 814c901

Browse files
committed
Use symbolic references for pg_language OIDs in the bootstrap data.
This patch teaches genbki.pl to replace pg_language names by OIDs in much the same way as it already does for pg_am names etc, and converts pg_proc.dat to use such symbolic references in the prolang column. Aside from getting rid of a few more magic numbers in the initial catalog data, this means that Gen_fmgrtab.pl no longer needs to read pg_language.dat, since it doesn't have to know the OID of the "internal" language; now it's just looking for the string "internal". No need for a catversion bump, since the contents of postgres.bki don't actually change at all. John Naylor Discussion: https://postgr.es/m/CAJVSVGWtUqxpfAaxS88vEGvi+jKzWZb2EStu5io-UPc4p9rSJg@mail.gmail.com
1 parent 7170268 commit 814c901

File tree

7 files changed

+66
-63
lines changed

7 files changed

+66
-63
lines changed

doc/src/sgml/bki.sgml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,9 @@
409409
that's error-prone and hard to understand, so for frequently-referenced
410410
catalogs, <filename>genbki.pl</filename> provides mechanisms to write
411411
symbolic references instead. Currently this is possible for references
412-
to access methods, functions, operators, opclasses, opfamilies, and
413-
types. The rules are as follows:
412+
to access methods, functions, languages,
413+
operators, opclasses, opfamilies, and types.
414+
The rules are as follows:
414415
</para>
415416

416417
<itemizedlist>
@@ -421,6 +422,7 @@
421422
by attaching <literal>BKI_LOOKUP(<replaceable>lookuprule</replaceable>)</literal>
422423
to the column's definition, where <replaceable>lookuprule</replaceable>
423424
is <literal>pg_am</literal>, <literal>pg_proc</literal>,
425+
<literal>pg_language</literal>,
424426
<literal>pg_operator</literal>, <literal>pg_opclass</literal>,
425427
<literal>pg_opfamily</literal>, or <literal>pg_type</literal>.
426428
<literal>BKI_LOOKUP</literal> can be attached to columns of

src/backend/catalog/genbki.pl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,20 @@
178178
# Build lookup tables for OID macro substitutions and for pg_attribute
179179
# copies of pg_type values.
180180

181-
# index access method OID lookup
181+
# access method OID lookup
182182
my %amoids;
183183
foreach my $row (@{ $catalog_data{pg_am} })
184184
{
185185
$amoids{ $row->{amname} } = $row->{oid};
186186
}
187187

188+
# language OID lookup
189+
my %langoids;
190+
foreach my $row (@{ $catalog_data{pg_language} })
191+
{
192+
$langoids{ $row->{lanname} } = $row->{oid};
193+
}
194+
188195
# opclass OID lookup
189196
my %opcoids;
190197
foreach my $row (@{ $catalog_data{pg_opclass} })
@@ -259,6 +266,7 @@
259266
# Map catalog name to OID lookup.
260267
my %lookup_kind = (
261268
pg_am => \%amoids,
269+
pg_language => \%langoids,
262270
pg_opclass => \%opcoids,
263271
pg_operator => \%operoids,
264272
pg_opfamily => \%opfoids,

src/backend/utils/Gen_fmgrtab.pl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
# Note: We pass data file names as arguments and then look for matching
6060
# headers to parse the schema from. This is backwards from genbki.pl,
6161
# but the Makefile dependencies look more sensible this way.
62+
# We currently only need pg_proc, but retain the possibility of reading
63+
# more than one data file.
6264
my %catalogs;
6365
my %catalog_data;
6466
foreach my $datfile (@input_files)
@@ -82,9 +84,6 @@
8284
my $FirstGenbkiObjectId =
8385
Catalog::FindDefinedSymbol('access/transam.h', $include_path,
8486
'FirstGenbkiObjectId');
85-
my $INTERNALlanguageId =
86-
Catalog::FindDefinedSymbolFromData($catalog_data{pg_language},
87-
'INTERNALlanguageId');
8887

8988
# Collect certain fields from pg_proc.dat.
9089
my @fmgr = ();
@@ -94,7 +93,7 @@
9493
my %bki_values = %$row;
9594

9695
# Select out just the rows for internal-language procedures.
97-
next if $bki_values{prolang} ne $INTERNALlanguageId;
96+
next if $bki_values{prolang} ne 'internal';
9897

9998
push @fmgr,
10099
{

src/backend/utils/Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,11 @@ generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp $(top_
3131

3232
$(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h
3333

34-
FMGR_DATA := $(addprefix $(top_srcdir)/src/include/catalog/,\
35-
pg_language.dat pg_proc.dat \
36-
)
37-
3834
# fmgr-stamp records the last time we ran Gen_fmgrtab.pl. We don't rely on
3935
# the timestamps of the individual output files, because the Perl script
4036
# won't update them if they didn't change (to avoid unnecessary recompiles).
41-
fmgr-stamp: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(FMGR_DATA) $(top_srcdir)/src/include/access/transam.h
42-
$(PERL) -I $(catalogdir) $< -I $(top_srcdir)/src/include/ $(FMGR_DATA)
37+
fmgr-stamp: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.dat $(top_srcdir)/src/include/access/transam.h
38+
$(PERL) -I $(catalogdir) $< -I $(top_srcdir)/src/include/ $(top_srcdir)/src/include/catalog/pg_proc.dat
4339
touch $@
4440

4541
errcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes.pl

0 commit comments

Comments
 (0)