]> granicus.if.org Git - postgresql/commitdiff
Correct portability problem introduced by yours truly --- I used a
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Jun 2000 02:00:28 +0000 (02:00 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Jun 2000 02:00:28 +0000 (02:00 +0000)
conditional expression x?y:z in an awk program.  Seems old versions
of awk don't have that ...

src/backend/utils/Gen_fmgrtab.sh.in

index 7b8dd1a9b90aa62abf6e6e3f824661e13dbee620..bc6edf9019a86c71d33ac2c8dbe5f894e737b954 100644 (file)
@@ -9,7 +9,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.23 2000/05/29 20:18:30 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.24 2000/06/02 02:00:28 tgl Exp $
 #
 # NOTES
 #    Passes any -D options on to cpp prior to generating the list
@@ -82,7 +82,7 @@ cat > $OIDSFILE <<FuNkYfMgRsTuFf
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: Gen_fmgrtab.sh.in,v 1.23 2000/05/29 20:18:30 tgl Exp $
+ * $Id: Gen_fmgrtab.sh.in,v 1.24 2000/06/02 02:00:28 tgl Exp $
  *
  * NOTES
  *     ******************************
@@ -105,8 +105,8 @@ cat > $OIDSFILE <<FuNkYfMgRsTuFf
  *     For example, we want to be able to assign different macro names to both
  *     char_text() and int4_text() even though these both appear with proname
  *     'text'.  If the same C function appears in more than one pg_proc entry,
- *     its equivalent macro will be defined with the OID of the entry appearing
- *     first in pg_proc.h.
+ *     its equivalent macro will be defined with the lowest OID among those
+ *     entries.
  */
 FuNkYfMgRsTuFf
 
@@ -139,7 +139,7 @@ cat > $TABLEFILE <<FuNkYfMgRtAbStUfF
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.23 2000/05/29 20:18:30 tgl Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.24 2000/06/02 02:00:28 tgl Exp $
  *
  * NOTES
  *
@@ -170,11 +170,19 @@ cat >> $TABLEFILE <<FuNkYfMgRtAbStUfF
 const FmgrBuiltin fmgr_builtins[] = {
 FuNkYfMgRtAbStUfF
 
-awk '{ printf ("  { %d, \"%s\", %d, %s, %s, %s },\n"), \
-       $1, $(NF-1), $9, \
-       ($8 == "t") ? "true" : "false", \
-       ($4 == "11") ? "true" : "false", \
-       $(NF-1) }' $RAWFILE >> $TABLEFILE
+# Note: using awk arrays to translate from pg_proc values to fmgrtab values
+# may seem tedious, but avoid the temptation to write a quick x?y:z
+# conditional expression instead.  Not all awks have conditional expressions.
+
+awk 'BEGIN {
+    Strict["t"] = "true"
+    Strict["f"] = "false"
+    OldStyle["11"] = "true"
+    OldStyle["12"] = "false"
+}
+{ printf ("  { %d, \"%s\", %d, %s, %s, %s },\n"), \
+       $1, $(NF-1), $9, Strict[$8], OldStyle[$4], $(NF-1)
+}' $RAWFILE >> $TABLEFILE
 
 cat >> $TABLEFILE <<FuNkYfMgRtAbStUfF
   /* dummy entry is easier than getting rid of comma after last real one */