From 6b7eebc05e3bfd86757f5aa1f05bca463e92d7db Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Wed, 9 Jul 2008 15:56:49 +0000
Subject: [PATCH] Increase PG_SYSLOG_LIMIT (the max line length sent to
 syslog()) from 128 to 1024 to improve performance when sending large elog
 messages.  Also add a comment about why we use that number.

Since this represents an externally visible behavior change, and might
possibly result in portability issues, it seems best not to back-patch it.
---
 src/backend/utils/error/elog.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 0d4fd56a224..46b7853e50a 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -42,7 +42,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.204 2008/07/08 22:17:41 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.205 2008/07/09 15:56:49 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -85,6 +85,17 @@ char	   *Log_line_prefix = NULL;		/* format for extra log line info */
 int			Log_destination = LOG_DESTINATION_STDERR;
 
 #ifdef HAVE_SYSLOG
+
+/*
+ * Max string length to send to syslog().  Note that this doesn't count the
+ * sequence-number prefix we add, and of course it doesn't count the prefix
+ * added by syslog itself.  On many implementations it seems that the hard
+ * limit is approximately 2K bytes including both those prefixes.
+ */
+#ifndef PG_SYSLOG_LIMIT
+#define PG_SYSLOG_LIMIT 1024
+#endif
+
 static bool openlog_done = false;
 static char *syslog_ident = NULL;
 static int	syslog_facility = LOG_LOCAL0;
@@ -1257,7 +1268,6 @@ DebugFileOpen(void)
 }
 
 
-
 #ifdef HAVE_SYSLOG
 
 /*
@@ -1293,10 +1303,6 @@ set_syslog_parameters(const char *ident, int facility)
 }
 
 
-#ifndef PG_SYSLOG_LIMIT
-#define PG_SYSLOG_LIMIT 128
-#endif
-
 /*
  * Write a message line to syslog
  */
-- 
GitLab