From: Tom Lane Date: Fri, 14 Jun 2013 03:15:15 +0000 (-0400) Subject: Remove special-case treatment of LOG severity level in standalone mode. X-Git-Tag: REL9_3_BETA2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c62866eeafd52822ec61a0d2db9428c05e97d3cc;p=postgresql Remove special-case treatment of LOG severity level in standalone mode. elog.c has historically treated LOG messages as low-priority during bootstrap and standalone operation. This has led to confusion and even masked a bug, because the normal expectation of code authors is that elog(LOG) will put something into the postmaster log, and that wasn't happening during initdb. So get rid of the special-case rule and make the priority order the same as it is in normal operation. To keep from cluttering initdb's output and the behavior of a standalone backend, tweak the severity level of three messages routinely issued by xlog.c during startup and shutdown so that they won't appear in these cases. Per my proposal back in December. --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 7210ca5fdd..654c9c18d8 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4883,9 +4883,12 @@ StartupXLOG(void) (errmsg("control file contains invalid data"))); if (ControlFile->state == DB_SHUTDOWNED) - ereport(LOG, + { + /* This is the expected case, so don't be chatty in standalone mode */ + ereport(IsPostmasterEnvironment ? LOG : NOTICE, (errmsg("database system was shut down at %s", str_time(ControlFile->time)))); + } else if (ControlFile->state == DB_SHUTDOWNED_IN_RECOVERY) ereport(LOG, (errmsg("database system was shut down in recovery at %s", @@ -6590,7 +6593,8 @@ GetNextXidAndEpoch(TransactionId *xid, uint32 *epoch) void ShutdownXLOG(int code, Datum arg) { - ereport(LOG, + /* Don't be chatty in standalone mode */ + ereport(IsPostmasterEnvironment ? LOG : NOTICE, (errmsg("shutting down"))); if (RecoveryInProgress()) @@ -6612,7 +6616,8 @@ ShutdownXLOG(int code, Datum arg) ShutdownSUBTRANS(); ShutdownMultiXact(); - ereport(LOG, + /* Don't be chatty in standalone mode */ + ereport(IsPostmasterEnvironment ? LOG : NOTICE, (errmsg("database system is shut down"))); } diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index e9eb3d5be8..7f03f419de 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -285,11 +285,7 @@ errstart(int elevel, const char *filename, int lineno, */ /* Determine whether message is enabled for server log output */ - if (IsPostmasterEnvironment) - output_to_server = is_log_level_output(elevel, log_min_messages); - else - /* In bootstrap/standalone case, do not sort LOG out-of-order */ - output_to_server = (elevel >= log_min_messages); + output_to_server = is_log_level_output(elevel, log_min_messages); /* Determine whether message is enabled for client output */ if (whereToSendOutput == DestRemote && elevel != COMMERROR)