Hide backend debug output in initdb by default. To that end, the bootstrap

backend gets on -o option like the regular backend.
This commit is contained in:
Peter Eisentraut 2001-08-25 00:31:17 +00:00
parent f5cda6d3f3
commit d374e06905
2 changed files with 52 additions and 30 deletions

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.114 2001/08/10 18:57:33 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.115 2001/08/25 00:31:17 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -187,10 +187,11 @@ usage(void)
{ {
fprintf(stderr, fprintf(stderr,
gettext("Usage:\n" gettext("Usage:\n"
" postgres -boot [-d] [-D datadir] [-F] [-x num] dbname\n" " postgres -boot [-d] [-D datadir] [-F] [-o file] [-x num] dbname\n"
" -d debug mode\n" " -d debug mode\n"
" -D datadir data directory\n" " -D datadir data directory\n"
" -F turn off fsync\n" " -F turn off fsync\n"
" -o file send debug output to file\n"
" -x num internal use\n")); " -x num internal use\n"));
proc_exit(1); proc_exit(1);
@ -248,7 +249,7 @@ BootstrapMain(int argc, char *argv[])
* variable */ * variable */
} }
while ((flag = getopt(argc, argv, "B:dD:Fpx:")) != EOF) while ((flag = getopt(argc, argv, "B:dD:Fo:px:")) != EOF)
{ {
switch (flag) switch (flag)
{ {
@ -262,6 +263,9 @@ BootstrapMain(int argc, char *argv[])
case 'F': case 'F':
SetConfigOption("fsync", "false", PGC_POSTMASTER, true); SetConfigOption("fsync", "false", PGC_POSTMASTER, true);
break; break;
case 'o':
StrNCpy(OutputFileName, optarg, MAXPGPATH);
break;
case 'x': case 'x':
xlogop = atoi(optarg); xlogop = atoi(optarg);
break; break;

View File

@ -27,7 +27,7 @@
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.132 2001/08/10 18:57:38 tgl Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.133 2001/08/25 00:31:17 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -343,14 +343,16 @@ POSTGRESQL_CONF_SAMPLE="$datadir"/postgresql.conf.sample
if [ "$show_setting" = yes ] || [ "$debug" = yes ] if [ "$show_setting" = yes ] || [ "$debug" = yes ]
then then
(
echo echo
echo "Initdb variables:" echo "initdb variables:"
for var in PGDATA datadir PGPATH MULTIBYTE MULTIBYTEID \ for var in PGDATA datadir PGPATH MULTIBYTE MULTIBYTEID \
POSTGRES_SUPERUSERNAME POSTGRES_SUPERUSERID POSTGRES_BKI \ POSTGRES_SUPERUSERNAME POSTGRES_SUPERUSERID POSTGRES_BKI \
POSTGRES_DESCR POSTGRESQL_CONF_SAMPLE \ POSTGRES_DESCR POSTGRESQL_CONF_SAMPLE \
PG_HBA_SAMPLE PG_IDENT_SAMPLE ; do PG_HBA_SAMPLE PG_IDENT_SAMPLE ; do
eval "echo ' '$var=\$$var" eval "echo ' '$var=\$$var"
done done
) 1>&2
fi fi
if [ "$show_setting" = yes ] ; then if [ "$show_setting" = yes ] ; then
@ -386,7 +388,7 @@ done
trap 'echo "Caught signal." ; exit_nicely' 1 2 3 15 trap 'echo "Caught signal." ; exit_nicely' 1 2 3 15
# Let's go # Let's go
echo "This database system will be initialized with username \"$POSTGRES_SUPERUSERNAME\"." echo "This database system will be initialized with user name \"$POSTGRES_SUPERUSERNAME\"."
echo "This user will own all the data files and must also own the server process." echo "This user will own all the data files and must also own the server process."
echo echo
@ -411,28 +413,32 @@ then
exit 1 exit 1
else else
if [ ! -d "$PGDATA" ]; then if [ ! -d "$PGDATA" ]; then
echo "Creating directory $PGDATA" $ECHO_N "creating directory $PGDATA... "$ECHO_C
mkdir -p "$PGDATA" >/dev/null 2>&1 || mkdir "$PGDATA" || exit_nicely mkdir -p "$PGDATA" >/dev/null 2>&1 || mkdir "$PGDATA" || exit_nicely
made_new_pgdata=yes made_new_pgdata=yes
else else
echo "Fixing permissions on existing directory $PGDATA" $ECHO_N "Fixing permissions on existing directory $PGDATA... "$ECHO_C
chmod go-rwx "$PGDATA" || exit_nicely chmod go-rwx "$PGDATA" || exit_nicely
fi fi
echo "ok"
if [ ! -d "$PGDATA"/base ] if [ ! -d "$PGDATA"/base ]
then then
echo "Creating directory $PGDATA/base" $ECHO_N "creating directory $PGDATA/base... "$ECHO_C
mkdir "$PGDATA"/base || exit_nicely mkdir "$PGDATA"/base || exit_nicely
echo "ok"
fi fi
if [ ! -d "$PGDATA"/global ] if [ ! -d "$PGDATA"/global ]
then then
echo "Creating directory $PGDATA/global" $ECHO_N "creating directory $PGDATA/global... "$ECHO_C
mkdir "$PGDATA"/global || exit_nicely mkdir "$PGDATA"/global || exit_nicely
echo "ok"
fi fi
if [ ! -d "$PGDATA"/pg_xlog ] if [ ! -d "$PGDATA"/pg_xlog ]
then then
echo "Creating directory $PGDATA/pg_xlog" $ECHO_N "creating directory $PGDATA/pg_xlog... "$ECHO_C
mkdir "$PGDATA"/pg_xlog || exit_nicely mkdir "$PGDATA"/pg_xlog || exit_nicely
echo "ok"
fi fi
fi fi
@ -441,32 +447,39 @@ fi
# #
# RUN BKI SCRIPT IN BOOTSTRAP MODE TO CREATE TEMPLATE1 # RUN BKI SCRIPT IN BOOTSTRAP MODE TO CREATE TEMPLATE1
rm -rf "$PGDATA"/base/1 || exit_nicely # common backend options
mkdir "$PGDATA"/base/1 || exit_nicely PGSQL_OPT="-F -D$PGDATA"
if [ "$debug" = yes ] if [ "$debug" = yes ]
then then
BACKEND_TALK_ARG="-d" BACKEND_TALK_ARG="-d"
else
PGSQL_OPT="$PGSQL_OPT -o /dev/null"
fi fi
FIRSTRUN="-boot -x1 -F -D$PGDATA $BACKEND_TALK_ARG"
echo "Creating template1 database in $PGDATA/base/1" $ECHO_N "creating template1 database in $PGDATA/base/1... "$ECHO_C
[ "$debug" = yes ] && echo "Running: $PGPATH/postgres $FIRSTRUN template1"
rm -rf "$PGDATA"/base/1 || exit_nicely
mkdir "$PGDATA"/base/1 || exit_nicely
cat "$POSTGRES_BKI" \ cat "$POSTGRES_BKI" \
| sed -e "s/POSTGRES/$POSTGRES_SUPERUSERNAME/g" \ | sed -e "s/POSTGRES/$POSTGRES_SUPERUSERNAME/g" \
-e "s/PGUID/$POSTGRES_SUPERUSERID/g" \ -e "s/PGUID/$POSTGRES_SUPERUSERID/g" \
-e "s/ENCODING/$MULTIBYTEID/g" \ -e "s/ENCODING/$MULTIBYTEID/g" \
| "$PGPATH"/postgres $FIRSTRUN template1 \ | "$PGPATH"/postgres -boot -x1 $PGSQL_OPT $BACKEND_TALK_ARG template1 \
|| exit_nicely || exit_nicely
echo $short_version > "$PGDATA"/base/1/PG_VERSION || exit_nicely echo $short_version > "$PGDATA"/base/1/PG_VERSION || exit_nicely
echo "ok"
########################################################################## ##########################################################################
# #
# CREATE CONFIG FILES # CREATE CONFIG FILES
$ECHO_N "creating configuration files... "$ECHO_C
echo $short_version > "$PGDATA/PG_VERSION" || exit_nicely echo $short_version > "$PGDATA/PG_VERSION" || exit_nicely
cp "$PG_HBA_SAMPLE" "$PGDATA"/pg_hba.conf || exit_nicely cp "$PG_HBA_SAMPLE" "$PGDATA"/pg_hba.conf || exit_nicely
@ -475,6 +488,8 @@ cp "$POSTGRESQL_CONF_SAMPLE" "$PGDATA"/postgresql.conf || exit_nicely
chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \ chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
"$PGDATA"/postgresql.conf "$PGDATA"/postgresql.conf
echo "ok"
########################################################################## ##########################################################################
# #
# CREATE VIEWS and other things # CREATE VIEWS and other things
@ -484,14 +499,9 @@ chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
# To break an SQL command across lines in this script, backslash-escape all # To break an SQL command across lines in this script, backslash-escape all
# internal newlines in the command. # internal newlines in the command.
if [ "$debug" = yes ] PGSQL_OPT="$PGSQL_OPT -O"
then
PGSQL_OPT="-O -F -D$PGDATA"
else
PGSQL_OPT="-o /dev/null -O -F -D$PGDATA"
fi
echo "Initializing pg_shadow." $ECHO_N "initializing pg_shadow... "$ECHO_C
"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
-- Create a trigger so that direct updates to pg_shadow will be written -- Create a trigger so that direct updates to pg_shadow will be written
@ -505,6 +515,7 @@ EOF
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
exit_nicely exit_nicely
fi fi
echo "ok"
# set up password # set up password
if [ "$PwPrompt" ]; then if [ "$PwPrompt" ]; then
@ -522,6 +533,7 @@ if [ "$PwPrompt" ]; then
echo "Passwords didn't match." 1>&2 echo "Passwords didn't match." 1>&2
exit_nicely exit_nicely
fi fi
$ECHO_N "setting password... "$ECHO_C
"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
ALTER USER "$POSTGRES_SUPERUSERNAME" WITH PASSWORD '$FirstPw'; ALTER USER "$POSTGRES_SUPERUSERNAME" WITH PASSWORD '$FirstPw';
EOF EOF
@ -529,14 +541,15 @@ EOF
exit_nicely exit_nicely
fi fi
if [ ! -f $PGDATA/global/pg_pwd ]; then if [ ! -f $PGDATA/global/pg_pwd ]; then
echo
echo "The password file wasn't generated. Please report this problem." 1>&2 echo "The password file wasn't generated. Please report this problem." 1>&2
exit_nicely exit_nicely
fi fi
echo "Setting password" echo "ok"
fi fi
echo "Enabling unlimited row width for system tables." $ECHO_N "enabling unlimited row size for system tables... "$ECHO_C
"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
ALTER TABLE pg_attrdef CREATE TOAST TABLE; ALTER TABLE pg_attrdef CREATE TOAST TABLE;
@ -549,9 +562,10 @@ EOF
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
exit_nicely exit_nicely
fi fi
echo "ok"
echo "Creating system views." $ECHO_N "creating system views... "$ECHO_C
"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
@ -795,8 +809,9 @@ EOF
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
exit_nicely exit_nicely
fi fi
echo "ok"
echo "Loading pg_description." $ECHO_N "loading pg_description... "$ECHO_C
( (
cat <<EOF cat <<EOF
CREATE TEMP TABLE tmp_pg_description ( \ CREATE TEMP TABLE tmp_pg_description ( \
@ -815,8 +830,9 @@ EOF
EOF EOF
) \ ) \
| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
echo "ok"
echo "Vacuuming database." $ECHO_N "vacuuming database template1... "$ECHO_C
"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
VACUUM FULL ANALYZE; VACUUM FULL ANALYZE;
@ -824,8 +840,9 @@ EOF
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
exit_nicely exit_nicely
fi fi
echo "ok"
echo "Copying template1 to template0." $ECHO_N "copying template1 to template0... "$ECHO_C
"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
CREATE DATABASE template0; CREATE DATABASE template0;
@ -845,6 +862,7 @@ EOF
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
exit_nicely exit_nicely
fi fi
echo "ok"
########################################################################## ##########################################################################