From d81cd7032eb6c44e55e1528aac90cd9fb447be74 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon, 22 Mar 2004 15:34:22 +0000
Subject: [PATCH] Standardize output buffer size and display format for
 strftime; followup to complaint from Korean User's Group.

---
 contrib/pg_autovacuum/pg_autovacuum.c   |  7 +++----
 src/backend/utils/adt/nabstime.c        |  6 +++---
 src/backend/utils/error/elog.c          | 10 +++++-----
 src/bin/pg_controldata/pg_controldata.c |  6 +++---
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/contrib/pg_autovacuum/pg_autovacuum.c b/contrib/pg_autovacuum/pg_autovacuum.c
index ed59024b69d..89f0e0bf91d 100644
--- a/contrib/pg_autovacuum/pg_autovacuum.c
+++ b/contrib/pg_autovacuum/pg_autovacuum.c
@@ -5,9 +5,8 @@
  */
 
 #include "pg_autovacuum.h"
-#define TIMEBUFF 256
+
 FILE	   *LOGOUTPUT;
-char		timebuffer[TIMEBUFF];
 char		logbuffer[4096];
 
 void
@@ -15,11 +14,11 @@ log_entry(const char *logentry)
 {
 	time_t		curtime;
 	struct tm  *loctime;
+	char		timebuffer[128];
 
 	curtime = time(NULL);
 	loctime = localtime(&curtime);
-	strftime(timebuffer, TIMEBUFF, "%Y-%m-%d %r", loctime);		/* cbb - %F is not
-																 * always available */
+	strftime(timebuffer, sizeof(timebuffer), "%Y-%m-%d %H:%M:%S %Z", loctime);
 	fprintf(LOGOUTPUT, "[%s] %s\n", timebuffer, logentry);
 }
 
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index d88d1555f36..e9109938adb 100644
--- a/src/backend/utils/adt/nabstime.c
+++ b/src/backend/utils/adt/nabstime.c
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.118 2003/11/29 19:51:58 pgsql Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.119 2004/03/22 15:34:22 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1724,8 +1724,8 @@ timeofday(PG_FUNCTION_ARGS)
 {
 	struct timeval tp;
 	struct timezone tpz;
-	char		templ[100];
-	char		buf[100];
+	char		templ[128];
+	char		buf[128];
 	text	   *result;
 	int			len;
 
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 8569b6ce5cf..37c5b36e09d 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.130 2004/03/21 22:29:11 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.131 2004/03/22 15:34:22 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1187,9 +1187,9 @@ log_line_prefix(StringInfo buf)
 			case 't':
 				{
 					time_t stamp_time = time(NULL);
-					char strfbuf[32];
+					char strfbuf[128];
 
-					strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S",
+					strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S %Z",
 							 localtime(&stamp_time));
 					appendStringInfoString(buf, strfbuf);
 				}
@@ -1198,9 +1198,9 @@ log_line_prefix(StringInfo buf)
 				if (MyProcPort)
 				{
 					time_t stamp_time = MyProcPort->session_start.tv_sec;
-					char strfbuf[32];
+					char strfbuf[128];
 
-					strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S",
+					strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S %Z",
 							 localtime(&stamp_time));
 					appendStringInfoString(buf, strfbuf);
 				}
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index 9d7549cc686..4342d1e10af 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -6,7 +6,7 @@
  * copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
  * licence: BSD
  *
- * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.13 2004/02/11 22:55:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.14 2004/03/22 15:34:22 tgl Exp $
  */
 #include "postgres.h"
 
@@ -71,8 +71,8 @@ main(int argc, char *argv[])
 	char		ControlFilePath[MAXPGPATH];
 	char	   *DataDir;
 	crc64		crc;
-	char		pgctime_str[32];
-	char		ckpttime_str[32];
+	char		pgctime_str[128];
+	char		ckpttime_str[128];
 	char		sysident_str[32];
 	char	   *strftime_fmt = "%c";
 	char	   *progname;
-- 
GitLab