There's no longer any good reason for genbki.sh and Gen_fmgrtab.sh to

run the data through cpp, and we know of at least one platform where
unusual cpp behavior breaks the process.  So remove the cpp step,
and make consequent simplifications.
This commit is contained in:
Tom Lane 2004-01-04 05:57:21 +00:00
parent 4351f8823d
commit 187b190adb
5 changed files with 25 additions and 82 deletions

View File

@ -2,7 +2,7 @@
#
# Makefile for backend/catalog
#
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.49 2003/11/29 19:51:42 pgsql Exp $
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.50 2004/01/04 05:57:21 tgl Exp $
#
#-------------------------------------------------------------------------
@ -42,7 +42,7 @@ postgres.description: postgres.bki ;
postgres.bki: genbki.sh $(POSTGRES_BKI_SRCS) \
$(top_srcdir)/src/include/postgres_ext.h $(top_builddir)/src/include/pg_config_manual.h
CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $< $(BKIOPTS) -o postgres $(pg_includes) $(POSTGRES_BKI_SRCS) --set-version=$(VERSION)
AWK='$(AWK)' $(SHELL) $< $(pg_includes) --set-version=$(VERSION) -o postgres $(POSTGRES_BKI_SRCS)
.PHONY: install-data
install-data: $(BKIFILES) installdirs

View File

@ -10,7 +10,7 @@
#
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.31 2003/11/29 19:51:42 pgsql Exp $
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.32 2004/01/04 05:57:21 tgl Exp $
#
# NOTES
# non-essential whitespace is removed from the generated file.
@ -20,11 +20,9 @@
#-------------------------------------------------------------------------
: ${AWK='awk'}
: ${CPP='cc -E'}
CMDNAME=`basename $0`
BKIOPTS=
INCLUDE_DIRS=
OUTPUT_PREFIX=
INFILES=
@ -36,12 +34,6 @@ major_version=
while [ $# -gt 0 ]
do
case $1 in
-D)
BKIOPTS="$BKIOPTS -D$2"
shift;;
-D*)
BKIOPTS="$BKIOPTS $1"
;;
-I)
INCLUDE_DIRS="$INCLUDE_DIRS $2"
shift;;
@ -63,21 +55,20 @@ do
echo "$CMDNAME generates system catalog bootstrapping files."
echo
echo "Usage:"
echo " $CMDNAME [ -D define [...] ] [ -I dir ] --set-version=VERSION -o prefix files..."
echo " $CMDNAME [ -I dir ] --set-version=VERSION -o prefix files..."
echo
echo "Options:"
echo " -I path to postgres_ext.h and pg_config_manual.h files"
echo " -o prefix of output files"
echo " --set-version PostgreSQL version number for initdb cross-check"
echo
echo "The environment variables CPP and AWK determine which C"
echo "preprocessor and Awk program to use. The defaults are"
echo "\`cc -E' and \`awk'."
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
;;
@ -108,12 +99,8 @@ if [ x"$major_version" = x"" ] ; then
exit 1
fi
if [ x"$TMPDIR" = x"" ] ; then
TMPDIR=/tmp
fi
TMPFILE="$TMPDIR/genbkitmp$$.c"
TMPFILE="genbkitmp$$.c"
trap "rm -f $TMPFILE ${OUTPUT_PREFIX}.bki.$$ ${OUTPUT_PREFIX}.description.$$" 0 1 2 3 15
@ -214,7 +201,6 @@ sed -e "s/;[ ]*$//g" \
# ----------------
BEGIN {
inside = 0;
raw = 0;
bootstrap = "";
shared_relation = "";
without_oids = "";
@ -237,14 +223,6 @@ comment_level > 0 { next; }
/^[ ]*$/ { next; }
# ----------------
# anything in a BKI_BEGIN .. BKI_END block should be passed
# along without interpretation.
# ----------------
/^BKI_BEGIN/ { raw = 1; next; }
/^BKI_END/ { raw = 0; next; }
raw == 1 { print; next; }
# ----------------
# DATA() statements are basically passed right through after
# stripping off the DATA( and the ) on the end. However,
@ -410,9 +388,8 @@ END {
echo "# PostgreSQL $major_version" >${OUTPUT_PREFIX}.bki.$$
$CPP $BKIOPTS $TMPFILE | \
sed -e '/^[ ]*$/d' \
-e 's/[ ][ ]*/ /g' >>${OUTPUT_PREFIX}.bki.$$ || exit
-e 's/[ ][ ]*/ /g' $TMPFILE >>${OUTPUT_PREFIX}.bki.$$ || exit
#
# Sanity check: if one of the sed/awk/etc commands fails, we'll probably

View File

@ -9,20 +9,18 @@
#
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.sh,v 1.27 2003/11/29 19:51:57 pgsql Exp $
# $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.sh,v 1.28 2004/01/04 05:57:21 tgl Exp $
#
#-------------------------------------------------------------------------
CMDNAME=`basename $0`
: ${AWK='awk'}
: ${CPP='cc -E'}
cleanup(){
[ x"$noclean" != x"t" ] && rm -f "$CPPTMPFILE" "$RAWFILE" "$$-$OIDSFILE" "$$-$TABLEFILE"
[ x"$noclean" != x"t" ] && rm -f "$SORTEDFILE" "$$-$OIDSFILE" "$$-$TABLEFILE"
}
BKIOPTS=
noclean=
#
@ -31,12 +29,6 @@ noclean=
while [ $# -gt 0 ]
do
case $1 in
-D)
BKIOPTS="$BKIOPTS -D$2"
shift;;
-D*)
BKIOPTS="$BKIOPTS $1"
;;
--noclean)
noclean=t
;;
@ -44,17 +36,15 @@ do
echo "$CMDNAME generates fmgroids.h and fmgrtab.c from pg_proc.h."
echo
echo "Usage:"
echo " $CMDNAME [ -D define [...] ]"
echo " $CMDNAME inputfile"
echo
echo "The environment variables CPP and AWK determine which C"
echo "preprocessor and Awk program to use. The defaults are"
echo "\`cc -E' and \`awk'."
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
;;
--) shift; break;;
-*)
-*)
echo "$CMDNAME: invalid option: $1"
exit 1
;;
@ -71,8 +61,7 @@ if [ x"$INFILE" = x ] ; then
exit 1
fi
CPPTMPFILE="$$-fmgrtmp.c"
RAWFILE="$$-fmgr.raw"
SORTEDFILE="$$-fmgr.data"
OIDSFILE=fmgroids.h
TABLEFILE=fmgrtab.c
@ -84,34 +73,14 @@ trap 'echo "Caught signal." ; cleanup ; exit 1' 1 2 15
# Generate the file containing raw pg_proc tuple data
# (but only for "internal" language procedures...).
#
# Unlike genbki.sh, which can run through cpp last, we have to
# deal with preprocessor statements first (before we sort the
# function table by oid).
#
# Note assumption here that prolang == $5 and INTERNALlanguageId == 12.
#
$AWK '
BEGIN { raw = 0; }
/^DATA/ { print; next; }
/^BKI_BEGIN/ { raw = 1; next; }
/^BKI_END/ { raw = 0; next; }
raw == 1 { print; next; }' $INFILE | \
egrep '^DATA' $INFILE | \
sed -e 's/^.*OID[^=]*=[^0-9]*//' \
-e 's/(//g' \
-e 's/[ ]*).*$//' | \
$AWK '
/^#/ { print; next; }
$5 == "12" { print; next; }' > $CPPTMPFILE
if [ $? -ne 0 ]; then
cleanup
echo "$CMDNAME failed"
exit 1
fi
$CPP $BKIOPTS $CPPTMPFILE | \
egrep '^[ ]*[0-9]' | \
sort -n > $RAWFILE
$AWK '$5 == "12" { print }' | \
sort -n > $SORTEDFILE
if [ $? -ne 0 ]; then
cleanup
@ -165,7 +134,7 @@ FuNkYfMgRsTuFf
# Note assumption here that prosrc == $(NF-2).
tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $RAWFILE | \
tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $SORTEDFILE | \
$AWK '
BEGIN { OFS = ""; }
{ if (seenit[$(NF-2)]++ == 0) print "#define F_", $(NF-2), " ", $1; }' >> "$$-$OIDSFILE"
@ -215,7 +184,7 @@ FuNkYfMgRtAbStUfF
# Note assumption here that prosrc == $(NF-2).
$AWK '{ print "extern Datum", $(NF-2), "(PG_FUNCTION_ARGS);"; }' $RAWFILE >> "$$-$TABLEFILE"
$AWK '{ print "extern Datum", $(NF-2), "(PG_FUNCTION_ARGS);"; }' $SORTEDFILE >> "$$-$TABLEFILE"
if [ $? -ne 0 ]; then
cleanup
@ -242,7 +211,7 @@ $AWK 'BEGIN {
}
{ printf (" { %d, \"%s\", %d, %s, %s, %s },\n"), \
$1, $(NF-2), $11, Bool[$8], Bool[$9], $(NF-2)
}' $RAWFILE >> "$$-$TABLEFILE"
}' $SORTEDFILE >> "$$-$TABLEFILE"
if [ $? -ne 0 ]; then
cleanup

View File

@ -1,7 +1,7 @@
#
# Makefile for utils
#
# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.21 2003/11/29 19:51:57 pgsql Exp $
# $PostgreSQL: pgsql/src/backend/utils/Makefile,v 1.22 2004/01/04 05:57:21 tgl Exp $
#
subdir = src/backend/utils/
@ -24,7 +24,7 @@ $(SUBDIRS:%=%-recursive): fmgroids.h
$(MAKE) -C $(subst -recursive,,$@) SUBSYS.o
fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $< $(top_srcdir)/src/include/catalog/pg_proc.h
AWK='$(AWK)' $(SHELL) $< $(top_srcdir)/src/include/catalog/pg_proc.h
clean:

View File

@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.66 2003/11/29 22:40:53 pgsql Exp $
* $PostgreSQL: pgsql/src/include/postgres.h,v 1.67 2004/01/04 05:57:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -544,9 +544,6 @@ extern int ExceptionalCondition(char *conditionName, char *errorType,
#define DATA(x) extern int no_such_variable
#define DESCR(x) extern int no_such_variable
#define BKI_BEGIN
#define BKI_END
typedef int4 aclitem; /* PHONY definition for catalog use only */
#endif /* POSTGRES_H */