Avoid substituting NAMEDATALEN, FLOAT4PASSBYVAL, and FLOAT8PASSBYVAL into
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 19 Jul 2008 04:01:29 +0000 (04:01 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 19 Jul 2008 04:01:29 +0000 (04:01 +0000)
the postgres.bki file during build, because we want that file to be entirely
platform- and configuration-independent; else it can't safely be put into
/usr/share on multiarch machines.  We can do the substitution during initdb,
instead.  FLOAT4PASSBYVAL and FLOAT8PASSBYVAL are new breakage as of 8.4,
while the NAMEDATALEN hazard has been there all along but I guess no one
tripped over it.  Noticed while trying to build "universal" OS X binaries.

src/backend/catalog/genbki.sh
src/bin/initdb/initdb.c
src/tools/msvc/Genbki.pm

index 88d72ce1c8d8f5a64595b3431c19652aec0e6aca..428228fba5667aa5e94df3aeffce957d12d9b417 100644 (file)
@@ -59,7 +59,7 @@ do
             echo "  $CMDNAME [ -I dir ] --set-version=VERSION -o prefix files..."
             echo
             echo "Options:"
-            echo "  -I  path to pg_config_manual.h file"
+            echo "  -I  path to include files"
             echo "  -o  prefix of output files"
             echo "  --set-version  PostgreSQL version number for initdb cross-check"
             echo
@@ -106,22 +106,11 @@ TMPFILE="genbkitmp$$.c"
 trap "rm -f $TMPFILE ${OUTPUT_PREFIX}.bki.$$ ${OUTPUT_PREFIX}.description.$$ ${OUTPUT_PREFIX}.shdescription.$$" 0 1 2 3 15
 
 
-# Get NAMEDATALEN from pg_config_manual.h
-for dir in $INCLUDE_DIRS; do
-    if [ -f "$dir/pg_config_manual.h" ]; then
-        NAMEDATALEN=`grep '^#define[   ]*NAMEDATALEN' $dir/pg_config_manual.h | $AWK '{ print $3 }'`
-        break
-    fi
-done
-
-# Get FLOAT4PASSBYVAL and FLOAT8PASSBYVAL from pg_config.h
-for dir in $INCLUDE_DIRS; do
-    if [ -f "$dir/pg_config.h" ]; then
-        FLOAT4PASSBYVAL=`grep '^#define[       ]*FLOAT4PASSBYVAL' $dir/pg_config.h | $AWK '{ print $3 }'`
-        FLOAT8PASSBYVAL=`grep '^#define[       ]*FLOAT8PASSBYVAL' $dir/pg_config.h | $AWK '{ print $3 }'`
-        break
-    fi
-done
+# CAUTION: be wary about what symbols you substitute into the .bki file here!
+# It's okay to substitute things that are expected to be really constant
+# within a given Postgres release, such as fixed OIDs.  Do not substitute
+# anything that could depend on platform or configuration.  (The right place
+# to handle those sorts of things is in initdb.c's bootstrap_template1().)
 
 # Get BOOTSTRAP_SUPERUSERID from catalog/pg_authid.h
 for dir in $INCLUDE_DIRS; do
@@ -172,9 +161,6 @@ sed -e "s/;[        ]*$//g" \
     -e "s/^TransactionId/xid/g" \
     -e "s/(TransactionId/(xid/g" \
     -e "s/PGUID/$BOOTSTRAP_SUPERUSERID/g" \
-    -e "s/NAMEDATALEN/$NAMEDATALEN/g" \
-    -e "s/FLOAT4PASSBYVAL/$FLOAT4PASSBYVAL/g" \
-    -e "s/FLOAT8PASSBYVAL/$FLOAT8PASSBYVAL/g" \
     -e "s/PGNSP/$PG_CATALOG_NAMESPACE/g" \
 | $AWK '
 # ----------------
index cb5d8dd23461f9438898f84b5fe4e01f6a9db6b7..08cd9f203751d12235585c62fd9c8ca3376a5bdd 100644 (file)
@@ -1313,6 +1313,7 @@ bootstrap_template1(char *short_version)
        char       *talkargs = "";
        char      **bki_lines;
        char            headerline[MAXPGPATH];
+       char            buf[64];
 
        printf(_("creating template1 database in %s/base/1 ... "), pg_data);
        fflush(stdout);
@@ -1337,6 +1338,17 @@ bootstrap_template1(char *short_version)
                exit_nicely();
        }
 
+       /* Substitute for various symbols used in the BKI file */
+
+       sprintf(buf, "%d", NAMEDATALEN);
+       bki_lines = replace_token(bki_lines, "NAMEDATALEN", buf);
+
+       bki_lines = replace_token(bki_lines, "FLOAT4PASSBYVAL",
+                                                         FLOAT4PASSBYVAL ? "true" : "false");
+
+       bki_lines = replace_token(bki_lines, "FLOAT8PASSBYVAL",
+                                                         FLOAT8PASSBYVAL ? "true" : "false");
+
        bki_lines = replace_token(bki_lines, "POSTGRES", username);
 
        bki_lines = replace_token(bki_lines, "ENCODING", encodingid);
index 8c305101e3dc3f28d7dad04b0786c74d504a7eee..3009662679140711ce275f12c77b210c20d62b9e 100644 (file)
@@ -33,19 +33,6 @@ sub genbki
     $version =~ /^(\d+\.\d+)/ || die "Bad format verison $version\n";
     my $majorversion = $1;
 
-    my $pgext = read_file("src/include/pg_config_manual.h");
-    $pgext =~ /^#define\s+NAMEDATALEN\s+(\d+)$/mg
-      || die "Could not read NAMEDATALEN from pg_config_manual.h\n";
-    my $namedatalen = $1;
-
-    my $pgconf = read_file("src/include/pg_config.h");
-    $pgconf =~ /^#define\s+FLOAT4PASSBYVAL\s+(\w+)$/mg
-      || die "Could not read FLOAT4PASSBYVAL from pg_config.h\n";
-    my $float4passbyval = $1;
-    $pgconf =~ /^#define\s+FLOAT8PASSBYVAL\s+(\w+)$/mg
-      || die "Could not read FLOAT8PASSBYVAL from pg_config.h\n";
-    my $float8passbyval = $1;
-
     my $pgauthid = read_file("src/include/catalog/pg_authid.h");
     $pgauthid =~ /^#define\s+BOOTSTRAP_SUPERUSERID\s+(\d+)$/mg
       || die "Could not read BOOTSTRAUP_SUPERUSERID from pg_authid.h\n";
@@ -78,9 +65,6 @@ sub genbki
     $indata =~ s{^TransactionId}{xid}gm;
     $indata =~ s{\(TransactionId}{(xid}g;
     $indata =~ s{PGUID}{$bootstrapsuperuserid}g;
-    $indata =~ s{NAMEDATALEN}{$namedatalen}g;
-    $indata =~ s{FLOAT4PASSBYVAL}{$float4passbyval}g;
-    $indata =~ s{FLOAT8PASSBYVAL}{$float8passbyval}g;
     $indata =~ s{PGNSP}{$pgcatalognamespace}g;
 
     #print $indata;