Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9e0fcc2

Browse files
committed
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.
1 parent f9df1b2 commit 9e0fcc2

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

src/backend/commands/variable.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.95 2004/05/21 05:07:57 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.96 2004/05/23 23:12:11 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -329,9 +329,13 @@ assign_timezone(const char *value, bool doit, GucSource source)
329329
* Otherwise assume it is a timezone name.
330330
*
331331
* We have to actually apply the change before we can have any
332-
* hope of checking it. So, save the old value in case we
333-
* have to back out. We have to copy since pg_get_current_timezone
332+
* hope of checking it. So, save the old value in case we have
333+
* to back out. We have to copy since pg_get_current_timezone
334334
* returns a pointer to its static state.
335+
*
336+
* This would all get a lot simpler if the TZ library had a better
337+
* API that would let us look up and test a timezone name without
338+
* making it the default.
335339
*/
336340
const char *cur_tz;
337341
char *save_tz;
@@ -361,8 +365,31 @@ assign_timezone(const char *value, bool doit, GucSource source)
361365
*/
362366
if (save_tz)
363367
pg_tzset(save_tz);
364-
else /* TZ library not initialized yet */
365-
select_default_timezone();
368+
else
369+
{
370+
/*
371+
* TZ library wasn't initialized yet. Annoyingly, we will
372+
* come here during startup because guc-file.l checks
373+
* the value with doit = false before actually applying.
374+
* The best approach seems to be as follows:
375+
*
376+
* 1. known && acceptable: leave the setting in place,
377+
* since we'll apply it soon anyway. This is mainly
378+
* so that any log messages printed during this interval
379+
* are timestamped with the user's requested timezone.
380+
*
381+
* 2. known && !acceptable: revert to GMT for lack of
382+
* any better idea. (select_default_timezone() may get
383+
* called later to undo this.)
384+
*
385+
* 3. !known: no need to do anything since TZ library
386+
* did not change its state.
387+
*
388+
* Again, this should all go away sometime soon.
389+
*/
390+
if (known && !acceptable)
391+
pg_tzset("GMT");
392+
}
366393
/* Complain if it was bad */
367394
if (!known)
368395
{

0 commit comments

Comments
 (0)