diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-04 01:26:54 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-04 01:26:54 +0000 |
commit | bdd6b62245fe7b5f25c4fec509b80ec930b6deff (patch) | |
tree | 91af2ffde788fdd2855b0dfb1c18e2bbb5aa50a1 /src/backend/postmaster/syslogger.c | |
parent | 73852bd520c219051431a74ee511c4f29dd4baf3 (diff) | |
download | postgresql-bdd6b62245fe7b5f25c4fec509b80ec930b6deff.tar.gz postgresql-bdd6b62245fe7b5f25c4fec509b80ec930b6deff.zip |
Switch over to using the src/timezone functions for formatting timestamps
displayed in the postmaster log. This avoids Windows-specific problems with
localized time zone names that are in the wrong encoding, and generally seems
like a good idea to forestall other potential platform-dependent issues.
To preserve the existing behavior that all backends will log in the same time
zone, create a new GUC variable log_timezone that can only be changed on a
system-wide basis, and reference log-related calculations to that zone instead
of the TimeZone variable.
This fixes the issue reported by Hiroshi Saito that timestamps printed by
xlog.c startup could be improperly localized on Windows. We still need a
simpler patch for that problem in the back branches, however.
Diffstat (limited to 'src/backend/postmaster/syslogger.c')
-rw-r--r-- | src/backend/postmaster/syslogger.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index 00480600690..cd3793497bd 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -18,7 +18,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.35 2007/08/02 23:39:44 adunstan Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.36 2007/08/04 01:26:53 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1038,7 +1038,6 @@ logfile_getname(pg_time_t timestamp) { char *filename; int len; - struct pg_tm *tm; filename = palloc(MAXPGPATH); @@ -1049,8 +1048,8 @@ logfile_getname(pg_time_t timestamp) if (strchr(Log_filename, '%')) { /* treat it as a strftime pattern */ - tm = pg_localtime(×tamp, global_timezone); - pg_strftime(filename + len, MAXPGPATH - len, Log_filename, tm); + pg_strftime(filename + len, MAXPGPATH - len, Log_filename, + pg_localtime(×tamp, log_timezone)); } else { @@ -1079,12 +1078,12 @@ set_next_rotation_time(void) /* * The requirements here are to choose the next time > now that is a * "multiple" of the log rotation interval. "Multiple" can be interpreted - * fairly loosely. In this version we align to local time rather than + * fairly loosely. In this version we align to log_timezone rather than * GMT. */ rotinterval = Log_RotationAge * SECS_PER_MINUTE; /* convert to seconds */ - now = time(NULL); - tm = pg_localtime(&now, global_timezone); + now = (pg_time_t) time(NULL); + tm = pg_localtime(&now, log_timezone); now += tm->tm_gmtoff; now -= now % rotinterval; now += rotinterval; |