Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4b362c6

Browse files
committed
Avoid substituting NAMEDATALEN, FLOAT4PASSBYVAL, and FLOAT8PASSBYVAL into
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.
1 parent a1c6923 commit 4b362c6

File tree

3 files changed

+21
-39
lines changed

3 files changed

+21
-39
lines changed

src/backend/catalog/genbki.sh

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.44 2008/04/21 00:26:45 tgl Exp $
14+
# $PostgreSQL: pgsql/src/backend/catalog/genbki.sh,v 1.45 2008/07/19 04:01:29 tgl Exp $
1515
#
1616
# NOTES
1717
# non-essential whitespace is removed from the generated file.
@@ -59,7 +59,7 @@ do
5959
echo " $CMDNAME [ -I dir ] --set-version=VERSION -o prefix files..."
6060
echo
6161
echo "Options:"
62-
echo " -I path to pg_config_manual.h file"
62+
echo " -I path to include files"
6363
echo " -o prefix of output files"
6464
echo " --set-version PostgreSQL version number for initdb cross-check"
6565
echo
@@ -106,22 +106,11 @@ TMPFILE="genbkitmp$$.c"
106106
trap "rm -f $TMPFILE ${OUTPUT_PREFIX}.bki.$$ ${OUTPUT_PREFIX}.description.$$ ${OUTPUT_PREFIX}.shdescription.$$" 0 1 2 3 15
107107

108108

109-
# Get NAMEDATALEN from pg_config_manual.h
110-
for dir in $INCLUDE_DIRS; do
111-
if [ -f "$dir/pg_config_manual.h" ]; then
112-
NAMEDATALEN=`grep '^#define[ ]*NAMEDATALEN' $dir/pg_config_manual.h | $AWK '{ print $3 }'`
113-
break
114-
fi
115-
done
116-
117-
# Get FLOAT4PASSBYVAL and FLOAT8PASSBYVAL from pg_config.h
118-
for dir in $INCLUDE_DIRS; do
119-
if [ -f "$dir/pg_config.h" ]; then
120-
FLOAT4PASSBYVAL=`grep '^#define[ ]*FLOAT4PASSBYVAL' $dir/pg_config.h | $AWK '{ print $3 }'`
121-
FLOAT8PASSBYVAL=`grep '^#define[ ]*FLOAT8PASSBYVAL' $dir/pg_config.h | $AWK '{ print $3 }'`
122-
break
123-
fi
124-
done
109+
# CAUTION: be wary about what symbols you substitute into the .bki file here!
110+
# It's okay to substitute things that are expected to be really constant
111+
# within a given Postgres release, such as fixed OIDs. Do not substitute
112+
# anything that could depend on platform or configuration. (The right place
113+
# to handle those sorts of things is in initdb.c's bootstrap_template1().)
125114

126115
# Get BOOTSTRAP_SUPERUSERID from catalog/pg_authid.h
127116
for dir in $INCLUDE_DIRS; do
@@ -172,9 +161,6 @@ sed -e "s/;[ ]*$//g" \
172161
-e "s/^TransactionId/xid/g" \
173162
-e "s/(TransactionId/(xid/g" \
174163
-e "s/PGUID/$BOOTSTRAP_SUPERUSERID/g" \
175-
-e "s/NAMEDATALEN/$NAMEDATALEN/g" \
176-
-e "s/FLOAT4PASSBYVAL/$FLOAT4PASSBYVAL/g" \
177-
-e "s/FLOAT8PASSBYVAL/$FLOAT8PASSBYVAL/g" \
178164
-e "s/PGNSP/$PG_CATALOG_NAMESPACE/g" \
179165
| $AWK '
180166
# ----------------

src/bin/initdb/initdb.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.157 2008/06/26 01:35:45 momjian Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.158 2008/07/19 04:01:29 tgl Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -1313,6 +1313,7 @@ bootstrap_template1(char *short_version)
13131313
char *talkargs = "";
13141314
char **bki_lines;
13151315
char headerline[MAXPGPATH];
1316+
char buf[64];
13161317

13171318
printf(_("creating template1 database in %s/base/1 ... "), pg_data);
13181319
fflush(stdout);
@@ -1337,6 +1338,17 @@ bootstrap_template1(char *short_version)
13371338
exit_nicely();
13381339
}
13391340

1341+
/* Substitute for various symbols used in the BKI file */
1342+
1343+
sprintf(buf, "%d", NAMEDATALEN);
1344+
bki_lines = replace_token(bki_lines, "NAMEDATALEN", buf);
1345+
1346+
bki_lines = replace_token(bki_lines, "FLOAT4PASSBYVAL",
1347+
FLOAT4PASSBYVAL ? "true" : "false");
1348+
1349+
bki_lines = replace_token(bki_lines, "FLOAT8PASSBYVAL",
1350+
FLOAT8PASSBYVAL ? "true" : "false");
1351+
13401352
bki_lines = replace_token(bki_lines, "POSTGRES", username);
13411353

13421354
bki_lines = replace_token(bki_lines, "ENCODING", encodingid);

src/tools/msvc/Genbki.pm

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $PostgreSQL: pgsql/src/tools/msvc/Genbki.pm,v 1.4 2008/04/21 00:26:47 tgl Exp $
14+
# $PostgreSQL: pgsql/src/tools/msvc/Genbki.pm,v 1.5 2008/07/19 04:01:29 tgl Exp $
1515
#
1616
#-------------------------------------------------------------------------
1717

@@ -33,19 +33,6 @@ sub genbki
3333
$version =~ /^(\d+\.\d+)/ || die "Bad format verison $version\n";
3434
my $majorversion = $1;
3535

36-
my $pgext = read_file("src/include/pg_config_manual.h");
37-
$pgext =~ /^#define\s+NAMEDATALEN\s+(\d+)$/mg
38-
|| die "Could not read NAMEDATALEN from pg_config_manual.h\n";
39-
my $namedatalen = $1;
40-
41-
my $pgconf = read_file("src/include/pg_config.h");
42-
$pgconf =~ /^#define\s+FLOAT4PASSBYVAL\s+(\w+)$/mg
43-
|| die "Could not read FLOAT4PASSBYVAL from pg_config.h\n";
44-
my $float4passbyval = $1;
45-
$pgconf =~ /^#define\s+FLOAT8PASSBYVAL\s+(\w+)$/mg
46-
|| die "Could not read FLOAT8PASSBYVAL from pg_config.h\n";
47-
my $float8passbyval = $1;
48-
4936
my $pgauthid = read_file("src/include/catalog/pg_authid.h");
5037
$pgauthid =~ /^#define\s+BOOTSTRAP_SUPERUSERID\s+(\d+)$/mg
5138
|| die "Could not read BOOTSTRAUP_SUPERUSERID from pg_authid.h\n";
@@ -78,9 +65,6 @@ sub genbki
7865
$indata =~ s{^TransactionId}{xid}gm;
7966
$indata =~ s{\(TransactionId}{(xid}g;
8067
$indata =~ s{PGUID}{$bootstrapsuperuserid}g;
81-
$indata =~ s{NAMEDATALEN}{$namedatalen}g;
82-
$indata =~ s{FLOAT4PASSBYVAL}{$float4passbyval}g;
83-
$indata =~ s{FLOAT8PASSBYVAL}{$float8passbyval}g;
8468
$indata =~ s{PGNSP}{$pgcatalognamespace}g;
8569

8670
#print $indata;

0 commit comments

Comments
 (0)