1010#
1111#
1212# IDENTIFICATION
13- # $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh,v 1.24 2001/09/08 15:24:00 petere Exp $
13+ # $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh,v 1.25 2001/11/30 20:21:06 tgl Exp $
1414#
1515# NOTES
1616# non-essential whitespace is removed from the generated file.
1717# if this is ever a problem, then the sed script at the very
18- # end can be changed into another awk script or something smarter..
18+ # end can be changed into another awk script or something smarter.
1919#
2020# -------------------------------------------------------------------------
2121
@@ -121,7 +121,7 @@ trap "rm -f $TMPFILE ${OUTPUT_PREFIX}.bki.$$ ${OUTPUT_PREFIX}.description.$$" 0
121121# Get NAMEDATALEN from postgres_ext.h
122122for dir in $INCLUDE_DIRS ; do
123123if [-f " $dir /postgres_ext.h" ]; then
124- NAMEDATALEN=` grep' #define[ ]*NAMEDATALEN' $dir /postgres_ext.h| $AWK ' { print $3 }' `
124+ NAMEDATALEN=` grep' ^ #define[ ]*NAMEDATALEN' $dir /postgres_ext.h| $AWK ' { print $3 }' `
125125break
126126fi
127127done
@@ -130,16 +130,16 @@ done
130130# (who needs consistency?)
131131for dir in $INCLUDE_DIRS ; do
132132if [-f " $dir /pg_config.h" ]; then
133- INDEXMAXKEYS=` grep' #define[ ]*INDEX_MAX_KEYS' $dir /pg_config.h| $AWK ' { print $3 }' `
134- DEFAULTATTSTATTARGET=` grep' #define[ ]*DEFAULT_ATTSTATTARGET' $dir /pg_config.h| $AWK ' { print $3 }' `
133+ INDEXMAXKEYS=` grep' ^ #define[ ]*INDEX_MAX_KEYS' $dir /pg_config.h| $AWK ' { print $3 }' `
134+ DEFAULTATTSTATTARGET=` grep' ^ #define[ ]*DEFAULT_ATTSTATTARGET' $dir /pg_config.h| $AWK ' { print $3 }' `
135135break
136136fi
137137done
138138
139139# Get FirstGenBKIObjectId from access/transam.h
140140for dir in $INCLUDE_DIRS ; do
141141if [-f " $dir /access/transam.h" ]; then
142- BKIOBJECTID=` grep' #define[ ]*FirstGenBKIObjectId' $dir /access/transam.h| $AWK ' { print $3 }' `
142+ BKIOBJECTID=` grep' ^ #define[ ]*FirstGenBKIObjectId' $dir /access/transam.h| $AWK ' { print $3 }' `
143143break
144144fi
145145done
@@ -372,7 +372,7 @@ inside == 1 {
372372
373373# ----
374374# if we are inside the catalog definition, then keep sucking up
375- #attibute names and types
375+ #attribute names and types
376376# ----
377377if ($2 ~ /\[.*\]/) {# array attribute
378378idlen = index($2,"[") - 1;
@@ -401,6 +401,23 @@ $CPP $BKIOPTS $TMPFILE | \
401401sed -e' /^[ ]*$/d' \
402402 -e' s/[ ][ ]*/ /g' >> ${OUTPUT_PREFIX} .bki.$$ || exit
403403
404+ #
405+ # Sanity check: if one of the sed/awk/etc commands fails, we'll probably
406+ # end up with a .bki file that is empty or just a few lines. Cross-check
407+ # that the files are of reasonable size. The numbers here are arbitrary,
408+ # but are much smaller than the actual expected sizes as of Postgres 7.2.
409+ #
410+ if [` wc -c< ${OUTPUT_PREFIX} .bki.$$ ` -lt 100000 ]; then
411+ echo " $CMDNAME : something seems to be wrong with the .bki file" >&2
412+ exit 1
413+ fi
414+ if [` wc -c< ${OUTPUT_PREFIX} .description.$$ ` -lt 10000 ]; then
415+ echo " $CMDNAME : something seems to be wrong with the .description file" >&2
416+ exit 1
417+ fi
418+
419+ # Looks good, commit ...
420+
404421mv${OUTPUT_PREFIX} .bki.$$ ${OUTPUT_PREFIX} .bki|| exit
405422mv${OUTPUT_PREFIX} .description.$$ ${OUTPUT_PREFIX} .description|| exit
406423