9
9
#
10
10
#
11
11
# IDENTIFICATION
12
- # $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.sh,v 1.27 2003/11/29 19:51:57 pgsql Exp $
12
+ # $PostgreSQL: pgsql/src/backend/utils/Gen_fmgrtab.sh,v 1.28 2004/01/04 05:57:21 tgl Exp $
13
13
#
14
14
# -------------------------------------------------------------------------
15
15
16
16
CMDNAME=` basename $0 `
17
17
18
18
: ${AWK=' awk' }
19
- : ${CPP=' cc -E' }
20
19
21
20
cleanup (){
22
- [ x" $noclean " != x" t" ] && rm -f " $CPPTMPFILE " " $RAWFILE " " $$ -$OIDSFILE " " $$ -$TABLEFILE "
21
+ [ x" $noclean " != x" t" ] && rm -f " $SORTEDFILE " " $$ -$OIDSFILE " " $$ -$TABLEFILE "
23
22
}
24
23
25
- BKIOPTS=
26
24
noclean=
27
25
28
26
#
@@ -31,30 +29,22 @@ noclean=
31
29
while [ $# -gt 0 ]
32
30
do
33
31
case $1 in
34
- -D)
35
- BKIOPTS=" $BKIOPTS -D$2 "
36
- shift ;;
37
- -D* )
38
- BKIOPTS=" $BKIOPTS $1 "
39
- ;;
40
32
--noclean)
41
33
noclean=t
42
34
;;
43
35
--help)
44
36
echo " $CMDNAME generates fmgroids.h and fmgrtab.c from pg_proc.h."
45
37
echo
46
38
echo " Usage:"
47
- echo " $CMDNAME [ -D define [...] ] "
39
+ echo " $CMDNAME inputfile "
48
40
echo
49
- echo " The environment variables CPP and AWK determine which C"
50
- echo " preprocessor and Awk program to use. The defaults are"
51
- echo " \` cc -E' and \` awk'."
41
+ echo " The environment variable AWK determines which Awk program"
42
+ echo " to use. The default is \` awk'."
52
43
echo
53
44
echo " Report bugs to <pgsql-bugs@postgresql.org>."
54
45
exit 0
55
46
;;
56
- --) shift ; break ;;
57
- -* )
47
+ -* )
58
48
echo " $CMDNAME : invalid option: $1 "
59
49
exit 1
60
50
;;
@@ -71,8 +61,7 @@ if [ x"$INFILE" = x ] ; then
71
61
exit 1
72
62
fi
73
63
74
- CPPTMPFILE=" $$ -fmgrtmp.c"
75
- RAWFILE=" $$ -fmgr.raw"
64
+ SORTEDFILE=" $$ -fmgr.data"
76
65
OIDSFILE=fmgroids.h
77
66
TABLEFILE=fmgrtab.c
78
67
@@ -84,34 +73,14 @@ trap 'echo "Caught signal." ; cleanup ; exit 1' 1 2 15
84
73
# Generate the file containing raw pg_proc tuple data
85
74
# (but only for "internal" language procedures...).
86
75
#
87
- # Unlike genbki.sh, which can run through cpp last, we have to
88
- # deal with preprocessor statements first (before we sort the
89
- # function table by oid).
90
- #
91
76
# Note assumption here that prolang == $5 and INTERNALlanguageId == 12.
92
77
#
93
- $AWK '
94
- BEGIN { raw = 0; }
95
- /^DATA/ { print; next; }
96
- /^BKI_BEGIN/ { raw = 1; next; }
97
- /^BKI_END/ { raw = 0; next; }
98
- raw == 1 { print; next; }' $INFILE | \
78
+ egrep ' ^DATA' $INFILE | \
99
79
sed -e ' s/^.*OID[^=]*=[^0-9]*//' \
100
80
-e ' s/(//g' \
101
81
-e ' s/[ ]*).*$//' | \
102
- $AWK '
103
- /^#/ { print; next; }
104
- $5 == "12" { print; next; }' > $CPPTMPFILE
105
-
106
- if [ $? -ne 0 ]; then
107
- cleanup
108
- echo " $CMDNAME failed"
109
- exit 1
110
- fi
111
-
112
- $CPP $BKIOPTS $CPPTMPFILE | \
113
- egrep ' ^[ ]*[0-9]' | \
114
- sort -n > $RAWFILE
82
+ $AWK ' $5 == "12" { print }' | \
83
+ sort -n > $SORTEDFILE
115
84
116
85
if [ $? -ne 0 ]; then
117
86
cleanup
@@ -165,7 +134,7 @@ FuNkYfMgRsTuFf
165
134
166
135
# Note assumption here that prosrc == $(NF-2).
167
136
168
- tr ' abcdefghijklmnopqrstuvwxyz' ' ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $RAWFILE | \
137
+ tr ' abcdefghijklmnopqrstuvwxyz' ' ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $SORTEDFILE | \
169
138
$AWK '
170
139
BEGIN { OFS = ""; }
171
140
{ if (seenit[$(NF-2)]++ == 0) print "#define F_", $(NF-2), " ", $1; }' >> " $$ -$OIDSFILE "
@@ -215,7 +184,7 @@ FuNkYfMgRtAbStUfF
215
184
216
185
# Note assumption here that prosrc == $(NF-2).
217
186
218
- $AWK ' { print "extern Datum", $(NF-2), "(PG_FUNCTION_ARGS);"; }' $RAWFILE >> " $$ -$TABLEFILE "
187
+ $AWK ' { print "extern Datum", $(NF-2), "(PG_FUNCTION_ARGS);"; }' $SORTEDFILE >> " $$ -$TABLEFILE "
219
188
220
189
if [ $? -ne 0 ]; then
221
190
cleanup
@@ -242,7 +211,7 @@ $AWK 'BEGIN {
242
211
}
243
212
{ printf (" { %d, \"%s\", %d, %s, %s, %s },\n"), \
244
213
$1, $(NF-2), $11, Bool[$8], Bool[$9], $(NF-2)
245
- }' $RAWFILE >> " $$ -$TABLEFILE "
214
+ }' $SORTEDFILE >> " $$ -$TABLEFILE "
246
215
247
216
if [ $? -ne 0 ]; then
248
217
cleanup
0 commit comments