#!/bin/sh #------------------------------------------------------------------------- # # Gen_fmgrtab.sh-- # shell script to generate fmgr.h and fmgrtab.c from pg_proc.h # # Copyright (c) 1994, Regents of the University of California # # # IDENTIFICATION # $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.16 1999/07/15 23:03:25 momjian Exp $ # # NOTES # Passes any -D options on to cpp prior to generating the list # of internal functions. These come from BKIOPTS. # #------------------------------------------------------------------------- if [ $? != 0 ] then echo `basename $0`: Bad option exit 1 fi BKIOPTS='' # # Pass on any -D declarations, throwing away any other command # line switches. # for opt in $* do case $opt in -D) BKIOPTS="$BKIOPTS -D$2"; shift; shift;; -D*) BKIOPTS="$BKIOPTS $1";shift;; --) shift; break;; -*) shift;; esac done INFILE=$1 RAWFILE=fmgr.raw CPPTMPFILE=fmgrtmp.c HFILE=fmgr.h TABCFILE=fmgrtab.c # # 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). # awk ' BEGIN { raw = 0; } /^DATA/ { print; next; } /^BKI_BEGIN/ { raw = 1; next; } /^BKI_END/ { raw = 0; next; } raw == 1 { print; next; }' $INFILE | \ sed -e 's/^.*OID[^=]*=[^0-9]*//' \ -e 's/(//g' \ -e 's/[ ]*).*$//' | \ awk ' /^#/ { print; next; } $4 == "11" { print; next; }' > $CPPTMPFILE @CPP@ $BKIOPTS $CPPTMPFILE | \ egrep '^[0-9]' | \ sort -n > $RAWFILE rm -f $CPPTMPFILE # # Generate fmgr.h # cat > $HFILE <fn_addr \ ) #ifdef TRACE_FMGR_PTR #define FMGR_PTR2(FINFO, ARG1, ARG2) \ fmgr_ptr(FINFO, 2, ARG1, ARG2) #else #define FMGR_PTR2(FINFO, ARG1, ARG2) \ ( \ ((FINFO)->fn_addr) ? \ (*(fmgr_faddr(FINFO)))(ARG1, ARG2) \ : \ fmgr((FINFO)->fn_oid, ARG1, ARG2) \ ) #endif /* * Flags for the builtin oprrest selectivity routines. */ #define SEL_CONSTANT 1 /* constant does not vary (not a parameter) */ #define SEL_RIGHT 2 /* constant appears to right of operator */ /* * Constant macros for the OIDs of entries in pg_proc. * NOTE: if the same "proname" is used for more than one * internal-function entry in pg_proc, the equivalent macro * will be defined with the lowest OID among those entries. */ FuNkYfMgRsTuFf @TR@ @TRARGS@ < $RAWFILE | \ awk ' BEGIN { OFS = ""; } { if (seenit[$2]++ == 0) print "#define F_", $2, " ", $1; }' >> $HFILE cat >> $HFILE < $TABCFILE < #include "postgres.h" #include "utils/fmgrtab.h" FuNkYfMgRtAbStUfF awk '{ print "extern char *", $(NF-1), "();"; }' $RAWFILE >> $TABCFILE cat >> $TABCFILE <> $TABCFILE cat >> $TABCFILE <proid) return ptr; else if (id > ptr->proid) low = i + 1; else high = i - 1; } return (FmgrCall *) NULL; } func_ptr fmgr_lookupByName(char *name) { /* Lookup a builtin by name. Note there can be more than one entry in * the array matching this name, but they should all point to the same * routine. */ int i; for (i=0; i