v2-0004-Remove-am_syslogger-global-variable.patch

text/plain

Filename: v2-0004-Remove-am_syslogger-global-variable.patch
Type: text/plain
Part: 3
Message: Re: backend type in log_line_prefix?

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v2-0004
Subject: Remove am_syslogger global variable
File+
src/backend/postmaster/syslogger.c 1 8
src/backend/utils/error/elog.c 4 4
src/include/postmaster/syslogger.h 0 2
From 2ffee681f3c17a674f3cab1f512dfbbd79e43357 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Thu, 20 Feb 2020 18:17:28 +0100
Subject: [PATCH v2 4/4] Remove am_syslogger global variable

Use MyBackendType instead.
---
 src/backend/postmaster/syslogger.c | 9 +--------
 src/backend/utils/error/elog.c     | 8 ++++----
 src/include/postmaster/syslogger.h | 2 --
 3 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index 20c59e9b6a..cfb189550e 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -74,11 +74,6 @@ char	   *Log_filename = NULL;
 bool		Log_truncate_on_rotation = false;
 int			Log_file_mode = S_IRUSR | S_IWUSR;
 
-/*
- * Globally visible state (used by elog.c)
- */
-bool		am_syslogger = false;
-
 extern bool redirection_done;
 
 /*
@@ -177,8 +172,6 @@ SysLoggerMain(int argc, char *argv[])
 	syslogger_parseArgs(argc, argv);
 #endif							/* EXEC_BACKEND */
 
-	am_syslogger = true;
-
 	MyBackendType = B_LOGGER;
 	init_ps_display(NULL);
 
@@ -1073,7 +1066,7 @@ flush_pipe_input(char *logbuffer, int *bytes_in_logbuffer)
 /*
  * Write text to the currently open logfile
  *
- * This is exported so that elog.c can call it when am_syslogger is true.
+ * This is exported so that elog.c can call it when BackendType is B_LOGGER.
  * This allows the syslogger process to record elog messages of its own,
  * even though its stderr does not point at the syslog pipe.
  */
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index bb65eb41ca..3a6f7f9456 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2952,7 +2952,7 @@ write_csvlog(ErrorData *edata)
 	appendStringInfoChar(&buf, '\n');
 
 	/* If in the syslogger process, try to write messages direct to file */
-	if (am_syslogger)
+	if (MyBackendType == B_LOGGER)
 		write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_CSVLOG);
 	else
 		write_pipe_chunks(buf.data, buf.len, LOG_DESTINATION_CSVLOG);
@@ -3146,7 +3146,7 @@ send_message_to_server_log(ErrorData *edata)
 		 * catching stderr output, and we are not ourselves the syslogger.
 		 * Otherwise, just do a vanilla write to stderr.
 		 */
-		if (redirection_done && !am_syslogger)
+		if (redirection_done && MyBackendType != B_LOGGER)
 			write_pipe_chunks(buf.data, buf.len, LOG_DESTINATION_STDERR);
 #ifdef WIN32
 
@@ -3165,13 +3165,13 @@ send_message_to_server_log(ErrorData *edata)
 	}
 
 	/* If in the syslogger process, try to write messages direct to file */
-	if (am_syslogger)
+	if (MyBackendType == B_LOGGER)
 		write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_STDERR);
 
 	/* Write to CSV log if enabled */
 	if (Log_destination & LOG_DESTINATION_CSVLOG)
 	{
-		if (redirection_done || am_syslogger)
+		if (redirection_done || MyBackendType == B_LOGGER)
 		{
 			/*
 			 * send CSV data if it's safe to do so (syslogger doesn't need the
diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h
index 9b7a386dbd..f611bd1411 100644
--- a/src/include/postmaster/syslogger.h
+++ b/src/include/postmaster/syslogger.h
@@ -70,8 +70,6 @@ extern PGDLLIMPORT char *Log_filename;
 extern bool Log_truncate_on_rotation;
 extern int	Log_file_mode;
 
-extern bool am_syslogger;
-
 #ifndef WIN32
 extern int	syslogPipe[2];
 #else
-- 
2.25.0