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>
<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>
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.
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>
<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>
{
if (!SelectConfigFiles(userDoption, progname))
proc_exit(1);
- /* If timezone is not set, determine what the OS uses */
- pg_timezone_initialize();
- /* If timezone_abbreviations is not set, select default */
- pg_timezone_abbrev_initialize();
}
/* Validate we have been given a reasonable-looking DataDir */
char *endptr;
double hours;
- if (*newval == NULL)
- {
- /*
- * The boot_val given for TimeZone in guc.c is NULL. When we see this
- * we just do nothing. If this isn't overridden from the config file
- * then pg_timezone_initialize() will eventually select a default
- * value from the environment. This hack has two purposes: to avoid
- * wasting cycles loading values that might soon be overridden from
- * the config file, and to avoid trying to read the timezone files
- * during InitializeGUCOptions(). The latter doesn't work in an
- * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet
- * and so we can't locate PGSHAREDIR.
- */
- Assert(source == PGC_S_DEFAULT);
- return true;
- }
-
/*
* Initialize the "extra" struct that will be passed to assign_timezone.
* We don't want to change any of the three global variables except as
return false;
}
- if (!tz_acceptable(new_tz))
+ if (!pg_tz_acceptable(new_tz))
{
GUC_check_errmsg("time zone \"%s\" appears to use leap seconds",
*newval);
{
timezone_extra *myextra = (timezone_extra *) extra;
- /* Do nothing for the boot_val default of NULL */
- if (!myextra)
- return;
-
session_timezone = myextra->session_timezone;
CTimeZone = myextra->CTimeZone;
HasCTZSet = myextra->HasCTZSet;
{
pg_tz *new_tz;
- if (*newval == NULL)
- {
- /*
- * The boot_val given for log_timezone in guc.c is NULL. When we see
- * this we just do nothing. If this isn't overridden from the config
- * file then pg_timezone_initialize() will eventually select a default
- * value from the environment.
- */
- Assert(source == PGC_S_DEFAULT);
- return true;
- }
-
/*
- * Otherwise assume it is a timezone name, and try to load it.
+ * Assume it is a timezone name, and try to load it.
*/
new_tz = pg_tzset(*newval);
return false;
}
- if (!tz_acceptable(new_tz))
+ if (!pg_tz_acceptable(new_tz))
{
GUC_check_errmsg("time zone \"%s\" appears to use leap seconds",
*newval);
void
assign_log_timezone(const char *newval, void *extra)
{
- /* Do nothing for the boot_val default of NULL */
- if (!extra)
- return;
-
log_timezone = *((pg_tz **) extra);
}
*/
CreateDataDirLockFile(true);
- /*
- * If timezone is not set, determine what the OS uses. (In theory this
- * should be done during GUC initialization, but because it can take as
- * much as several seconds, we delay it until after we've created the
- * postmaster.pid file. This prevents problems with boot scripts that
- * expect the pidfile to appear quickly. Also, we avoid problems with
- * trying to locate the timezone files too early in initialization.)
- */
- pg_timezone_initialize();
-
- /*
- * Likewise, init timezone_abbreviations if not already set.
- */
- pg_timezone_abbrev_initialize();
-
/*
* Initialize SSL library, if specified.
*/
{
if (!SelectConfigFiles(userDoption, progname))
proc_exit(1);
- /* If timezone is not set, determine what the OS uses */
- pg_timezone_initialize();
- /* If timezone_abbreviations is not set, select default */
- pg_timezone_abbrev_initialize();
}
/*