diff options
author | Tom Lane | 2011-04-07 04:11:01 +0000 |
---|---|---|
committer | Tom Lane | 2011-04-07 04:12:02 +0000 |
commit | 2594cf0e8c04406ffff19b1651c5a406d376657c (patch) | |
tree | 8ced737d26b54f4499a8029d8cad0ab42fc83ba3 /src/timezone/pgtz.c | |
parent | 5d0e462366f4521e37744fdb42fed3c6819a3374 (diff) |
Revise the API for GUC variable assign hooks.
The previous functions of assign hooks are now split between check hooks
and assign hooks, where the former can fail but the latter shouldn't.
Aside from being conceptually clearer, this approach exposes the
"canonicalized" form of the variable value to guc.c without having to do
an actual assignment. And that lets us fix the problem recently noted by
Bernd Helmle that the auto-tune patch for wal_buffers resulted in bogus
log messages about "parameter "wal_buffers" cannot be changed without
restarting the server". There may be some speed advantage too, because
this design lets hook functions avoid re-parsing variable values when
restoring a previous state after a rollback (they can store a pre-parsed
representation of the value instead). This patch also resolves a
longstanding annoyance about custom error messages from variable assign
hooks: they should modify, not appear separately from, guc.c's own message
about "invalid parameter value".
Diffstat (limited to 'src/timezone/pgtz.c')
-rw-r--r-- | src/timezone/pgtz.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c index d09d4ad736f..382a4e04f50 100644 --- a/src/timezone/pgtz.c +++ b/src/timezone/pgtz.c @@ -1444,27 +1444,39 @@ pg_timezone_initialize(void) { pg_tz *def_tz = NULL; - /* Do we need to try to figure the session timezone? */ - if (pg_strcasecmp(GetConfigOption("timezone", false), "UNKNOWN") == 0) + /* + * Make sure that session_timezone and log_timezone are set. + * (session_timezone could still be NULL even if a timezone value was set + * in postgresql.conf, if that setting was interval-based rather than + * timezone-based.) + */ + if (!session_timezone) { - /* Select setting */ def_tz = select_default_timezone(); session_timezone = def_tz; - /* Tell GUC about the value. Will redundantly call pg_tzset() */ - SetConfigOption("timezone", pg_get_timezone_name(def_tz), - PGC_POSTMASTER, PGC_S_ARGV); } - - /* What about the log timezone? */ - if (pg_strcasecmp(GetConfigOption("log_timezone", false), "UNKNOWN") == 0) + if (!log_timezone) { - /* Select setting, but don't duplicate work */ + /* Don't duplicate work */ if (!def_tz) def_tz = select_default_timezone(); 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() */ + 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() */ - SetConfigOption("log_timezone", pg_get_timezone_name(def_tz), - PGC_POSTMASTER, PGC_S_ARGV); + SetConfigOption("log_timezone", pg_get_timezone_name(log_timezone), + PGC_POSTMASTER, PGC_S_ENV_VAR); } } |