1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +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

@ -259,23 +259,6 @@ check_timezone(char **newval, void **extra, GucSource source)
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
@ -374,7 +357,7 @@ check_timezone(char **newval, void **extra, GucSource source)
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);
@ -427,10 +410,6 @@ assign_timezone(const char *newval, void *extra)
{
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;
@ -490,20 +469,8 @@ check_log_timezone(char **newval, void **extra, GucSource source)
{
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);
@ -513,7 +480,7 @@ check_log_timezone(char **newval, void **extra, GucSource source)
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);
@ -538,10 +505,6 @@ check_log_timezone(char **newval, void **extra, GucSource source)
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);
}