diff options
author | Cédric Villemain | 2011-05-13 20:55:39 +0000 |
---|---|---|
committer | Cédric Villemain | 2011-05-13 20:55:39 +0000 |
commit | e0c3b474d5436c7874aef36988f2646bdb890249 (patch) | |
tree | 49c41d2b8abbd9bae4096643d840859f3a02a08c /src/timezone | |
parent | 40cefa392974c73ec20deb3c15fb5111ed7fad17 (diff) | |
parent | 9bb6d9795253bb521f81c626fea49a704a369ca9 (diff) |
Merge branch 'master' into analyze_cacheanalyze_cache
Diffstat (limited to 'src/timezone')
-rw-r--r-- | src/timezone/pgtz.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c index cb66f6380b..622cf94c5a 100644 --- a/src/timezone/pgtz.c +++ b/src/timezone/pgtz.c @@ -1438,6 +1438,10 @@ pg_timezone_pre_initialize(void) * This is called after initial loading of postgresql.conf. If no TimeZone * setting was found therein, we try to derive one from the environment. * Likewise for log_timezone. + * + * Note: this is also called from ProcessConfigFile, to re-establish valid + * GUC settings if the GUCs have been reset to default following their + * removal from postgresql.conf. */ void pg_timezone_initialize(void) @@ -1463,21 +1467,34 @@ pg_timezone_initialize(void) log_timezone = def_tz; } - /* Now, set the timezone GUC if it's not already set */ - if (GetConfigOption("timezone", false) == NULL) - { - /* Tell GUC about the value. Will redundantly call pg_tzset() */ + /* + * Now, set the timezone and log_timezone GUCs if they're still default. + * (This will redundantly call pg_tzset().) + * + * We choose to label these values PGC_S_ENV_VAR, rather than + * PGC_S_DYNAMIC_DEFAULT which would be functionally equivalent, because + * they came either from getenv("TZ") or from libc behavior that's + * determined by process environment of some kind. + * + * Note: in the case where a setting has just been removed from + * postgresql.conf, this code will not do what you might expect, namely + * call select_default_timezone() and install that value as the setting. + * Rather, the previously active setting --- typically the one from + * postgresql.conf --- will be reinstalled, relabeled as PGC_S_ENV_VAR. + * If we did try to install the "correct" default value, the effect would + * be that each postmaster child would independently run an extremely + * expensive search of the timezone database, bringing the database to its + * knees for possibly multiple seconds. This is so unpleasant, and could + * so easily be triggered quite unintentionally, that it seems better to + * violate the principle of least astonishment. + */ + if (GetConfigOptionResetString("timezone") == NULL) SetConfigOption("timezone", pg_get_timezone_name(session_timezone), PGC_POSTMASTER, PGC_S_ENV_VAR); - } - /* Likewise for log timezone */ - if (GetConfigOption("log_timezone", false) == NULL) - { - /* Tell GUC about the value. Will redundantly call pg_tzset() */ + if (GetConfigOptionResetString("log_timezone") == NULL) SetConfigOption("log_timezone", pg_get_timezone_name(log_timezone), PGC_POSTMASTER, PGC_S_ENV_VAR); - } } |