Skip to content

Commit aae0781

Browse files
committed
In bootstrap and standalone-backend modes, do not sort LOG elevel out
of order; the 'server log' output is actually client output in these scenarios and we ought to treat elevels the same way as in the client case. This allows initdb to not send backend stderr to /dev/null anymore, which makes it much more likely that people will notice problems during initdb.
1 parent fc8d970 commit aae0781

File tree

5 files changed

+35
-24
lines changed

5 files changed

+35
-24
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.329 2003/05/27 17:49:46 momjian Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.330 2003/05/28 17:25:02 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -379,6 +379,8 @@ PostmasterMain(int argc, char *argv[])
379379

380380
progname = argv[0];
381381

382+
IsPostmasterEnvironment = true;
383+
382384
/*
383385
* Catch standard options before doing much else. This even works on
384386
* systems without getopt_long.

src/backend/utils/error/elog.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.109 2003/04/24 21:16:44 tgl Exp $
40+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.110 2003/05/28 17:25:02 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -189,25 +189,33 @@ errstart(int elevel, const char *filename, int lineno,
189189
}
190190

191191
/* Determine whether message is enabled for server log output */
192-
/* Complicated because LOG is sorted out-of-order for this purpose */
193-
if (elevel == LOG || elevel == COMMERROR)
192+
if (IsPostmasterEnvironment)
194193
{
195-
if (log_min_messages == LOG)
196-
output_to_server = true;
197-
else if (log_min_messages < FATAL)
198-
output_to_server = true;
199-
}
200-
else
201-
{
202-
/* elevel != LOG */
203-
if (log_min_messages == LOG)
194+
/* Complicated because LOG is sorted out-of-order for this purpose */
195+
if (elevel == LOG || elevel == COMMERROR)
204196
{
205-
if (elevel >= FATAL)
197+
if (log_min_messages == LOG)
198+
output_to_server = true;
199+
else if (log_min_messages < FATAL)
206200
output_to_server = true;
207201
}
208-
/* Neither is LOG */
209-
else if (elevel >= log_min_messages)
210-
output_to_server = true;
202+
else
203+
{
204+
/* elevel != LOG */
205+
if (log_min_messages == LOG)
206+
{
207+
if (elevel >= FATAL)
208+
output_to_server = true;
209+
}
210+
/* Neither is LOG */
211+
else if (elevel >= log_min_messages)
212+
output_to_server = true;
213+
}
214+
}
215+
else
216+
{
217+
/* In bootstrap/standalone case, do not sort LOG out-of-order */
218+
output_to_server = (elevel >= log_min_messages);
211219
}
212220

213221
/* Determine whether message is enabled for client output */

src/backend/utils/init/globals.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.69 2003/02/22 05:57:45 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.70 2003/05/28 17:25:02 tgl Exp $
1212
*
1313
* NOTES
1414
* Globals used all over the place should be declared here and not
@@ -57,6 +57,8 @@ char *DatabasePath = NULL;
5757

5858
Oid MyDatabaseId = InvalidOid;
5959

60+
/* these are initialized for the bootstrap/standalone case: */
61+
bool IsPostmasterEnvironment = false;
6062
bool IsUnderPostmaster = false;
6163

6264
int DateStyle = USE_ISO_DATES;

src/bin/initdb/initdb.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
2828
# Portions Copyright (c) 1994, Regents of the University of California
2929
#
30-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.189 2003/05/15 15:50:19 petere Exp $
30+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.190 2003/05/28 17:25:02 tgl Exp $
3131
#
3232
#-------------------------------------------------------------------------
3333

@@ -546,9 +546,7 @@ PGSQL_OPT="-F -D$PGDATA"
546546

547547
if [ "$debug" = yes ]
548548
then
549-
BACKEND_TALK_ARG="-d 5"
550-
else
551-
PGSQL_OPT="$PGSQL_OPT -o /dev/null"
549+
BOOTSTRAP_TALK_ARG="-d 5"
552550
fi
553551

554552

@@ -570,7 +568,7 @@ cat "$POSTGRES_BKI" \
570568
export LC_COLLATE
571569
export LC_CTYPE
572570
unset LC_ALL
573-
"$PGPATH"/postgres -boot -x1 $PGSQL_OPT $BACKEND_TALK_ARG template1
571+
"$PGPATH"/postgres -boot -x1 $PGSQL_OPT $BOOTSTRAP_TALK_ARG template1
574572
) \
575573
|| exit_nicely
576574

src/include/miscadmin.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: miscadmin.h,v 1.121 2003/05/03 03:52:07 momjian Exp $
15+
* $Id: miscadmin.h,v 1.122 2003/05/28 17:25:02 tgl Exp $
1616
*
1717
* NOTES
1818
* some of the information in this file should be moved to
@@ -104,6 +104,7 @@ extern void ProcessInterrupts(void);
104104
/*
105105
* from postmaster/postmaster.c
106106
*/
107+
extern bool IsPostmasterEnvironment;
107108
extern bool IsUnderPostmaster;
108109
extern bool ClientAuthInProgress;
109110
extern const bool ExecBackend;

0 commit comments

Comments
 (0)