mirror of
https://github.com/postgres/postgres.git
synced 2025-11-26 23:43:30 +03:00
Minor edits to catalog files and scripts
This fixes a few typos and small mistakes; it also cleans a few minor stylistic issues. The biggest functional change is that Gen_fmgrtab.pl no longer knows the OID of language 'internal'. Author: John Naylor Discussion: https://postgr.es/m/CAJVSVGXAkwbk-A9QHHHf00N905kKisyQbaYwKqaRpze_gPXGfg@mail.gmail.com
This commit is contained in:
@@ -16,11 +16,6 @@ package Catalog;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
require Exporter;
|
|
||||||
our @ISA = qw(Exporter);
|
|
||||||
our @EXPORT = ();
|
|
||||||
our @EXPORT_OK = qw(Catalogs SplitDataLine RenameTempFile FindDefinedSymbol);
|
|
||||||
|
|
||||||
# Call this function with an array of names of header files to parse.
|
# Call this function with an array of names of header files to parse.
|
||||||
# Returns a nested data structure describing the data in the headers.
|
# Returns a nested data structure describing the data in the headers.
|
||||||
sub Catalogs
|
sub Catalogs
|
||||||
@@ -36,7 +31,8 @@ sub Catalogs
|
|||||||
'int64' => 'int8',
|
'int64' => 'int8',
|
||||||
'Oid' => 'oid',
|
'Oid' => 'oid',
|
||||||
'NameData' => 'name',
|
'NameData' => 'name',
|
||||||
'TransactionId' => 'xid');
|
'TransactionId' => 'xid',
|
||||||
|
'XLogRecPtr' => 'pg_lsn');
|
||||||
|
|
||||||
foreach my $input_file (@_)
|
foreach my $input_file (@_)
|
||||||
{
|
{
|
||||||
@@ -162,7 +158,7 @@ sub Catalogs
|
|||||||
/BKI_WITHOUT_OIDS/ ? ' without_oids' : '';
|
/BKI_WITHOUT_OIDS/ ? ' without_oids' : '';
|
||||||
$catalog{rowtype_oid} =
|
$catalog{rowtype_oid} =
|
||||||
/BKI_ROWTYPE_OID\((\d+)\)/ ? " rowtype_oid $1" : '';
|
/BKI_ROWTYPE_OID\((\d+)\)/ ? " rowtype_oid $1" : '';
|
||||||
$catalog{schema_macro} = /BKI_SCHEMA_MACRO/ ? 'True' : '';
|
$catalog{schema_macro} = /BKI_SCHEMA_MACRO/ ? 1 : 0;
|
||||||
$declaring_attributes = 1;
|
$declaring_attributes = 1;
|
||||||
}
|
}
|
||||||
elsif ($declaring_attributes)
|
elsif ($declaring_attributes)
|
||||||
@@ -175,7 +171,7 @@ sub Catalogs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my %row;
|
my %column;
|
||||||
my ($atttype, $attname, $attopt) = split /\s+/, $_;
|
my ($atttype, $attname, $attopt) = split /\s+/, $_;
|
||||||
die "parse error ($input_file)" unless $attname;
|
die "parse error ($input_file)" unless $attname;
|
||||||
if (exists $RENAME_ATTTYPE{$atttype})
|
if (exists $RENAME_ATTTYPE{$atttype})
|
||||||
@@ -188,18 +184,18 @@ sub Catalogs
|
|||||||
$atttype .= '[]'; # variable-length only
|
$atttype .= '[]'; # variable-length only
|
||||||
}
|
}
|
||||||
|
|
||||||
$row{'type'} = $atttype;
|
$column{type} = $atttype;
|
||||||
$row{'name'} = $attname;
|
$column{name} = $attname;
|
||||||
|
|
||||||
if (defined $attopt)
|
if (defined $attopt)
|
||||||
{
|
{
|
||||||
if ($attopt eq 'BKI_FORCE_NULL')
|
if ($attopt eq 'BKI_FORCE_NULL')
|
||||||
{
|
{
|
||||||
$row{'forcenull'} = 1;
|
$column{forcenull} = 1;
|
||||||
}
|
}
|
||||||
elsif ($attopt eq 'BKI_FORCE_NOT_NULL')
|
elsif ($attopt eq 'BKI_FORCE_NOT_NULL')
|
||||||
{
|
{
|
||||||
$row{'forcenotnull'} = 1;
|
$column{forcenotnull} = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -207,7 +203,7 @@ sub Catalogs
|
|||||||
"unknown column option $attopt on column $attname";
|
"unknown column option $attopt on column $attname";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
push @{ $catalog{columns} }, \%row;
|
push @{ $catalog{columns} }, \%column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ POSTGRES_BKI_SRCS = $(addprefix $(top_srcdir)/src/include/catalog/,\
|
|||||||
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
|
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
|
||||||
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
|
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
|
||||||
pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
|
pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
|
||||||
pg_subscription_rel.h toasting.h indexing.h \
|
pg_subscription_rel.h \
|
||||||
toasting.h indexing.h \
|
toasting.h indexing.h \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my @input_files;
|
my @input_files;
|
||||||
our @include_path;
|
my @include_path;
|
||||||
my $output_path = '';
|
my $output_path = '';
|
||||||
my $major_version;
|
my $major_version;
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ print $bki "# PostgreSQL $major_version\n";
|
|||||||
my %schemapg_entries;
|
my %schemapg_entries;
|
||||||
my @tables_needing_macros;
|
my @tables_needing_macros;
|
||||||
my %regprocoids;
|
my %regprocoids;
|
||||||
our @types;
|
my @types;
|
||||||
|
|
||||||
# produce output, one catalog at a time
|
# produce output, one catalog at a time
|
||||||
foreach my $catname (@{ $catalogs->{names} })
|
foreach my $catname (@{ $catalogs->{names} })
|
||||||
@@ -124,7 +124,8 @@ foreach my $catname (@{ $catalogs->{names} })
|
|||||||
my $first = 1;
|
my $first = 1;
|
||||||
|
|
||||||
print $bki " (\n";
|
print $bki " (\n";
|
||||||
foreach my $column (@{ $catalog->{columns} })
|
my $schema = $catalog->{columns};
|
||||||
|
foreach my $column (@$schema)
|
||||||
{
|
{
|
||||||
my $attname = $column->{name};
|
my $attname = $column->{name};
|
||||||
my $atttype = $column->{type};
|
my $atttype = $column->{type};
|
||||||
@@ -150,8 +151,9 @@ foreach my $catname (@{ $catalogs->{names} })
|
|||||||
}
|
}
|
||||||
print $bki "\n )\n";
|
print $bki "\n )\n";
|
||||||
|
|
||||||
# open it, unless bootstrap case (create bootstrap does this automatically)
|
# Open it, unless bootstrap case (create bootstrap does this
|
||||||
if ($catalog->{bootstrap} eq '')
|
# automatically)
|
||||||
|
if (!$catalog->{bootstrap})
|
||||||
{
|
{
|
||||||
print $bki "open $catname\n";
|
print $bki "open $catname\n";
|
||||||
}
|
}
|
||||||
@@ -169,21 +171,23 @@ foreach my $catname (@{ $catalogs->{names} })
|
|||||||
Catalog::SplitDataLine($row->{bki_values});
|
Catalog::SplitDataLine($row->{bki_values});
|
||||||
|
|
||||||
# Perform required substitutions on fields
|
# Perform required substitutions on fields
|
||||||
foreach my $att (keys %bki_values)
|
foreach my $column (@$schema)
|
||||||
{
|
{
|
||||||
|
my $attname = $column->{name};
|
||||||
|
my $atttype = $column->{type};
|
||||||
|
|
||||||
# Substitute constant values we acquired above.
|
# Substitute constant values we acquired above.
|
||||||
# (It's intentional that this can apply to parts of a field).
|
# (It's intentional that this can apply to parts of a field).
|
||||||
$bki_values{$att} =~ s/\bPGUID\b/$BOOTSTRAP_SUPERUSERID/g;
|
$bki_values{$attname} =~ s/\bPGUID\b/$BOOTSTRAP_SUPERUSERID/g;
|
||||||
$bki_values{$att} =~ s/\bPGNSP\b/$PG_CATALOG_NAMESPACE/g;
|
$bki_values{$attname} =~ s/\bPGNSP\b/$PG_CATALOG_NAMESPACE/g;
|
||||||
|
|
||||||
# Replace regproc columns' values with OIDs.
|
# Replace regproc columns' values with OIDs.
|
||||||
# If we don't have a unique value to substitute,
|
# If we don't have a unique value to substitute,
|
||||||
# just do nothing (regprocin will complain).
|
# just do nothing (regprocin will complain).
|
||||||
if ($bki_attr{$att}->{type} eq 'regproc')
|
if ($atttype eq 'regproc')
|
||||||
{
|
{
|
||||||
my $procoid = $regprocoids{ $bki_values{$att} };
|
my $procoid = $regprocoids{ $bki_values{$attname} };
|
||||||
$bki_values{$att} = $procoid
|
$bki_values{$attname} = $procoid
|
||||||
if defined($procoid) && $procoid ne 'MULTIPLE';
|
if defined($procoid) && $procoid ne 'MULTIPLE';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,16 +219,17 @@ foreach my $catname (@{ $catalogs->{names} })
|
|||||||
printf $bki "insert %s( %s )\n", $oid,
|
printf $bki "insert %s( %s )\n", $oid,
|
||||||
join(' ', @bki_values{@attnames});
|
join(' ', @bki_values{@attnames});
|
||||||
|
|
||||||
# Write comments to postgres.description and postgres.shdescription
|
# Write comments to postgres.description and
|
||||||
|
# postgres.shdescription
|
||||||
if (defined $row->{descr})
|
if (defined $row->{descr})
|
||||||
{
|
{
|
||||||
printf $descr "%s\t%s\t0\t%s\n", $row->{oid}, $catname,
|
printf $descr "%s\t%s\t0\t%s\n",
|
||||||
$row->{descr};
|
$row->{oid}, $catname, $row->{descr};
|
||||||
}
|
}
|
||||||
if (defined $row->{shdescr})
|
if (defined $row->{shdescr})
|
||||||
{
|
{
|
||||||
printf $shdescr "%s\t%s\t%s\n", $row->{oid}, $catname,
|
printf $shdescr "%s\t%s\t%s\n",
|
||||||
$row->{shdescr};
|
$row->{oid}, $catname, $row->{shdescr};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,11 +245,10 @@ foreach my $catname (@{ $catalogs->{names} })
|
|||||||
|
|
||||||
# Currently, all bootstrapped relations also need schemapg.h
|
# Currently, all bootstrapped relations also need schemapg.h
|
||||||
# entries, so skip if the relation isn't to be in schemapg.h.
|
# entries, so skip if the relation isn't to be in schemapg.h.
|
||||||
next if $table->{schema_macro} ne 'True';
|
next if !$table->{schema_macro};
|
||||||
|
|
||||||
$schemapg_entries{$table_name} = [];
|
$schemapg_entries{$table_name} = [];
|
||||||
push @tables_needing_macros, $table_name;
|
push @tables_needing_macros, $table_name;
|
||||||
my $is_bootstrap = $table->{bootstrap};
|
|
||||||
|
|
||||||
# Generate entries for user attributes.
|
# Generate entries for user attributes.
|
||||||
my $attnum = 0;
|
my $attnum = 0;
|
||||||
@@ -259,7 +263,7 @@ foreach my $catname (@{ $catalogs->{names} })
|
|||||||
$priornotnull &= ($row->{attnotnull} eq 't');
|
$priornotnull &= ($row->{attnotnull} eq 't');
|
||||||
|
|
||||||
# If it's bootstrapped, put an entry in postgres.bki.
|
# If it's bootstrapped, put an entry in postgres.bki.
|
||||||
if ($is_bootstrap eq ' bootstrap')
|
if ($table->{bootstrap})
|
||||||
{
|
{
|
||||||
bki_insert($row, @attnames);
|
bki_insert($row, @attnames);
|
||||||
}
|
}
|
||||||
@@ -268,15 +272,14 @@ foreach my $catname (@{ $catalogs->{names} })
|
|||||||
$row =
|
$row =
|
||||||
emit_schemapg_row($row,
|
emit_schemapg_row($row,
|
||||||
grep { $bki_attr{$_}{type} eq 'bool' } @attnames);
|
grep { $bki_attr{$_}{type} eq 'bool' } @attnames);
|
||||||
push @{ $schemapg_entries{$table_name} }, '{ '
|
push @{ $schemapg_entries{$table_name} },
|
||||||
. join(
|
sprintf "{ %s }",
|
||||||
', ', grep { defined $_ }
|
join(', ', grep { defined $_ } @{$row}{@attnames});
|
||||||
map $row->{$_}, @attnames) . ' }';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate entries for system attributes.
|
# Generate entries for system attributes.
|
||||||
# We only need postgres.bki entries, not schemapg.h entries.
|
# We only need postgres.bki entries, not schemapg.h entries.
|
||||||
if ($is_bootstrap eq ' bootstrap')
|
if ($table->{bootstrap})
|
||||||
{
|
{
|
||||||
$attnum = 0;
|
$attnum = 0;
|
||||||
my @SYS_ATTRS = (
|
my @SYS_ATTRS = (
|
||||||
@@ -294,9 +297,9 @@ foreach my $catname (@{ $catalogs->{names} })
|
|||||||
$row->{attnum} = $attnum;
|
$row->{attnum} = $attnum;
|
||||||
$row->{attstattarget} = '0';
|
$row->{attstattarget} = '0';
|
||||||
|
|
||||||
# some catalogs don't have oids
|
# Omit the oid column if the catalog doesn't have them
|
||||||
next
|
next
|
||||||
if $table->{without_oids} eq ' without_oids'
|
if $table->{without_oids}
|
||||||
&& $row->{attname} eq 'oid';
|
&& $row->{attname} eq 'oid';
|
||||||
|
|
||||||
bki_insert($row, @attnames);
|
bki_insert($row, @attnames);
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Gen_fmgrtab.pl
|
# Gen_fmgrtab.pl
|
||||||
# Perl script that generates fmgroids.h and fmgrtab.c from pg_proc.h
|
# Perl script that generates fmgroids.h, fmgrprotos.h, and fmgrtab.c
|
||||||
|
# from pg_proc.h
|
||||||
#
|
#
|
||||||
# Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
# Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
||||||
# Portions Copyright (c) 1994, Regents of the University of California
|
# Portions Copyright (c) 1994, Regents of the University of California
|
||||||
@@ -56,6 +57,8 @@ die "No include path; you must specify -I at least once.\n" if !@include_path;
|
|||||||
|
|
||||||
my $FirstBootstrapObjectId =
|
my $FirstBootstrapObjectId =
|
||||||
Catalog::FindDefinedSymbol('access/transam.h', \@include_path, 'FirstBootstrapObjectId');
|
Catalog::FindDefinedSymbol('access/transam.h', \@include_path, 'FirstBootstrapObjectId');
|
||||||
|
my $INTERNALlanguageId =
|
||||||
|
Catalog::FindDefinedSymbol('catalog/pg_language.h', \@include_path, 'INTERNALlanguageId');
|
||||||
|
|
||||||
# Read all the data from the include/catalog files.
|
# Read all the data from the include/catalog files.
|
||||||
my $catalogs = Catalog::Catalogs($infile);
|
my $catalogs = Catalog::Catalogs($infile);
|
||||||
@@ -77,8 +80,7 @@ foreach my $row (@$data)
|
|||||||
@bki_values{@attnames} = Catalog::SplitDataLine($row->{bki_values});
|
@bki_values{@attnames} = Catalog::SplitDataLine($row->{bki_values});
|
||||||
|
|
||||||
# Select out just the rows for internal-language procedures.
|
# Select out just the rows for internal-language procedures.
|
||||||
# Note assumption here that INTERNALlanguageId is 12.
|
next if $bki_values{prolang} ne $INTERNALlanguageId;
|
||||||
next if $bki_values{prolang} ne '12';
|
|
||||||
|
|
||||||
push @fmgr,
|
push @fmgr,
|
||||||
{ oid => $row->{oid},
|
{ oid => $row->{oid},
|
||||||
@@ -281,7 +283,8 @@ sub usage
|
|||||||
die <<EOM;
|
die <<EOM;
|
||||||
Usage: perl -I [directory of Catalog.pm] Gen_fmgrtab.pl [path to pg_proc.h]
|
Usage: perl -I [directory of Catalog.pm] Gen_fmgrtab.pl [path to pg_proc.h]
|
||||||
|
|
||||||
Gen_fmgrtab.pl generates fmgroids.h and fmgrtab.c from pg_proc.h
|
Gen_fmgrtab.pl generates fmgroids.h, fmgrprotos.h, and fmgrtab.c from
|
||||||
|
pg_proc.h
|
||||||
|
|
||||||
Report bugs to <pgsql-bugs\@postgresql.org>.
|
Report bugs to <pgsql-bugs\@postgresql.org>.
|
||||||
EOM
|
EOM
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
* src/include/catalog/pg_partitioned_table.h
|
* src/include/catalog/pg_partitioned_table.h
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* the genbki.sh script reads this file and generates .bki
|
* the genbki.pl script reads this file and generates .bki
|
||||||
* information from the DATA() statements.
|
* information from the DATA() statements.
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
/* -------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* pg_sequence.h
|
||||||
|
* definition of the system "sequence" relation (pg_sequence)
|
||||||
|
*
|
||||||
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
||||||
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
|
*
|
||||||
|
* -------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
#ifndef PG_SEQUENCE_H
|
#ifndef PG_SEQUENCE_H
|
||||||
#define PG_SEQUENCE_H
|
#define PG_SEQUENCE_H
|
||||||
|
|
||||||
|
|||||||
@@ -161,12 +161,10 @@ typedef FormData_pg_statistic *Form_pg_statistic;
|
|||||||
#define Anum_pg_statistic_stavalues5 26
|
#define Anum_pg_statistic_stavalues5 26
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Currently, five statistical slot "kinds" are defined by core PostgreSQL,
|
* Several statistical slot "kinds" are defined by core PostgreSQL, as
|
||||||
* as documented below. Additional "kinds" will probably appear in
|
* documented below. Also, custom data types can define their own "kind"
|
||||||
* future to help cope with non-scalar datatypes. Also, custom data types
|
* codes by mutual agreement between a custom typanalyze routine and the
|
||||||
* can define their own "kind" codes by mutual agreement between a custom
|
* selectivity estimation functions of the type's operators.
|
||||||
* typanalyze routine and the selectivity estimation functions of the type's
|
|
||||||
* operators.
|
|
||||||
*
|
*
|
||||||
* Code reading the pg_statistic relation should not assume that a particular
|
* Code reading the pg_statistic relation should not assume that a particular
|
||||||
* data "kind" will appear in any particular slot. Instead, search the
|
* data "kind" will appear in any particular slot. Instead, search the
|
||||||
|
|||||||
@@ -23,15 +23,12 @@
|
|||||||
*/
|
*/
|
||||||
#define SubscriptionRelRelationId 6102
|
#define SubscriptionRelRelationId 6102
|
||||||
|
|
||||||
/* Workaround for genbki not knowing about XLogRecPtr */
|
|
||||||
#define pg_lsn XLogRecPtr
|
|
||||||
|
|
||||||
CATALOG(pg_subscription_rel,6102) BKI_WITHOUT_OIDS
|
CATALOG(pg_subscription_rel,6102) BKI_WITHOUT_OIDS
|
||||||
{
|
{
|
||||||
Oid srsubid; /* Oid of subscription */
|
Oid srsubid; /* Oid of subscription */
|
||||||
Oid srrelid; /* Oid of relation */
|
Oid srrelid; /* Oid of relation */
|
||||||
char srsubstate; /* state of the relation in subscription */
|
char srsubstate; /* state of the relation in subscription */
|
||||||
pg_lsn srsublsn; /* remote lsn of the state change used for
|
XLogRecPtr srsublsn; /* remote lsn of the state change used for
|
||||||
* synchronization coordination */
|
* synchronization coordination */
|
||||||
} FormData_pg_subscription_rel;
|
} FormData_pg_subscription_rel;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user