Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitac06a7a

Browse files
committed
Try to make genbki.sh a little more bulletproof, per trouble report
from Paul Stavrides.
1 parentc31bcbc commitac06a7a

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

‎src/backend/catalog/genbki.sh

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
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
122122
fordirin$INCLUDE_DIRS;do
123123
if [-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 }'`
125125
break
126126
fi
127127
done
@@ -130,16 +130,16 @@ done
130130
# (who needs consistency?)
131131
fordirin$INCLUDE_DIRS;do
132132
if [-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 }'`
135135
break
136136
fi
137137
done
138138

139139
# Get FirstGenBKIObjectId from access/transam.h
140140
fordirin$INCLUDE_DIRS;do
141141
if [-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 }'`
143143
break
144144
fi
145145
done
@@ -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
# ----
377377
if ($2 ~ /\[.*\]/) {# array attribute
378378
idlen = index($2,"[") - 1;
@@ -401,6 +401,23 @@ $CPP $BKIOPTS $TMPFILE | \
401401
sed -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+
404421
mv${OUTPUT_PREFIX}.bki.$$${OUTPUT_PREFIX}.bki||exit
405422
mv${OUTPUT_PREFIX}.description.$$${OUTPUT_PREFIX}.description||exit
406423

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp