99#
1010#
1111# IDENTIFICATION
12- # $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh,v 1.16 2000/07/06 21:33:30 petere Exp $
12+ # $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh,v 1.17 2000/07/13 16:07:06 petere Exp $
1313#
1414# -------------------------------------------------------------------------
1515
@@ -19,7 +19,7 @@ CMDNAME=`basename $0`
1919: ${CPP=' cc -E' }
2020
2121cleanup (){
22- [ x" $noclean " != x" t" ] && rm -f " $CPPTMPFILE " " $RAWFILE "
22+ [ x" $noclean " != x" t" ] && rm -f " $CPPTMPFILE " " $RAWFILE " " $$ - $OIDSFILE " " $$ - $TABLEFILE "
2323}
2424
2525BKIOPTS=
@@ -71,13 +71,13 @@ if [ x"$INFILE" = x ] ; then
7171 exit 1
7272fi
7373
74- CPPTMPFILE=fmgrtmp.c
75- RAWFILE=fmgr.raw
74+ CPPTMPFILE=" $$ - fmgrtmp.c"
75+ RAWFILE=" $$ - fmgr.raw"
7676OIDSFILE=fmgroids.h
7777TABLEFILE=fmgrtab.c
7878
7979
80- trap ' echo "Caught signal." ; cleanup ; exit 1' 1 2 3 15
80+ trap ' echo "Caught signal." ; cleanup ; exit 1' 1 2 15
8181
8282
8383#
@@ -124,7 +124,7 @@ cpp_define=`echo $OIDSFILE | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTU
124124#
125125# Generate fmgroids.h
126126#
127- cat > " $OIDSFILE " << FuNkYfMgRsTuFf
127+ cat > " $$ - $ OIDSFILE" << FuNkYfMgRsTuFf
128128/*-------------------------------------------------------------------------
129129 *
130130 * $OIDSFILE
@@ -165,15 +165,15 @@ FuNkYfMgRsTuFf
165165tr ' abcdefghijklmnopqrstuvwxyz' ' ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $RAWFILE | \
166166$AWK '
167167BEGIN { OFS = ""; }
168- { if (seenit[$(NF-1)]++ == 0) print "#define F_", $(NF-1), " ", $1; }' >> " $OIDSFILE "
168+ { if (seenit[$(NF-1)]++ == 0) print "#define F_", $(NF-1), " ", $1; }' >> " $$ - $ OIDSFILE"
169169
170170if [ $? -ne 0 ]; then
171171 cleanup
172172 echo " $CMDNAME failed"
173173 exit 1
174174fi
175175
176- cat >> " $OIDSFILE " << FuNkYfMgRsTuFf
176+ cat >> " $$ - $ OIDSFILE" << FuNkYfMgRsTuFf
177177
178178#endif /* $cpp_define */
179179FuNkYfMgRsTuFf
@@ -187,7 +187,7 @@ FuNkYfMgRsTuFf
187187# this table definition as a separate C file that won't need to include any
188188# "real" declarations for those functions!
189189#
190- cat > " $TABLEFILE " << FuNkYfMgRtAbStUfF
190+ cat > " $$ - $ TABLEFILE" << FuNkYfMgRtAbStUfF
191191/*-------------------------------------------------------------------------
192192 *
193193 * $TABLEFILE
@@ -218,7 +218,7 @@ cat > "$TABLEFILE" <<FuNkYfMgRtAbStUfF
218218
219219FuNkYfMgRtAbStUfF
220220
221- $AWK ' { print "extern Datum", $(NF-1), "(PG_FUNCTION_ARGS);"; }' $RAWFILE >> " $TABLEFILE "
221+ $AWK ' { print "extern Datum", $(NF-1), "(PG_FUNCTION_ARGS);"; }' $RAWFILE >> " $$ - $ TABLEFILE"
222222
223223if [ $? -ne 0 ]; then
224224 cleanup
@@ -227,7 +227,7 @@ if [ $? -ne 0 ]; then
227227fi
228228
229229
230- cat >> " $TABLEFILE " << FuNkYfMgRtAbStUfF
230+ cat >> " $$ - $ TABLEFILE" << FuNkYfMgRtAbStUfF
231231
232232const FmgrBuiltin fmgr_builtins[] = {
233233FuNkYfMgRtAbStUfF
@@ -244,15 +244,15 @@ $AWK 'BEGIN {
244244}
245245{ printf (" { %d, \"%s\", %d, %s, %s, %s },\n"), \
246246 $1, $(NF-1), $9, Strict[$8], OldStyle[$4], $(NF-1)
247- }' $RAWFILE >> " $TABLEFILE "
247+ }' $RAWFILE >> " $$ - $ TABLEFILE"
248248
249249if [ $? -ne 0 ]; then
250250 cleanup
251251 echo " $CMDNAME failed"
252252 exit 1
253253fi
254254
255- cat >> " $TABLEFILE " << FuNkYfMgRtAbStUfF
255+ cat >> " $$ - $ TABLEFILE" << FuNkYfMgRtAbStUfF
256256 /* dummy entry is easier than getting rid of comma after last real one */
257257 /* (not that there has ever been anything wrong with *having* a
258258 comma after the last field in an array initializer) */
@@ -264,5 +264,10 @@ const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin)) - 1;
264264
265265FuNkYfMgRtAbStUfF
266266
267+ # We use the temporary files to avoid problems with concurrent runs
268+ # (which can happen during parallel make).
269+ mv " $$ -$OIDSFILE " $OIDSFILE
270+ mv " $$ -$TABLEFILE " $TABLEFILE
271+
267272cleanup
268273exit 0
0 commit comments