#!/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.10 1998/10/14 16:06:14 thomas 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 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; }' | \ @CPP@ @CPPSTDIN@ $BKIOPTS | \ egrep '^[0-9]' | \ sort -n > $RAWFILE # # 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 */ FuNkYfMgRsTuFf awk '{ print $2, $1; }' $RAWFILE | \ @TR@ @TRARGS@ | \ sed -e 's/^/#define F_/' >> $HFILE cat >> $HFILE < $TABCFILE < #include #ifdef WIN32 # include #else # ifdef HAVE_LIMITS_H # include # define MAXINT INT_MAX # else # include # endif #endif #include "utils/fmgrtab.h" FuNkYfMgRtAbStUfF awk '{ print "extern char *" $2 "();"; }' $RAWFILE >> $TABCFILE cat >> $TABCFILE <> $TABCFILE cat >> $TABCFILE < fmgr_builtins[i].proid) low = i + 1; else high = i - 1; } if (id == fmgr_builtins[i].proid) return(&fmgr_builtins[i]); return((FmgrCall *) NULL); } func_ptr fmgr_lookupByName(char *name) { int i; for (i=0;i