diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-09-09 17:59:11 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-09-09 17:59:11 -0400 |
commit | ca4af308c32d03db5fbacb54d6e583ceb904f268 (patch) | |
tree | 352fb06319a1c8e3efd78acaca9cc8b8ff0e7eda /src/backend/utils/error/elog.c | |
parent | a7801b62f21bd051444bd1119cd3745ecc8e14ec (diff) | |
download | postgresql-ca4af308c32d03db5fbacb54d6e583ceb904f268.tar.gz postgresql-ca4af308c32d03db5fbacb54d6e583ceb904f268.zip |
Simplify handling of the timezone GUC by making initdb choose the default.
We were doing some amazingly complicated things in order to avoid running
the very expensive identify_system_timezone() procedure during GUC
initialization. But there is an obvious fix for that, which is to do it
once during initdb and have initdb install the system-specific default into
postgresql.conf, as it already does for most other GUC variables that need
system-environment-dependent defaults. This means that the timezone (and
log_timezone) settings no longer have any magic behavior in the server.
Per discussion.
Diffstat (limited to 'src/backend/utils/error/elog.c')
-rw-r--r-- | src/backend/utils/error/elog.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 6e8e5aef4e0..f0b3b1feb06 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -1805,24 +1805,20 @@ setup_formatted_log_time(void) { struct timeval tv; pg_time_t stamp_time; - pg_tz *tz; char msbuf[8]; gettimeofday(&tv, NULL); stamp_time = (pg_time_t) tv.tv_sec; /* - * Normally we print log timestamps in log_timezone, but during startup we - * could get here before that's set. If so, fall back to gmt_timezone - * (which guc.c ensures is set up before Log_line_prefix can become - * nonempty). + * Note: we expect that guc.c will ensure that log_timezone is set up + * (at least with a minimal GMT value) before Log_line_prefix can become + * nonempty or CSV mode can be selected. */ - tz = log_timezone ? log_timezone : gmt_timezone; - pg_strftime(formatted_log_time, FORMATTED_TS_LEN, /* leave room for milliseconds... */ "%Y-%m-%d %H:%M:%S %Z", - pg_localtime(&stamp_time, tz)); + pg_localtime(&stamp_time, log_timezone)); /* 'paste' milliseconds into place... */ sprintf(msbuf, ".%03d", (int) (tv.tv_usec / 1000)); @@ -1836,19 +1832,15 @@ static void setup_formatted_start_time(void) { pg_time_t stamp_time = (pg_time_t) MyStartTime; - pg_tz *tz; /* - * Normally we print log timestamps in log_timezone, but during startup we - * could get here before that's set. If so, fall back to gmt_timezone - * (which guc.c ensures is set up before Log_line_prefix can become - * nonempty). + * Note: we expect that guc.c will ensure that log_timezone is set up + * (at least with a minimal GMT value) before Log_line_prefix can become + * nonempty or CSV mode can be selected. */ - tz = log_timezone ? log_timezone : gmt_timezone; - pg_strftime(formatted_start_time, FORMATTED_TS_LEN, "%Y-%m-%d %H:%M:%S %Z", - pg_localtime(&stamp_time, tz)); + pg_localtime(&stamp_time, log_timezone)); } /* @@ -1947,14 +1939,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata) case 't': { pg_time_t stamp_time = (pg_time_t) time(NULL); - pg_tz *tz; char strfbuf[128]; - tz = log_timezone ? log_timezone : gmt_timezone; - pg_strftime(strfbuf, sizeof(strfbuf), "%Y-%m-%d %H:%M:%S %Z", - pg_localtime(&stamp_time, tz)); + pg_localtime(&stamp_time, log_timezone)); appendStringInfoString(buf, strfbuf); } break; |