Skip to content

Commit d81cd70

Browse files
committed
Standardize output buffer size and display format for strftime;
followup to complaint from Korean User's Group.
1 parent 682a6bd commit d81cd70

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

contrib/pg_autovacuum/pg_autovacuum.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55
*/
66

77
#include "pg_autovacuum.h"
8-
#define TIMEBUFF 256
8+
99
FILE *LOGOUTPUT;
10-
char timebuffer[TIMEBUFF];
1110
char logbuffer[4096];
1211

1312
void
1413
log_entry(const char *logentry)
1514
{
1615
time_t curtime;
1716
struct tm *loctime;
17+
char timebuffer[128];
1818

1919
curtime = time(NULL);
2020
loctime = localtime(&curtime);
21-
strftime(timebuffer, TIMEBUFF, "%Y-%m-%d %r", loctime); /* cbb - %F is not
22-
* always available */
21+
strftime(timebuffer, sizeof(timebuffer), "%Y-%m-%d %H:%M:%S %Z", loctime);
2322
fprintf(LOGOUTPUT, "[%s] %s\n", timebuffer, logentry);
2423
}
2524

src/backend/utils/adt/nabstime.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.118 2003/11/29 19:51:58 pgsql Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.119 2004/03/22 15:34:22 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1724,8 +1724,8 @@ timeofday(PG_FUNCTION_ARGS)
17241724
{
17251725
struct timeval tp;
17261726
struct timezone tpz;
1727-
char templ[100];
1728-
char buf[100];
1727+
char templ[128];
1728+
char buf[128];
17291729
text *result;
17301730
int len;
17311731

src/backend/utils/error/elog.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.130 2004/03/21 22:29:11 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.131 2004/03/22 15:34:22 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -1187,9 +1187,9 @@ log_line_prefix(StringInfo buf)
11871187
case 't':
11881188
{
11891189
time_t stamp_time = time(NULL);
1190-
char strfbuf[32];
1190+
char strfbuf[128];
11911191

1192-
strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S",
1192+
strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S %Z",
11931193
localtime(&stamp_time));
11941194
appendStringInfoString(buf, strfbuf);
11951195
}
@@ -1198,9 +1198,9 @@ log_line_prefix(StringInfo buf)
11981198
if (MyProcPort)
11991199
{
12001200
time_t stamp_time = MyProcPort->session_start.tv_sec;
1201-
char strfbuf[32];
1201+
char strfbuf[128];
12021202

1203-
strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S",
1203+
strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S %Z",
12041204
localtime(&stamp_time));
12051205
appendStringInfoString(buf, strfbuf);
12061206
}

src/bin/pg_controldata/pg_controldata.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.13 2004/02/11 22:55:25 tgl Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.14 2004/03/22 15:34:22 tgl Exp $
1010
*/
1111
#include "postgres.h"
1212

@@ -71,8 +71,8 @@ main(int argc, char *argv[])
7171
char ControlFilePath[MAXPGPATH];
7272
char *DataDir;
7373
crc64 crc;
74-
char pgctime_str[32];
75-
char ckpttime_str[32];
74+
char pgctime_str[128];
75+
char ckpttime_str[128];
7676
char sysident_str[32];
7777
char *strftime_fmt = "%c";
7878
char *progname;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy