summaryrefslogtreecommitdiff
path: root/src/backend/commands/variable.c
diff options
context:
space:
mode:
authorTom Lane2004-05-23 23:12:11 +0000
committerTom Lane2004-05-23 23:12:11 +0000
commit72b648049583f1d28f154dcbb28ba2109ead49bd (patch)
treeea06de8fa43f5ec7132553073e9aec39537d6bdf /src/backend/commands/variable.c
parent46ae14fb34deaa858129e83b67ac7063d8741fd2 (diff)
Avoid calling select_default_timezone() when backing out an unwanted TZ
setting. This is a temporary kluge to keep Alvaro happy; eventually we should fix the TZ library API to make the problem really go away.
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r--src/backend/commands/variable.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 80082ad456..ad25a2b06e 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -329,9 +329,13 @@ assign_timezone(const char *value, bool doit, GucSource source)
* Otherwise assume it is a timezone name.
*
* We have to actually apply the change before we can have any
- * hope of checking it. So, save the old value in case we
- * have to back out. We have to copy since pg_get_current_timezone
+ * hope of checking it. So, save the old value in case we have
+ * to back out. We have to copy since pg_get_current_timezone
* returns a pointer to its static state.
+ *
+ * This would all get a lot simpler if the TZ library had a better
+ * API that would let us look up and test a timezone name without
+ * making it the default.
*/
const char *cur_tz;
char *save_tz;
@@ -361,8 +365,31 @@ assign_timezone(const char *value, bool doit, GucSource source)
*/
if (save_tz)
pg_tzset(save_tz);
- else /* TZ library not initialized yet */
- select_default_timezone();
+ else
+ {
+ /*
+ * TZ library wasn't initialized yet. Annoyingly, we will
+ * come here during startup because guc-file.l checks
+ * the value with doit = false before actually applying.
+ * The best approach seems to be as follows:
+ *
+ * 1. known && acceptable: leave the setting in place,
+ * since we'll apply it soon anyway. This is mainly
+ * so that any log messages printed during this interval
+ * are timestamped with the user's requested timezone.
+ *
+ * 2. known && !acceptable: revert to GMT for lack of
+ * any better idea. (select_default_timezone() may get
+ * called later to undo this.)
+ *
+ * 3. !known: no need to do anything since TZ library
+ * did not change its state.
+ *
+ * Again, this should all go away sometime soon.
+ */
+ if (known && !acceptable)
+ pg_tzset("GMT");
+ }
/* Complain if it was bad */
if (!known)
{