1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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.
This commit is contained in:
Tom Lane
2011-09-09 17:59:11 -04:00
parent a7801b62f2
commit ca4af308c3
19 changed files with 1373 additions and 1368 deletions

View File

@ -3915,9 +3915,10 @@ FROM pg_stat_activity;
Sets the time zone used for timestamps written in the server log.
Unlike <xref linkend="guc-timezone">, this value is cluster-wide,
so that all sessions will report timestamps consistently.
If not explicitly set, the server initializes this variable to the
time zone specified by its system environment. See <xref
linkend="datatype-timezones"> for more information.
The built-in default is <literal>GMT</>, but that is typically
overridden in <filename>postgresql.conf</>; <application>initdb</>
will install a setting there corresponding to its system environment.
See <xref linkend="datatype-timezones"> for more information.
This parameter can only be set in the <filename>postgresql.conf</>
file or on the server command line.
</para>
@ -4963,9 +4964,10 @@ SET XML OPTION { DOCUMENT | CONTENT };
<listitem>
<para>
Sets the time zone for displaying and interpreting time stamps.
If not explicitly set, the server initializes this variable to the
time zone specified by its system environment. See <xref
linkend="datatype-timezones"> for more information.
The built-in default is <literal>GMT</>, but that is typically
overridden in <filename>postgresql.conf</>; <application>initdb</>
will install a setting there corresponding to its system environment.
See <xref linkend="datatype-timezones"> for more information.
</para>
</listitem>
</varlistentry>

View File

@ -2286,7 +2286,7 @@ January 8 04:05:06 1999 PST
but continue to be prone to arbitrary changes, particularly with
respect to daylight-savings rules.
<productname>PostgreSQL</productname> uses the widely-used
<literal>zoneinfo</> time zone database for information about
<literal>zoneinfo</> (Olson) time zone database for information about
historical time zone rules. For times in the future, the assumption
is that the latest known rules for a given time zone will
continue to be observed indefinitely far into the future.
@ -2432,26 +2432,9 @@ January 8 04:05:06 1999 PST
The <xref linkend="guc-timezone"> configuration parameter can
be set in the file <filename>postgresql.conf</>, or in any of the
other standard ways described in <xref linkend="runtime-config">.
There are also several special ways to set it:
There are also some special ways to set it:
<itemizedlist>
<listitem>
<para>
If <varname>timezone</> is not specified in
<filename>postgresql.conf</> or as a server command-line option,
the server attempts to use the value of the <envar>TZ</envar>
environment variable as the default time zone. If <envar>TZ</envar>
is not defined or is not any of the time zone names known to
<productname>PostgreSQL</productname>, the server attempts to
determine the operating system's default time zone by checking the
behavior of the C library function <literal>localtime()</>. The
default time zone is selected as the closest match among
<productname>PostgreSQL</productname>'s known time zones.
(These rules are also used to choose the default value of
<xref linkend="guc-log-timezone">, if not specified.)
</para>
</listitem>
<listitem>
<para>
The <acronym>SQL</acronym> command <command>SET TIME ZONE</command>

View File

@ -239,9 +239,7 @@ SELECT setseed(<replaceable>value</replaceable>);
<listitem>
<para>
Set the time zone to your local time zone (that is, the
server's default value of <varname>timezone</>; if this
has not been explicitly set anywhere, it will be the zone that
the server's operating system defaults to).
server's default value of <varname>timezone</>).
</para>
</listitem>
</varlistentry>