Back before Christmas I complained that elog.c's behavior of
prioritizing LOG-level messages differently in standalone mode had
masked at least one significant bug, as well as causing confusion
in some other cases:
http://www.postgresql.org/message-id/6967.1355520...@sss.pgh.pa.us

I promptly forgot to do anything about it, but I'd still like to get
such a change into 9.3.  I've now written and tested a patch that
makes that change without creating any new noise during initdb or in a
manually-started standalone backend.  Does anyone have an objection to
applying the attached?

                        regards, tom lane

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 7210ca5fddba177fb1c6949761e938165892bb28..654c9c18d8ba0168c44c81e428b5c26731921a8d 100644
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
*************** StartupXLOG(void)
*** 4883,4891 ****
  				(errmsg("control file contains invalid data")));
  
  	if (ControlFile->state == DB_SHUTDOWNED)
! 		ereport(LOG,
  				(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",
--- 4883,4894 ----
  				(errmsg("control file contains invalid data")));
  
  	if (ControlFile->state == DB_SHUTDOWNED)
! 	{
! 		/* 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",
*************** GetNextXidAndEpoch(TransactionId *xid, u
*** 6590,6596 ****
  void
  ShutdownXLOG(int code, Datum arg)
  {
! 	ereport(LOG,
  			(errmsg("shutting down")));
  
  	if (RecoveryInProgress())
--- 6593,6600 ----
  void
  ShutdownXLOG(int code, Datum arg)
  {
! 	/* Don't be chatty in standalone mode */
! 	ereport(IsPostmasterEnvironment ? LOG : NOTICE,
  			(errmsg("shutting down")));
  
  	if (RecoveryInProgress())
*************** ShutdownXLOG(int code, Datum arg)
*** 6612,6618 ****
  	ShutdownSUBTRANS();
  	ShutdownMultiXact();
  
! 	ereport(LOG,
  			(errmsg("database system is shut down")));
  }
  
--- 6616,6623 ----
  	ShutdownSUBTRANS();
  	ShutdownMultiXact();
  
! 	/* 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 e9eb3d5be8cc8fbb4fc3ba4dc58f1b27e1057e45..7f03f419dead8f7f325a8e24a345d23fb1667192 100644
*** a/src/backend/utils/error/elog.c
--- b/src/backend/utils/error/elog.c
*************** errstart(int elevel, const char *filenam
*** 285,295 ****
  	 */
  
  	/* 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);
  
  	/* Determine whether message is enabled for client output */
  	if (whereToSendOutput == DestRemote && elevel != COMMERROR)
--- 285,291 ----
  	 */
  
  	/* Determine whether message is enabled for server log output */
! 	output_to_server = is_log_level_output(elevel, log_min_messages);
  
  	/* Determine whether message is enabled for client output */
  	if (whereToSendOutput == DestRemote && elevel != COMMERROR)
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to