Commit 64737e93 authored by Tom Lane's avatar Tom Lane

Get rid of the need for manual maintenance of the initial contents of

pg_attribute, by having genbki.pl derive the information from the various
catalog header files.  This greatly simplifies modification of the
"bootstrapped" catalogs.

This patch finally kills genbki.sh and Gen_fmgrtab.sh; we now rely entirely on
Perl scripts for those build steps.  To avoid creating a Perl build dependency
where there was not one before, the output files generated by these scripts
are now treated as distprep targets, ie, they will be built and shipped in
tarballs.  But you will need a reasonably modern Perl (probably at least
5.6) if you want to build from a CVS pull.

The changes to the MSVC build process are untested, and may well break ---
we'll soon find out from the buildfarm.

John Naylor, based on ideas from Robert Haas and others
parent fc09fb7b
<!-- $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.22 2009/09/26 22:42:00 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.23 2010/01/05 01:06:55 tgl Exp $ -->
<chapter id="bki">
<title><acronym>BKI</acronym> Backend Interface</title>
......@@ -20,10 +20,10 @@
to do part of its job when creating a new database cluster. The
input file used by <application>initdb</application> is created as
part of building and installing <productname>PostgreSQL</productname>
by a program named <filename>genbki.sh</filename>, which reads some
by a program named <filename>genbki.pl</filename>, which reads some
specially formatted C header files in the <filename>src/include/catalog/</>
directory of the source tree. The created
<acronym>BKI</acronym> file is called <filename>postgres.bki</filename> and is
directory of the source tree. The created <acronym>BKI</acronym> file
is called <filename>postgres.bki</filename> and is
normally installed in the
<filename>share</filename> subdirectory of the installation tree.
</para>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.335 2009/12/18 21:37:38 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.336 2010/01/05 01:06:55 tgl Exp $ -->
<chapter id="installation">
<title><![%standalone-include[<productname>PostgreSQL</>]]>
......@@ -310,7 +310,7 @@ su - postgres
<primary>perl</primary>
</indexterm>
<application>Perl</> is also needed to build from a CVS checkout,
<application>Perl</> 5.8 or later is needed to build from a CVS checkout,
or if you changed the input files for any of the build steps that
use Perl scripts. If building on Windows you will need
<application>Perl</> in any case.
......
......@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.137 2010/01/02 16:57:33 momjian Exp $
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.138 2010/01/05 01:06:56 tgl Exp $
#
#-------------------------------------------------------------------------
......@@ -42,7 +42,7 @@ LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS)
##########################################################################
all: submake-libpgport postgres $(POSTGRES_IMP)
all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
......@@ -111,7 +111,13 @@ endif
endif # aix
# Update the commonly used headers before building the subdirectories
$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/probes.h
$(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/probes.h
# run this unconditionally to avoid needing to know its dependencies here:
submake-schemapg:
$(MAKE) -C catalog schemapg.h
.PHONY: submake-schemapg
# The postgres.o target is needed by the rule in Makefile.global that
......@@ -127,7 +133,7 @@ postgres.o: $(OBJS)
parser/gram.h: parser/gram.y
$(MAKE) -C parser gram.h
utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
utils/fmgroids.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
$(MAKE) -C utils fmgroids.h
utils/probes.h: utils/probes.d
......@@ -136,15 +142,28 @@ utils/probes.h: utils/probes.d
# Make symlinks for these headers in the include directory. That way
# we can cut down on the -I options. Also, a symlink is automatically
# up to date when we update the base file.
#
# The point of the prereqdir incantation in some of the rules below is to
# force the symlink to use an absolute path rather than a relative path.
# For headers which are generated by make distprep, the actual header within
# src/backend will be in the source tree, while the symlink in src/include
# will be in the build tree, so a simple ../.. reference won't work.
# For headers generated during regular builds, we prefer a relative symlink.
$(top_builddir)/src/include/parser/gram.h: parser/gram.h
prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
cd $(dir $@) && rm -f $(notdir $@) && \
$(LN_S) "$$prereqdir/$(notdir $<)" .
$(top_builddir)/src/include/catalog/schemapg.h: catalog/schemapg.h
prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
cd $(dir $@) && rm -f $(notdir $@) && \
$(LN_S) "$$prereqdir/$(notdir $<)" .
$(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
cd $(dir $@) && rm -f $(notdir $@) && \
$(LN_S) ../../../$(subdir)/utils/fmgroids.h .
$(LN_S) "$$prereqdir/$(notdir $<)" .
$(top_builddir)/src/include/utils/probes.h: utils/probes.h
cd $(dir $@) && rm -f $(notdir $@) && \
......@@ -160,6 +179,8 @@ utils/probes.o: utils/probes.d $(SUBDIROBJS)
distprep:
$(MAKE) -C parser gram.c gram.h scan.c
$(MAKE) -C bootstrap bootparse.c bootscanner.c
$(MAKE) -C catalog schemapg.h postgres.bki postgres.description postgres.shdescription
$(MAKE) -C utils fmgrtab.c fmgroids.h
$(MAKE) -C utils/misc guc-file.c
......@@ -243,8 +264,10 @@ endif
clean:
rm -f $(LOCALOBJS) postgres$(X) $(POSTGRES_IMP) \
$(top_srcdir)/src/include/parser/gram.h \
$(top_builddir)/src/include/utils/fmgroids.h
$(top_builddir)/src/include/parser/gram.h \
$(top_builddir)/src/include/catalog/schemapg.h \
$(top_builddir)/src/include/utils/fmgroids.h \
$(top_builddir)/src/include/utils/probes.h
ifeq ($(PORTNAME), cygwin)
rm -f postgres.dll postgres.def libpostgres.a
endif
......@@ -261,6 +284,12 @@ maintainer-clean: distclean
parser/gram.c \
parser/scan.c \
parser/gram.h \
catalog/schemapg.h \
catalog/postgres.bki \
catalog/postgres.description \
catalog/postgres.shdescription \
utils/fmgroids.h \
utils/fmgrtab.c \
utils/misc/guc-file.c
......
postgres.bki
postgres.description
postgres.shdescription
schemapg.h
#----------------------------------------------------------------------
#
# Catalog.pm
# Perl module that extracts info from catalog headers into Perl
# data structures
#
# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/backend/catalog/Catalog.pm,v 1.1 2010/01/05 01:06:56 tgl Exp $
#
#----------------------------------------------------------------------
package Catalog;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = ();
our @EXPORT_OK = qw(Catalogs RenameTempFile);
# Call this function with an array of names of header files to parse.
# Returns a nested data structure describing the data in the headers.
sub Catalogs
{
my (%catalogs, $catname, $declaring_attributes, $most_recent);
$catalogs{names} = [];
# There are a few types which are given one name in the C source, but a
# different name at the SQL level. These are enumerated here.
my %RENAME_ATTTYPE = (
'Oid' => 'oid',
'NameData' => 'name',
'TransactionId' => 'xid'
);
foreach my $input_file (@_)
{
my %catalog;
$catalog{columns} = [];
$catalog{data} = [];
open(INPUT_FILE, '<', $input_file) || die "$input_file: $!";
# Scan the input file.
while (<INPUT_FILE>)
{
# Strip C-style comments.
s;/\*(.|\n)*\*/;;g;
if (m;/\*;)
{
# handle multi-line comments properly.
my $next_line = <INPUT_FILE>;
die "$input_file: ends within C-style comment\n"
if !defined $next_line;
$_ .= $next_line;
redo;
}
# Strip useless whitespace and trailing semicolons.
chomp;
s/^\s+//;
s/;\s*$//;
s/\s+/ /g;
# Push the data into the appropriate data structure.
if (/^DATA\(insert(\s+OID\s+=\s+(\d+))?\s+\(\s*(.*)\s*\)\s*\)$/)
{
push @{ $catalog{data} }, {oid => $2, bki_values => $3};
}
elsif (/^DESCR\(\"(.*)\"\)$/)
{
$most_recent = $catalog{data}->[-1];
# this tests if most recent line is not a DATA() statement
if (ref $most_recent ne 'HASH')
{
die "DESCR() does not apply to any catalog ($input_file)";
}
if (!defined $most_recent->{oid})
{
die "DESCR() does not apply to any oid ($input_file)";
}
elsif ($1 ne '')
{
$most_recent->{descr} = $1;
}
}
elsif (/^SHDESCR\(\"(.*)\"\)$/)
{
$most_recent = $catalog{data}->[-1];
# this tests if most recent line is not a DATA() statement
if (ref $most_recent ne 'HASH')
{
die "SHDESCR() does not apply to any catalog ($input_file)";
}
if (!defined $most_recent->{oid})
{
die "SHDESCR() does not apply to any oid ($input_file)";
}
elsif ($1 ne '')
{
$most_recent->{shdescr} = $1;
}
}
elsif (/^DECLARE_TOAST\(\s*(\w+),\s*(\d+),\s*(\d+)\)/)
{
$catname = 'toasting';
my ($toast_name, $toast_oid, $index_oid) = ($1, $2, $3);
push @{ $catalog{data} }, "declare toast $toast_oid $index_oid on $toast_name\n";
}
elsif (/^DECLARE_(UNIQUE_)?INDEX\(\s*(\w+),\s*(\d+),\s*(.+)\)/)
{
$catname = 'indexing';
my ($is_unique, $index_name, $index_oid, $using) = ($1, $2, $3, $4);
push @{ $catalog{data} },
sprintf(
"declare %sindex %s %s %s\n",
$is_unique ? 'unique ' : '',
$index_name, $index_oid, $using
);
}
elsif (/^BUILD_INDICES/)
{
push @{ $catalog{data} }, "build indices\n";
}
elsif (/^CATALOG\(([^,]*),(\d+)\)/)
{
$catname = $1;
$catalog{relation_oid} = $2;
# Store pg_* catalog names in the same order we receive them
push @{ $catalogs{names} }, $catname;
$catalog{bootstrap} = /BKI_BOOTSTRAP/ ? ' bootstrap' : '';
$catalog{shared_relation} = /BKI_SHARED_RELATION/ ? ' shared_relation' : '';
$catalog{without_oids} = /BKI_WITHOUT_OIDS/ ? ' without_oids' : '';
$catalog{rowtype_oid} = /BKI_ROWTYPE_OID\((\d+)\)/ ? " rowtype_oid $1" : '';
$catalog{schema_macro} = /BKI_SCHEMA_MACRO/ ? 'True' : '';
$declaring_attributes = 1;
}
elsif ($declaring_attributes)
{
next if (/^{|^$/);
if (/^}/)
{
undef $declaring_attributes;
}
else
{
my ($atttype, $attname) = split /\s+/, $_;
if (exists $RENAME_ATTTYPE{$atttype})
{
$atttype = $RENAME_ATTTYPE{$atttype};
}
if ($attname =~ /(.*)\[.*\]/) # array attribute
{
$attname = $1;
$atttype .= '[]'; # variable-length only
}
push @{ $catalog{columns} }, {$attname => $atttype};
}
}
}
$catalogs{$catname} = \%catalog;
close INPUT_FILE;
}
return \%catalogs;
}
# Rename temporary files to final names, if anything has changed.
# Call this function with the final file name --- we append .tmp automatically
sub RenameTempFile
{
my $final_name = shift;
my $temp_name = $final_name . '.tmp';
if (-e $final_name && -s $temp_name == -s $final_name)
{
open TN, '<', "$temp_name" || die "$temp_name: $!";
if (open FN, '<', $final_name)
{
local $/ = undef;
my $tn = <TN>;
my $fn = <FN>;
close FN;
if ($tn eq $fn)
{
print "$final_name unchanged, not replacing\n";
close TN;
unlink($temp_name) || die "unlink: $temp_name: $!";
return;
}
}
close TN;
}
print "Writing $final_name\n";
rename($temp_name, $final_name) || die "rename: $temp_name: $!";
}
1;
......@@ -2,7 +2,7 @@
#
# Makefile for backend/catalog
#
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.74 2009/12/11 03:34:55 itagaki Exp $
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.75 2010/01/05 01:06:56 tgl Exp $
#
#-------------------------------------------------------------------------
......@@ -19,7 +19,7 @@ BKIFILES = postgres.bki postgres.description postgres.shdescription
include $(top_srcdir)/src/backend/common.mk
all: $(BKIFILES)
all: $(BKIFILES) schemapg.h
# Note: there are some undocumented dependencies on the ordering in which
# the catalog header files are assembled into postgres.bki. In particular,
......@@ -41,15 +41,21 @@ POSTGRES_BKI_SRCS = $(addprefix $(top_srcdir)/src/include/catalog/,\
toasting.h indexing.h \
)
pg_includes = $(sort -I$(top_srcdir)/src/include -I$(top_builddir)/src/include)
# location of Catalog.pm
catalogdir = $(top_srcdir)/src/backend/catalog
# locations of headers that genbki.pl needs to read
pg_includes = -I$(top_srcdir)/src/include/catalog -I$(top_builddir)/src/include/catalog
# see explanation in ../parser/Makefile
postgres.description: postgres.bki ;
postgres.shdescription: postgres.bki ;
postgres.bki: genbki.sh $(POSTGRES_BKI_SRCS) $(top_builddir)/src/include/pg_config_manual.h
AWK='$(AWK)' $(SHELL) $< $(pg_includes) --set-version=$(VERSION) -o postgres $(POSTGRES_BKI_SRCS)
schemapg.h: postgres.bki ;
postgres.bki: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS)
$(PERL) -I $(catalogdir) $< $(pg_includes) --set-version=$(VERSION) $(POSTGRES_BKI_SRCS)
.PHONY: install-data
install-data: $(BKIFILES) installdirs
......@@ -67,5 +73,9 @@ installdirs:
uninstall-data:
rm -f $(addprefix '$(DESTDIR)$(datadir)'/, $(BKIFILES) system_views.sql information_schema.sql sql_features.txt)
# postgres.bki, postgres.description, postgres.shdescription, and schemapg.h
# are in the distribution tarball, so they are not cleaned here.
clean:
maintainer-clean: clean
rm -f $(BKIFILES)
$PostgreSQL: pgsql/src/backend/catalog/README,v 1.13 2008/03/21 13:23:28 momjian Exp $
$PostgreSQL: pgsql/src/backend/catalog/README,v 1.14 2010/01/05 01:06:56 tgl Exp $
System Catalog
==============
......@@ -7,7 +7,7 @@ This directory contains .c files that manipulate the system catalogs;
src/include/catalog contains the .h files that define the structure
of the system catalogs.
When the compile-time scripts (such as Gen_fmgrtab.sh and genbki.sh)
When the compile-time scripts (Gen_fmgrtab.pl and genbki.pl)
execute, they grep the DATA statements out of the .h files and munge
these in order to generate the postgres.bki file. The .bki file is then
used as input to initdb (which is just a wrapper around postgres
......@@ -44,7 +44,7 @@ catalog's .h file, and use the #define symbol in the C code. Writing
the actual numeric value of any OID in C code is considered very bad form.
Direct references to pg_proc OIDs are common enough that there's a special
mechanism to create the necessary #define's automatically: see
backend/utils/Gen_fmgrtab.sh. We also have standard conventions for setting
backend/utils/Gen_fmgrtab.pl. We also have standard conventions for setting
up #define's for the pg_class OIDs of system catalogs and indexes. For all
the other system catalogs, you have to manually create any #define's you
need.
......@@ -75,6 +75,7 @@ POSTGRES_BKI_SRCS variable, as these cannot be created through the standard
heap_create_with_catalog process, because it needs these tables to exist
already. The list of files this currently includes is:
pg_proc.h pg_type.h pg_attribute.h pg_class.h
Within this list, pg_type.h must come before pg_attribute.h.
Also, indexing.h must be last, since the indexes can't be created until all
the tables are in place, and toasting.h should probably be next-to-last
(or at least after all the tables that need toast tables). There are
......
This diff is collapsed.
This diff is collapsed.
......@@ -2,85 +2,89 @@
#-------------------------------------------------------------------------
#
# Gen_fmgrtab.pl
# Perl equivalent of Gen_fmgrtab.sh
#
# Usage: perl Gen_fmgrtab.pl path-to-pg_proc.h
#
# The reason for implementing this functionality twice is that we don't
# require people to have perl to build from a tarball, but on the other
# hand Windows can't deal with shell scripts.
# Perl script that generates fmgroids.h and fmgrtab.c from pg_proc.h
#
# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.pl,v 1.3 2010/01/02 16:57:53 momjian Exp $
# $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.pl,v 1.4 2010/01/05 01:06:56 tgl Exp $
#
#-------------------------------------------------------------------------
use Catalog;
use strict;
use warnings;
# Collect arguments
my $infile = shift;
defined($infile) || die "$0: missing required argument: pg_proc.h\n";
# Note: see Gen_fmgrtab.sh for detailed commentary on what this is doing
# Collect column numbers for pg_proc columns we need
my ($proname, $prolang, $proisstrict, $proretset, $pronargs, $prosrc);
open(I, $infile) || die "Could not open $infile: $!";
while (<I>)
my $infile; # pg_proc.h
my $output_path = '';
while (@ARGV)
{
if (m/#define Anum_pg_proc_proname\s+(\d+)/) {
$proname = $1;
}
if (m/#define Anum_pg_proc_prolang\s+(\d+)/) {
$prolang = $1;
}
if (m/#define Anum_pg_proc_proisstrict\s+(\d+)/) {
$proisstrict = $1;
}
if (m/#define Anum_pg_proc_proretset\s+(\d+)/) {
$proretset = $1;
my $arg = shift @ARGV;
if ($arg !~ /^-/)
{
$infile = $arg;
}
if (m/#define Anum_pg_proc_pronargs\s+(\d+)/) {
$pronargs = $1;
elsif ($arg =~ /^-o/)
{
$output_path = length($arg) > 2 ? substr($arg, 2) : shift @ARGV;
}
if (m/#define Anum_pg_proc_prosrc\s+(\d+)/) {
$prosrc = $1;
else
{
usage();
}
}
close(I);
# Collect the raw data
# Make sure output_path ends in a slash.
if ($output_path ne '' && substr($output_path, -1) ne '/')
{
$output_path .= '/';
}
# Read all the data from the include/catalog files.
my $catalogs = Catalog::Catalogs($infile);
# Collect the raw data from pg_proc.h.
my @fmgr = ();
my @attnames;
foreach my $column ( @{ $catalogs->{pg_proc}->{columns} } )
{
push @attnames, keys %$column;
}
open(I, $infile) || die "Could not open $infile: $!";
while (<I>)
my $data = $catalogs->{pg_proc}->{data};
foreach my $row (@$data)
{
next unless (/^DATA/);
s/^[^O]*OID[^=]*=[ \t]*//;
s/\(//;
s/"[^"]*"/"xxx"/g;
my @p = split;
next if ($p[$prolang] ne "12");
# To construct fmgroids.h and fmgrtab.c, we need to inspect some
# of the individual data fields. Just splitting on whitespace
# won't work, because some quoted fields might contain internal
# whitespace. We handle this by folding them all to a simple
# "xxx". Fortunately, this script doesn't need to look at any
# fields that might need quoting, so this simple hack is
# sufficient.
$row->{bki_values} =~ s/"[^"]*"/"xxx"/g;
@{$row}{@attnames} = split /\s+/, $row->{bki_values};
# Select out just the rows for internal-language procedures.
# Note assumption here that INTERNALlanguageId is 12.
next if $row->{prolang} ne '12';
push @fmgr,
{
oid => $p[0],
proname => $p[$proname],
strict => $p[$proisstrict],
retset => $p[$proretset],
nargs => $p[$pronargs],
prosrc => $p[$prosrc],
oid => $row->{oid},
strict => $row->{proisstrict},
retset => $row->{proretset},
nargs => $row->{pronargs},
prosrc => $row->{prosrc},
};
}
close(I);
# Emit headers for both files
open(H, '>', "$$-fmgroids.h") || die "Could not open $$-fmgroids.h: $!";
open H, '>', $output_path . 'fmgroids.h.tmp' || die "Could not open fmgroids.h.tmp: $!";
print H
qq|/*-------------------------------------------------------------------------
*
......@@ -119,7 +123,7 @@ qq|/*-------------------------------------------------------------------------
*/
|;
open(T, '>', "$$-fmgrtab.c") || die "Could not open $$-fmgrtab.c: $!";
open T, '>', $output_path . 'fmgrtab.c.tmp' || die "Could not open fmgrtab.c.tmp: $!";
print T
qq|/*-------------------------------------------------------------------------
*
......@@ -186,9 +190,18 @@ const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin)) - 1;
close(T);
# Finally, rename the completed files into place.
rename "$$-fmgroids.h", "fmgroids.h"
|| die "Could not rename $$-fmgroids.h to fmgroids.h: $!";
rename "$$-fmgrtab.c", "fmgrtab.c"
|| die "Could not rename $$-fmgrtab.c to fmgrtab.c: $!";
Catalog::RenameTempFile($output_path . 'fmgroids.h');
Catalog::RenameTempFile($output_path . 'fmgrtab.c');
sub usage
{
die <<EOM;
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
Report bugs to <pgsql-bugs\@postgresql.org>.
EOM
}
exit 0;
#! /bin/sh
#-------------------------------------------------------------------------
#
# Gen_fmgrtab.sh
# shell script to generate fmgroids.h and fmgrtab.c from pg_proc.h
#
# NOTE: if you change this, you need to fix Gen_fmgrtab.pl too!
#
# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.sh,v 1.42 2010/01/02 16:57:53 momjian Exp $
#
#-------------------------------------------------------------------------
CMDNAME=`basename $0`
if [ x"$AWK" = x"" ]; then
AWK=awk
fi
cleanup(){
[ x"$noclean" != x"t" ] && rm -f "$SORTEDFILE" "$$-$OIDSFILE" "$$-$TABLEFILE"
}
noclean=
#
# Process command line switches.
#
while [ $# -gt 0 ]
do
case $1 in
--noclean)
noclean=t
;;
--help)
echo "$CMDNAME generates fmgroids.h and fmgrtab.c from pg_proc.h."
echo
echo "Usage:"
echo " $CMDNAME inputfile"
echo
echo "The environment variable AWK determines which Awk program"
echo "to use. The default is \`awk'."
echo
echo "Report bugs to <pgsql-bugs@postgresql.org>."
exit 0
;;
-*)
echo "$CMDNAME: invalid option: $1"
exit 1
;;
*)
INFILE=$1
;;
esac
shift
done
if [ x"$INFILE" = x ] ; then
echo "$CMDNAME: no input file"
exit 1
fi
SORTEDFILE="$$-fmgr.data"
OIDSFILE=fmgroids.h
TABLEFILE=fmgrtab.c
trap 'echo "Caught signal." ; cleanup ; exit 1' 1 2 15
#
# Collect the column numbers of the pg_proc columns we need. Because we will
# be looking at data that includes the OID as the first column, add one to
# each column number.
#
proname=`egrep '^#define Anum_pg_proc_proname[ ]' $INFILE | $AWK '{print $3+1}'`
prolang=`egrep '^#define Anum_pg_proc_prolang[ ]' $INFILE | $AWK '{print $3+1}'`
proisstrict=`egrep '^#define Anum_pg_proc_proisstrict[ ]' $INFILE | $AWK '{print $3+1}'`
proretset=`egrep '^#define Anum_pg_proc_proretset[ ]' $INFILE | $AWK '{print $3+1}'`
pronargs=`egrep '^#define Anum_pg_proc_pronargs[ ]' $INFILE | $AWK '{print $3+1}'`
prosrc=`egrep '^#define Anum_pg_proc_prosrc[ ]' $INFILE | $AWK '{print $3+1}'`
#
# Generate the file containing raw pg_proc data. We do three things here:
# 1. Strip off the DATA macro call, leaving procedure OID as $1
# and all the pg_proc field values as $2, $3, etc on each line.
# 2. Fold quoted fields to simple "xxx". We need this because such fields
# may contain whitespace, which would confuse awk's counting of fields.
# Fortunately, this script doesn't need to look at any fields that might
# need quoting, so this simple hack is sufficient.
# 3. Select out just the rows for internal-language procedures.
#
# Note assumption here that INTERNALlanguageId == 12.
#
egrep '^DATA' $INFILE | \
sed -e 's/^[^O]*OID[^=]*=[ ]*//' \
-e 's/(//' \
-e 's/"[^"]*"/"xxx"/g' | \
$AWK "\$$prolang == \"12\" { print }" | \
sort -n > $SORTEDFILE
if [ $? -ne 0 ]; then
cleanup
echo "$CMDNAME failed"
exit 1
fi
cpp_define=`echo $OIDSFILE | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | sed -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
#
# Generate fmgroids.h
#
cat > "$$-$OIDSFILE" <<FuNkYfMgRsTuFf
/*-------------------------------------------------------------------------
*
* $OIDSFILE
* Macros that define the OIDs of built-in functions.
*
* These macros can be used to avoid a catalog lookup when a specific
* fmgr-callable function needs to be referenced.
*
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* NOTES
* ******************************
* *** DO NOT EDIT THIS FILE! ***
* ******************************
*
* It has been GENERATED by $CMDNAME
* from $INFILE
*
*-------------------------------------------------------------------------
*/
#ifndef $cpp_define
#define $cpp_define
/*
* Constant macros for the OIDs of entries in pg_proc.
*
* NOTE: macros are named after the prosrc value, ie the actual C name
* of the implementing function, not the proname which may be overloaded.
* For example, we want to be able to assign different macro names to both
* char_text() and name_text() even though these both appear with proname
* 'text'. If the same C function appears in more than one pg_proc entry,
* its equivalent macro will be defined with the lowest OID among those
* entries.
*/
FuNkYfMgRsTuFf
tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $SORTEDFILE | \
$AWK "{ if (seenit[\$$prosrc]++ == 0)
printf \"#define F_%s %s\\n\", \$$prosrc, \$1; }" >> "$$-$OIDSFILE"
if [ $? -ne 0 ]; then
cleanup
echo "$CMDNAME failed"
exit 1
fi
cat >> "$$-$OIDSFILE" <<FuNkYfMgRsTuFf
#endif /* $cpp_define */
FuNkYfMgRsTuFf
#
# Generate fmgr's built-in-function table.
#
# Print out the function declarations, then the table that refers to them.
#
cat > "$$-$TABLEFILE" <<FuNkYfMgRtAbStUfF
/*-------------------------------------------------------------------------
*
* $TABLEFILE
* The function manager's table of internal functions.
*
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* NOTES
*
* ******************************
* *** DO NOT EDIT THIS FILE! ***
* ******************************
*
* It has been GENERATED by $CMDNAME
* from $INFILE
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "utils/fmgrtab.h"
FuNkYfMgRtAbStUfF
$AWK "{ if (seenit[\$$prosrc]++ == 0)
print \"extern Datum\", \$$prosrc, \"(PG_FUNCTION_ARGS);\"; }" $SORTEDFILE >> "$$-$TABLEFILE"
if [ $? -ne 0 ]; then
cleanup
echo "$CMDNAME failed"
exit 1
fi
cat >> "$$-$TABLEFILE" <<FuNkYfMgRtAbStUfF
const FmgrBuiltin fmgr_builtins[] = {
FuNkYfMgRtAbStUfF
# Note: using awk arrays to translate from pg_proc values to fmgrtab values
# may seem tedious, but avoid the temptation to write a quick x?y:z
# conditional expression instead. Not all awks have conditional expressions.
$AWK "BEGIN {
Bool[\"t\"] = \"true\";
Bool[\"f\"] = \"false\";
}
{ printf (\" { %d, \\\"%s\\\", %d, %s, %s, %s },\\n\"),
\$1, \$$prosrc, \$$pronargs, Bool[\$$proisstrict], Bool[\$$proretset], \$$prosrc ;
}" $SORTEDFILE >> "$$-$TABLEFILE"
if [ $? -ne 0 ]; then
cleanup
echo "$CMDNAME failed"
exit 1
fi
cat >> "$$-$TABLEFILE" <<FuNkYfMgRtAbStUfF
/* dummy entry is easier than getting rid of comma after last real one */
/* (not that there has ever been anything wrong with *having* a
comma after the last field in an array initializer) */
{ 0, NULL, 0, false, false, NULL }
};
/* Note fmgr_nbuiltins excludes the dummy entry */
const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin)) - 1;
FuNkYfMgRtAbStUfF
# We use the temporary files to avoid problems with concurrent runs
# (which can happen during parallel make).
mv "$$-$OIDSFILE" $OIDSFILE
mv "$$-$TABLEFILE" $TABLEFILE
cleanup
exit 0
#
# Makefile for utils
#
# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.28 2008/08/01 13:16:09 alvherre Exp $
# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.29 2010/01/05 01:06:56 tgl Exp $
#
subdir = src/backend/utils
......@@ -11,14 +11,20 @@ include $(top_builddir)/src/Makefile.global
OBJS = fmgrtab.o
SUBDIRS = adt cache error fmgr hash init mb misc mmgr resowner sort time
# location of Catalog.pm
catalogdir = $(top_srcdir)/src/backend/catalog
include $(top_srcdir)/src/backend/common.mk
all: fmgroids.h probes.h
$(SUBDIRS:%=%-recursive): fmgroids.h
fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
AWK='$(AWK)' $(SHELL) $< $(top_srcdir)/src/include/catalog/pg_proc.h
# see explanation in ../parser/Makefile
fmgroids.h: fmgrtab.c ;
fmgrtab.c: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
$(PERL) -I $(catalogdir) $< $(top_srcdir)/src/include/catalog/pg_proc.h
ifneq ($(enable_dtrace), yes)
probes.h: Gen_dummy_probes.sed
......@@ -34,5 +40,10 @@ else
endif
# fmgroids.h and fmgrtab.c are in the distribution tarball, so they
# are not cleaned here.
clean:
rm -f fmgroids.h fmgrtab.c probes.h
rm -f probes.h
maintainer-clean: clean
rm -f fmgroids.h fmgrtab.c
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.295 2010/01/02 16:57:55 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.296 2010/01/05 01:06:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -50,6 +50,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/schemapg.h"
#include "commands/trigger.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
......
......@@ -4,7 +4,7 @@
#
# 'make install' installs whole contents of src/include.
#
# $PostgreSQL: pgsql/src/include/Makefile,v 1.29 2009/08/26 22:24:43 petere Exp $
# $PostgreSQL: pgsql/src/include/Makefile,v 1.30 2010/01/05 01:06:56 tgl Exp $
#
#-------------------------------------------------------------------------
......@@ -62,7 +62,7 @@ uninstall:
clean:
rm -f utils/fmgroids.h parser/gram.h utils/probes.h
rm -f utils/fmgroids.h parser/gram.h utils/probes.h catalog/schemapg.h
distclean maintainer-clean: clean
rm -f pg_config.h dynloader.h pg_config_os.h stamp-h
......@@ -5,14 +5,14 @@
*
* genbki.h defines CATALOG(), DATA(), BKI_BOOTSTRAP and related macros
* so that the catalog header files can be read by the C compiler.
* (These same words are recognized by genbki.sh to build the BKI
* (These same words are recognized by genbki.pl to build the BKI
* bootstrap file from these header files.)
*
*
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/genbki.h,v 1.5 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/genbki.h,v 1.6 2010/01/05 01:06:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -27,6 +27,7 @@
#define BKI_SHARED_RELATION
#define BKI_WITHOUT_OIDS
#define BKI_ROWTYPE_OID(oid)
#define BKI_SCHEMA_MACRO
/* Declarations that provide the initial content of a catalog */
/* In C, these need to expand into some harmless, repeatable declaration */
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.114 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.115 2010/01/05 01:06:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -37,7 +37,7 @@ extern void CatalogUpdateIndexes(Relation heapRel, HeapTuple heapTuple);
/*
* These macros are just to keep the C compiler from spitting up on the
* upcoming commands for genbki.sh.
* upcoming commands for genbki.pl.
*/
#define DECLARE_INDEX(name,oid,decl) extern int no_such_variable
#define DECLARE_UNIQUE_INDEX(name,oid,decl) extern int no_such_variable
......@@ -45,7 +45,7 @@ extern void CatalogUpdateIndexes(Relation heapRel, HeapTuple heapTuple);
/*
* What follows are lines processed by genbki.sh to create the statements
* What follows are lines processed by genbki.pl to create the statements
* the bootstrap parser will turn into DefineIndex commands.
*
* The keyword is DECLARE_INDEX or DECLARE_UNIQUE_INDEX. The first two
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.69 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.70 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_am.h,v 1.64 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_am.h,v 1.65 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -29,10 +29,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.91 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.92 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -22,10 +22,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.76 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.77 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_attrdef.h,v 1.25 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_attrdef.h,v 1.26 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
This diff is collapsed.
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_auth_members.h,v 1.7 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_auth_members.h,v 1.8 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -10,10 +10,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_authid.h,v 1.11 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_authid.h,v 1.12 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -10,10 +10,10 @@
*
* Copyright (c) 2002-2010, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.43 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.44 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.118 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.119 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......@@ -29,7 +29,7 @@
#define RelationRelationId 1259
#define RelationRelation_Rowtype_Id 83
CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83)
CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO
{
NameData relname; /* class name */
Oid relnamespace; /* OID of namespace containing this class */
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_constraint.h,v 1.35 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_constraint.h,v 1.36 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_conversion.h,v 1.23 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_conversion.h,v 1.24 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_database.h,v 1.52 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_database.h,v 1.53 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......@@ -29,7 +29,7 @@
#define DatabaseRelationId 1262
#define DatabaseRelation_Rowtype_Id 1248
CATALOG(pg_database,1262) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248)
CATALOG(pg_database,1262) BKI_SHARED_RELATION BKI_ROWTYPE_OID(1248) BKI_SCHEMA_MACRO
{
NameData datname; /* database name */
Oid datdba; /* owner of database */
......
......@@ -7,10 +7,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_db_role_setting.h,v 1.2 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_db_role_setting.h,v 1.3 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -7,10 +7,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_default_acl.h,v 1.2 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_default_acl.h,v 1.3 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_depend.h,v 1.12 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_depend.h,v 1.13 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -22,10 +22,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_description.h,v 1.29 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_description.h,v 1.30 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......@@ -78,7 +78,7 @@ typedef FormData_pg_description *Form_pg_description;
/*
* Because the contents of this table are taken from the other *.h files,
* there is no initialization here. The initial contents are extracted
* by genbki.sh and loaded during initdb.
* by genbki.pl and loaded during initdb.
*/
#endif /* PG_DESCRIPTION_H */
......@@ -7,10 +7,10 @@
*
* Copyright (c) 2006-2010, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/include/catalog/pg_enum.h,v 1.7 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_enum.h,v 1.8 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_foreign_data_wrapper.h,v 1.4 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_foreign_data_wrapper.h,v 1.5 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -6,10 +6,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_foreign_server.h,v 1.4 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_foreign_server.h,v 1.5 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_index.h,v 1.49 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_index.h,v 1.50 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......@@ -28,7 +28,7 @@
*/
#define IndexRelationId 2610
CATALOG(pg_index,2610) BKI_WITHOUT_OIDS
CATALOG(pg_index,2610) BKI_WITHOUT_OIDS BKI_SCHEMA_MACRO
{
Oid indexrelid; /* OID of the index */
Oid indrelid; /* OID of the relation it indexes */
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_inherits.h,v 1.29 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_inherits.h,v 1.30 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_language.h,v 1.36 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_language.h,v 1.37 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_largeobject.h,v 1.26 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_largeobject.h,v 1.27 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_largeobject_metadata.h,v 1.2 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_largeobject_metadata.h,v 1.3 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -7,10 +7,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_listener.h,v 1.27 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_listener.h,v 1.28 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_namespace.h,v 1.26 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_namespace.h,v 1.27 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -28,10 +28,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_opclass.h,v 1.86 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_opclass.h,v 1.87 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.168 2010/01/02 16:58:01 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.169 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_opfamily.h,v 1.12 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_opfamily.h,v 1.13 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_pltemplate.h,v 1.11 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_pltemplate.h,v 1.12 2010/01/05 01:06:56 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -7,11 +7,11 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.558 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.559 2010/01/05 01:06:56 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
* information from the DATA() statements. utils/Gen_fmgrtab.sh
* The script catalog/genbki.pl reads this file and generates .bki
* information from the DATA() statements. utils/Gen_fmgrtab.pl
* generates fmgroids.h and fmgrtab.c the same way.
*
* XXX do NOT break up DATA() statements into multiple lines!
......@@ -33,7 +33,7 @@
#define ProcedureRelationId 1255
#define ProcedureRelation_Rowtype_Id 81
CATALOG(pg_proc,1255) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81)
CATALOG(pg_proc,1255) BKI_BOOTSTRAP BKI_ROWTYPE_OID(81) BKI_SCHEMA_MACRO
{
NameData proname; /* procedure name */
Oid pronamespace; /* OID of namespace containing this proc */
......
......@@ -11,10 +11,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_rewrite.h,v 1.34 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_rewrite.h,v 1.35 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_shdepend.h,v 1.11 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_shdepend.h,v 1.12 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -15,10 +15,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_shdescription.h,v 1.8 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_shdescription.h,v 1.9 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......@@ -69,7 +69,7 @@ typedef FormData_pg_shdescription *Form_pg_shdescription;
/*
* Because the contents of this table are taken from the other *.h files,
* there is no initialization here. The initial contents are extracted
* by genbki.sh and loaded during initdb.
* by genbki.pl and loaded during initdb.
*/
#endif /* PG_SHDESCRIPTION_H */
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_statistic.h,v 1.41 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_statistic.h,v 1.42 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_tablespace.h,v 1.13 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_tablespace.h,v 1.14 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_trigger.h,v 1.37 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_trigger.h,v 1.38 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -7,10 +7,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_config.h,v 1.6 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_config.h,v 1.7 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -7,10 +7,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_config_map.h,v 1.6 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_config_map.h,v 1.7 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -7,10 +7,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_dict.h,v 1.6 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_dict.h,v 1.7 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -7,10 +7,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_parser.h,v 1.6 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_parser.h,v 1.7 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -7,10 +7,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_template.h,v 1.7 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_ts_template.h,v 1.8 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
* XXX do NOT break up DATA() statements into multiple lines!
......
......@@ -8,10 +8,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.211 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.212 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......@@ -34,7 +34,7 @@
#define TypeRelationId 1247
#define TypeRelation_Rowtype_Id 71
CATALOG(pg_type,1247) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71)
CATALOG(pg_type,1247) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71) BKI_SCHEMA_MACRO
{
NameData typname; /* type name */
Oid typnamespace; /* OID of namespace containing this type */
......@@ -264,9 +264,7 @@ typedef FormData_pg_type *Form_pg_type;
* Keep the following ordered by OID so that later changes can be made more
* easily.
*
* For types used in the system catalogs, make sure the typlen, typbyval, and
* typalign values here match the initial values for attlen, attbyval, and
* attalign in both places in pg_attribute.h for every instance. Also see
* For types used in the system catalogs, make sure the values here match
* TypInfo[] in bootstrap.c.
*/
......
......@@ -6,10 +6,10 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_user_mapping.h,v 1.4 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_user_mapping.h,v 1.5 2010/01/05 01:06:57 tgl Exp $
*
* 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.
*
*-------------------------------------------------------------------------
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.11 2010/01/02 16:58:02 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.12 2010/01/05 01:06:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -25,13 +25,13 @@ extern void BootstrapToastTable(char *relName,
/*
* This macro is just to keep the C compiler from spitting up on the
* upcoming commands for genbki.sh.
* upcoming commands for genbki.pl.
*/
#define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
/*
* What follows are lines processed by genbki.sh to create the statements
* What follows are lines processed by genbki.pl to create the statements
* the bootstrap parser will turn into BootstrapToastTable commands.
* Each line specifies the system catalog that needs a toast table,
* the OID to assign to the toast table, and the OID to assign to the
......
/*-------------------------------------------------------------------------
*
* pg_type.h
* definition of the system "type" relation (pg_type)
* along with the relation's initial contents.
* Hard-wired knowledge about some standard type OIDs.
*
* XXX keep this in sync with src/include/catalog/pg_type.h
*
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/pg_type.h,v 1.10 2010/01/02 16:58:11 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
* information from the DATA() statements.
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/pg_type.h,v 1.11 2010/01/05 01:06:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PG_TYPE_H
#define PG_TYPE_H
/* ----------------
* initial contents of pg_type
* ----------------
*/
/* keep the following ordered by OID so that later changes can be made easier*/
/* OIDS 1 - 99 */
#define BOOLOID 16
#define BYTEAOID 17
#define CHAROID 18
......
#!/usr/bin/perl
#-------------------------------------------------------------------------
#
# Genbki.pm --
# perl script which generates .bki files from specially formatted .h
# files. These .bki files are used to initialize the postgres template
# database.
#
# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/tools/msvc/Genbki.pm,v 1.9 2010/01/02 16:58:17 momjian Exp $
#
#-------------------------------------------------------------------------
package Genbki;
use strict;
use warnings;
use Exporter;
our (@ISA, @EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT_OK = qw(genbki);
sub genbki
{
my $version = shift;
my $prefix = shift;
$version =~ /^(\d+\.\d+)/ || die "Bad format version $version\n";
my $majorversion = $1;
my $pgauthid = read_file("src/include/catalog/pg_authid.h");
$pgauthid =~ /^#define\s+BOOTSTRAP_SUPERUSERID\s+(\d+)$/mg
|| die "Could not read BOOTSTRAP_SUPERUSERID from pg_authid.h\n";
my $bootstrapsuperuserid = $1;
my $pgnamespace = read_file("src/include/catalog/pg_namespace.h");
$pgnamespace =~ /^#define\s+PG_CATALOG_NAMESPACE\s+(\d+)$/mg
|| die "Could not read PG_CATALOG_NAMESPACE from pg_namespace.h\n";
my $pgcatalognamespace = $1;
my $indata = "";
while (@_)
{
my $f = shift;
next unless $f;
$indata .= read_file($f);
$indata .= "\n";
}
# Strip C comments, from perl FAQ 4.27
$indata =~ s{/\*.*?\*/}{}gs;
$indata =~ s{;\s*$}{}gm;
$indata =~ s{^\s+}{}gm;
$indata =~ s{^Oid}{oid}gm;
$indata =~ s{\(Oid}{(oid}gm;
$indata =~ s{^NameData}{name}gm;
$indata =~ s{\(NameData}{(name}g;
$indata =~ s{^TransactionId}{xid}gm;
$indata =~ s{\(TransactionId}{(xid}g;
$indata =~ s{PGUID}{$bootstrapsuperuserid}g;
$indata =~ s{PGNSP}{$pgcatalognamespace}g;
#print $indata;
my $bki = "";
my $desc = "";
my $shdesc = "";
my $oid = 0;
my $catalog = 0;
my $reln_open = 0;
my $bootstrap = "";
my $shared_relation = "";
my $without_oids = "";
my $rowtype_oid = "";
my $nc = 0;
my $inside = 0;
my @attr;
my @types;
foreach my $line (split /\n/, $indata)
{
if ($line =~ /^DATA\((.*)\)$/m)
{
my $data = $1;
my @fields = split /\s+/,$data;
if ($#fields >=4 && $fields[0] eq "insert" && $fields[1] eq "OID" && $fields[2] eq "=")
{
$oid = $fields[3];
}
else
{
$oid = 0;
}
$data =~ s/\s+/ /g;
$bki .= $data . "\n";
}
elsif ($line =~ /^DESCR\("(.*)"\)$/m)
{
if ($oid != 0)
{
$desc .= sprintf("%d\t%s\t0\t%s\n", $oid, $catalog, $1);
}
}
elsif ($line =~ /^SHDESCR\("(.*)"\)$/m)
{
if ($oid != 0)
{
$shdesc .= sprintf("%d\t%s\t%s\n", $oid, $catalog, $1);
}
}
elsif ($line =~ /^DECLARE_(UNIQUE_)?INDEX\((.*)\)$/m)
{
if ($reln_open)
{
$bki .= "close $catalog\n";
$reln_open = 0;
}
my $u = $1?" unique":"";
my @fields = split /,/,$2,3;
$fields[0] =~ s/\s+//g;
$fields[1] =~ s/\s+//g;
$fields[2] =~ s/\s+/ /g;
$fields[2] =~ s/^\s+//;
$bki .= "declare$u index $fields[0] $fields[1] $fields[2]\n";
}
elsif ($line =~ /^DECLARE_TOAST\((.*)\)$/m)
{
if ($reln_open)
{
$bki .= "close $catalog\n";
$reln_open = 0;
}
my @fields = split /,/,$1;
$fields[1] =~ s/\s+//g;
$fields[2] =~ s/\s+//g;
$bki .= "declare toast $fields[1] $fields[2] on $fields[0]\n";
}
elsif ($line =~ /^BUILD_INDICES/)
{
$bki .= "build indices\n";
}
elsif ($line =~ /^CATALOG\(([^)]*)\)(.*)$/m)
{
if ($reln_open)
{
$bki .= "close $catalog\n";
$reln_open = 0;
}
my $rest = $2;
my @fields = split /,/,$1;
$catalog = $fields[0];
$oid = $fields[1];
$bootstrap=$shared_relation=$without_oids=$rowtype_oid="";
if ($rest =~ /BKI_BOOTSTRAP/)
{
$bootstrap = " bootstrap";
}
if ($rest =~ /BKI_SHARED_RELATION/)
{
$shared_relation = " shared_relation";
}
if ($rest =~ /BKI_WITHOUT_OIDS/)
{
$without_oids = " without_oids";
}
if ($rest =~ /BKI_ROWTYPE_OID\((\d+)\)/)
{
$rowtype_oid = " rowtype_oid $1";
}
$nc++;
$inside = 1;
next;
}
if ($inside==1)
{
next if ($line =~ /{/);
if ($line =~ /}/)
{
# Last line
$bki .= "create $catalog $oid$bootstrap$shared_relation$without_oids$rowtype_oid\n (\n";
my $first = 1;
for (my $i = 0; $i <= $#attr; $i++)
{
if ($first == 1)
{
$first = 0;
}
else
{
$bki .= " ,\n";
}
$bki .= " " . $attr[$i] . " = " . $types[$i];
}
$bki .= "\n )\n";
undef(@attr);
undef(@types);
$reln_open = 1;
$inside = 0;
if ($bootstrap eq "")
{
$bki .= "open $catalog\n";
}
next;
}
# inside catalog definition, so keep sucking up attributes
my @fields = split /\s+/,$line;
if ($fields[1] =~ /(.*)\[.*\]/)
{ #Array attribute
push @attr, $1;
push @types, $fields[0] . '[]';
}
else
{
push @attr, $fields[1];
push @types, $fields[0];
}
next;
}
}
if ($reln_open == 1)
{
$bki .= "close $catalog\n";
}
open(O,">$prefix.bki") || die "Could not write $prefix.bki\n";
print O "# PostgreSQL $majorversion\n";
print O $bki;
close(O);
open(O,">$prefix.description") || die "Could not write $prefix.description\n";
print O $desc;
close(O);
open(O,">$prefix.shdescription") || die "Could not write $prefix.shdescription\n";
print O $shdesc;
close(O);
}
sub read_file
{
my $filename = shift;
my $F;
my $t = $/;
undef $/;
open($F, $filename) || die "Could not open file $filename\n";
my $txt = <$F>;
close($F);
$/ = $t;
return $txt;
}
1;
......@@ -3,14 +3,12 @@ package Solution;
#
# Package that encapsulates a Visual C++ solution file generation
#
# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.51 2010/01/01 17:34:25 mha Exp $
# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.52 2010/01/05 01:06:57 tgl Exp $
#
use Carp;
use strict;
use warnings;
use Genbki;
sub new
{
my $junk = shift;
......@@ -240,7 +238,7 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
{
print "Generating fmgrtab.c and fmgroids.h...\n";
chdir('src\backend\utils');
system("perl Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h");
system("perl -I ../catalog Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h");
chdir('..\..\..');
copyFile('src\backend\utils\fmgroids.h','src\include\utils\fmgroids.h');
}
......@@ -339,12 +337,12 @@ EOF
next if $bki eq "";
if (IsNewer('src/backend/catalog/postgres.bki', "src/include/catalog/$bki"))
{
print "Generating postgres.bki...\n";
Genbki::genbki(
$self->{majorver},
"src/backend/catalog/postgres",
split(/ /,join(' src/include/catalog/',@allbki))
);
print "Generating postgres.bki and schemapg.h...\n";
chdir('src\backend\catalog');
my $bki_srcs = join(' ../../../src/include/catalog/', @allbki);
system("perl genbki.pl -I../../../src/include/catalog --set-version=$self->{majorver} $bki_srcs");
chdir('..\..\..');
copyFile('src\backend\catalog\schemapg.h', 'src\include\catalog\schemapg.h');
last;
}
}
......
@echo off
REM $PostgreSQL: pgsql/src/tools/msvc/clean.bat,v 1.17 2010/01/01 16:58:53 mha Exp $
REM $PostgreSQL: pgsql/src/tools/msvc/clean.bat,v 1.18 2010/01/05 01:06:57 tgl Exp $
set DIST=0
if "%1"=="dist" set DIST=1
......@@ -23,11 +23,12 @@ if %DIST%==1 if exist src\backend\parser\gram.h del /q src\backend\parser\gram.h
if exist src\include\utils\fmgroids.h del /q src\include\utils\fmgroids.h
if exist src\include\utils\probes.h del /q src\include\utils\probes.h
if exist src\backend\utils\fmgroids.h del /q src\backend\utils\fmgroids.h
if exist src\backend\utils\fmgrtab.c del /q src\backend\utils\fmgrtab.c
if exist src\backend\catalog\postgres.bki del /q src\backend\catalog\postgres.bki
if exist src\backend\catalog\postgres.description del /q src\backend\catalog\postgres.description
if exist src\backend\catalog\postgres.shdescription del /q src\backend\catalog\postgres.shdescription
if %DIST%==1 if exist src\backend\utils\fmgroids.h del /q src\backend\utils\fmgroids.h
if %DIST%==1 if exist src\backend\utils\fmgrtab.c del /q src\backend\utils\fmgrtab.c
if %DIST%==1 if exist src\backend\catalog\postgres.bki del /q src\backend\catalog\postgres.bki
if %DIST%==1 if exist src\backend\catalog\postgres.description del /q src\backend\catalog\postgres.description
if %DIST%==1 if exist src\backend\catalog\postgres.shdescription del /q src\backend\catalog\postgres.shdescription
if %DIST%==1 if exist src\backend\catalog\schemapg.h del /q src\backend\catalog\schemapg.h
if %DIST%==1 if exist src\backend\parser\scan.c del /q src\backend\parser\scan.c
if %DIST%==1 if exist src\backend\parser\gram.c del /q src\backend\parser\gram.c
if %DIST%==1 if exist src\backend\bootstrap\bootscanner.c del /q src\backend\bootstrap\bootscanner.c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment