From bdd6b62245fe7b5f25c4fec509b80ec930b6deff Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 4 Aug 2007 01:26:54 +0000 Subject: 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. --- doc/src/sgml/config.sgml | 45 +++++++++++++++++++++++++++++++++------------ doc/src/sgml/datatype.sgml | 7 +++++-- 2 files changed, 38 insertions(+), 14 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index adac32931df..6b4db09605b 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1,4 +1,4 @@ - + Server Configuration @@ -2311,13 +2311,15 @@ SELECT * FROM parent WHERE key = 2400; When redirect_stderr is enabled, this parameter sets the file names of the created log files. The value is treated as a strftime pattern, - so %-escapes - can be used to specify time-varying file names. + so %-escapes can be used to specify time-varying + file names. (Note that if there are + any time-zone-dependent %-escapes, the computation + is done in the zone specified by .) If no %-escapes are present, - PostgreSQL will - append the epoch of the new log file's open time. For example, - if log_filename were server_log, then the - chosen file name would be server_log.1093827753 + PostgreSQL will append the epoch of the new + log file's creation time. For example, if + log_filename were server_log, + then the chosen file name would be server_log.1093827753 for a log starting at Sun Aug 29 19:02:33 2004 MST. This parameter can only be set in the postgresql.conf file or on the server command line. @@ -2884,7 +2886,7 @@ SELECT * FROM parent WHERE key = 2400; %t - Time stamp without milliseconds (no timezone either on Windows) + Time stamp without milliseconds no @@ -2909,7 +2911,7 @@ SELECT * FROM parent WHERE key = 2400; %s - Session start time stamp + Process start time stamp no @@ -2935,7 +2937,7 @@ SELECT * FROM parent WHERE key = 2400; The %c escape prints a quasi-unique session identifier, consisting of two 4-byte hexadecimal numbers (without leading zeros) - separated by a dot. The numbers are the session start time and the + separated by a dot. The numbers are the process start time and the process ID, so %c can also be used as a space saving way of printing those items. @@ -3036,6 +3038,25 @@ SELECT * FROM parent WHERE key = 2400; + + log_timezone (string) + + log_timezone configuration parameter + + + + Sets the time zone used for timestamps written in the log. + Unlike , this value is cluster-wide, + so that all sessions will report timestamps consistently. + The default is unknown, which means to use whatever + the system environment specifies as the time zone. See for more information. + This parameter can only be set in the postgresql.conf + file or on the server command line. + + + + @@ -3822,9 +3843,9 @@ SET XML OPTION { DOCUMENT | CONTENT }; Sets the time zone for displaying and interpreting time stamps. - The default is 'unknown', which means to use whatever + The default is unknown, which means to use whatever the system environment specifies as the time zone. See for more + linkend="datatype-timezones"> for more information. diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 64b53d1e83d..99cc22958f2 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,4 +1,4 @@ - + Data Types @@ -2234,7 +2234,8 @@ January 8 04:05:06 1999 PST savings transition-date rules as well. The recognized abbreviations are listed in the pg_timezone_abbrevs view (see ). You cannot set the - configuration parameter using a time + configuration parameters or + using a time zone abbreviation, but you can use abbreviations in date/time input values and with the AT TIME ZONE operator. @@ -2316,6 +2317,8 @@ January 8 04:05:06 1999 PST behavior of the C library function localtime(). The default time zone is selected as the closest match among PostgreSQL's known time zones. + (These rules are also used to choose the default value of + , if it is not specified.) -- cgit v1.2.3