Skip to content
Snippets Groups Projects
Commit 9e0fcc2a authored by Tom Lane's avatar Tom Lane
Browse files

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.
parent f9df1b28
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.95 2004/05/21 05:07:57 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.96 2004/05/23 23:12:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -329,9 +329,13 @@ assign_timezone(const char *value, bool doit, GucSource source) ...@@ -329,9 +329,13 @@ assign_timezone(const char *value, bool doit, GucSource source)
* Otherwise assume it is a timezone name. * Otherwise assume it is a timezone name.
* *
* We have to actually apply the change before we can have any * We have to actually apply the change before we can have any
* hope of checking it. So, save the old value in case we * hope of checking it. So, save the old value in case we have
* have to back out. We have to copy since pg_get_current_timezone * to back out. We have to copy since pg_get_current_timezone
* returns a pointer to its static state. * 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; const char *cur_tz;
char *save_tz; char *save_tz;
...@@ -361,8 +365,31 @@ assign_timezone(const char *value, bool doit, GucSource source) ...@@ -361,8 +365,31 @@ assign_timezone(const char *value, bool doit, GucSource source)
*/ */
if (save_tz) if (save_tz)
pg_tzset(save_tz); pg_tzset(save_tz);
else /* TZ library not initialized yet */ else
select_default_timezone(); {
/*
* 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 */ /* Complain if it was bad */
if (!known) if (!known)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment