|
9 | 9 | *
|
10 | 10 | *
|
11 | 11 | * 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 $ |
13 | 13 | *
|
14 | 14 | *-------------------------------------------------------------------------
|
15 | 15 | */
|
@@ -329,9 +329,13 @@ assign_timezone(const char *value, bool doit, GucSource source)
|
329 | 329 | * Otherwise assume it is a timezone name.
|
330 | 330 | *
|
331 | 331 | * 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 |
334 | 334 | * 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. |
335 | 339 | */
|
336 | 340 | const char *cur_tz;
|
337 | 341 | char *save_tz;
|
@@ -361,8 +365,31 @@ assign_timezone(const char *value, bool doit, GucSource source)
|
361 | 365 | */
|
362 | 366 | if (save_tz)
|
363 | 367 | 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 | + } |
366 | 393 | /* Complain if it was bad */
|
367 | 394 | if (!known)
|
368 | 395 | {
|
|
0 commit comments