diff options
Diffstat (limited to 'src/backend/postmaster/syslogger.c')
-rw-r--r-- | src/backend/postmaster/syslogger.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index cad43bdef23..bca38835726 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -38,6 +38,7 @@ #include "nodes/pg_list.h" #include "pgstat.h" #include "pgtime.h" +#include "port/pg_bitutils.h" #include "postmaster/fork_process.h" #include "postmaster/interrupt.h" #include "postmaster/postmaster.h" @@ -885,14 +886,15 @@ process_pipe_input(char *logbuffer, int *bytes_in_logbuffer) { PipeProtoHeader p; int chunklen; + bits8 dest_flags; /* Do we have a valid header? */ memcpy(&p, cursor, offsetof(PipeProtoHeader, data)); + dest_flags = p.flags & (PIPE_PROTO_DEST_STDERR | PIPE_PROTO_DEST_CSVLOG); if (p.nuls[0] == '\0' && p.nuls[1] == '\0' && p.len > 0 && p.len <= PIPE_MAX_PAYLOAD && p.pid != 0 && - (p.is_last == 't' || p.is_last == 'f' || - p.is_last == 'T' || p.is_last == 'F')) + pg_popcount((char *) &dest_flags, 1) == 1) { List *buffer_list; ListCell *cell; @@ -906,8 +908,15 @@ process_pipe_input(char *logbuffer, int *bytes_in_logbuffer) if (count < chunklen) break; - dest = (p.is_last == 'T' || p.is_last == 'F') ? - LOG_DESTINATION_CSVLOG : LOG_DESTINATION_STDERR; + if ((p.flags & PIPE_PROTO_DEST_STDERR) != 0) + dest = LOG_DESTINATION_STDERR; + else if ((p.flags & PIPE_PROTO_DEST_CSVLOG) != 0) + dest = LOG_DESTINATION_CSVLOG; + else + { + /* this should never happen as of the header validation */ + Assert(false); + } /* Locate any existing buffer for this source pid */ buffer_list = buffer_lists[p.pid % NBUFFER_LISTS]; @@ -924,7 +933,7 @@ process_pipe_input(char *logbuffer, int *bytes_in_logbuffer) free_slot = buf; } - if (p.is_last == 'f' || p.is_last == 'F') + if ((p.flags & PIPE_PROTO_IS_LAST) == 0) { /* * Save a complete non-final chunk in a per-pid buffer |