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

Commit 033a477

Browse files
committed
Adjust initialization sequence for timezone_abbreviations so that
it's handled just about like timezone; in particular, don't try to read anything during InitializeGUCOptions. Should solve current startup failure on Windows, and avoid wasted cycles if a nondefault setting is specified in postgresql.conf too. Possibly we need to think about a more general solution for handling 'expensive to set' GUC options.
1 parent 46d9c2e commit 033a477

File tree

5 files changed

+57
-11
lines changed

5 files changed

+57
-11
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.220 2006/07/14 14:52:17 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.221 2006/07/29 03:02:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -358,6 +358,8 @@ BootstrapMain(int argc, char *argv[])
358358
proc_exit(1);
359359
/* If timezone is not set, determine what the OS uses */
360360
pg_timezone_initialize();
361+
/* If timezone_abbreviations is not set, select default */
362+
pg_timezone_abbrev_initialize();
361363
}
362364

363365
/* Validate we have been given a reasonable-looking DataDir */

src/backend/postmaster/postmaster.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.496 2006/07/25 01:23:34 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.497 2006/07/29 03:02:55 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -691,10 +691,16 @@ PostmasterMain(int argc, char *argv[])
691691
* should be done during GUC initialization, but because it can take as
692692
* much as several seconds, we delay it until after we've created the
693693
* postmaster.pid file. This prevents problems with boot scripts that
694-
* expect the pidfile to appear quickly.)
694+
* expect the pidfile to appear quickly. Also, we avoid problems with
695+
* trying to locate the timezone files too early in initialization.)
695696
*/
696697
pg_timezone_initialize();
697698

699+
/*
700+
* Likewise, init timezone_abbreviations if not already set.
701+
*/
702+
pg_timezone_abbrev_initialize();
703+
698704
/*
699705
* Initialize SSL library, if specified.
700706
*/

src/backend/tcop/postgres.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.492 2006/07/14 14:52:23 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.493 2006/07/29 03:02:56 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -2758,6 +2758,8 @@ PostgresMain(int argc, char *argv[], const char *username)
27582758
proc_exit(1);
27592759
/* If timezone is not set, determine what the OS uses */
27602760
pg_timezone_initialize();
2761+
/* If timezone_abbreviations is not set, select default */
2762+
pg_timezone_abbrev_initialize();
27612763
}
27622764

27632765
if (PostAuthDelay)

src/backend/utils/misc/guc.c

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.332 2006/07/27 08:30:41 petere Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.333 2006/07/29 03:02:56 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -221,10 +221,10 @@ static char *regex_flavor_string;
221221
static char *server_encoding_string;
222222
static char *server_version_string;
223223
static char *timezone_string;
224+
static char *timezone_abbreviations_string;
224225
static char *XactIsoLevel_string;
225226
static char *data_directory;
226227
static char *custom_variable_classes;
227-
static char *timezone_abbreviations;
228228
static int max_function_args;
229229
static int max_index_keys;
230230
static int max_identifier_length;
@@ -2101,8 +2101,8 @@ static struct config_string ConfigureNamesString[] =
21012101
gettext_noop("Selects a file of timezone abbreviations"),
21022102
NULL,
21032103
},
2104-
&timezone_abbreviations,
2105-
"Default", assign_timezone_abbreviations, NULL
2104+
&timezone_abbreviations_string,
2105+
"UNKNOWN", assign_timezone_abbreviations, NULL
21062106
},
21072107

21082108
{
@@ -6288,9 +6288,27 @@ assign_backslash_quote(const char *newval, bool doit, GucSource source)
62886288
static const char *
62896289
assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
62906290
{
6291+
/*
6292+
* The powerup value shown above for timezone_abbreviations is "UNKNOWN".
6293+
* When we see this we just do nothing. If this value isn't overridden
6294+
* from the config file then pg_timezone_abbrev_initialize() will
6295+
* eventually replace it with "Default". This hack has two purposes:
6296+
* to avoid wasting cycles loading values that might soon be overridden
6297+
* from the config file, and to avoid trying to read the timezone abbrev
6298+
* files during InitializeGUCOptions(). The latter doesn't work in an
6299+
* EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and
6300+
* so we can't locate PGSHAREDIR. (Essentially the same hack is used
6301+
* to delay initializing TimeZone ... if we have any more, we should
6302+
* try to clean up and centralize this mechanism ...)
6303+
*/
6304+
if (strcmp(newval, "UNKNOWN") == 0)
6305+
{
6306+
return newval;
6307+
}
6308+
62916309
/* Loading abbrev file is expensive, so only do it when value changes */
6292-
if (timezone_abbreviations == NULL ||
6293-
strcmp(timezone_abbreviations, newval) != 0)
6310+
if (timezone_abbreviations_string == NULL ||
6311+
strcmp(timezone_abbreviations_string, newval) != 0)
62946312
{
62956313
int elevel;
62966314

@@ -6309,6 +6327,22 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
63096327
return newval;
63106328
}
63116329

6330+
/*
6331+
* pg_timezone_abbrev_initialize --- set default value if not done already
6332+
*
6333+
* This is called after initial loading of postgresql.conf. If no
6334+
* timezone_abbreviations setting was found therein, select default.
6335+
*/
6336+
void
6337+
pg_timezone_abbrev_initialize(void)
6338+
{
6339+
if (strcmp(timezone_abbreviations_string, "UNKNOWN") == 0)
6340+
{
6341+
SetConfigOption("timezone_abbreviations", "Default",
6342+
PGC_POSTMASTER, PGC_S_ARGV);
6343+
}
6344+
}
6345+
63126346
static bool
63136347
assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
63146348
{

src/include/utils/guc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
88
* Written by Peter Eisentraut <peter_e@gmx.net>.
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.70 2006/07/25 03:51:22 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.71 2006/07/29 03:02:56 tgl Exp $
1111
*--------------------------------------------------------------------
1212
*/
1313
#ifndef GUC_H
@@ -208,6 +208,8 @@ extern void ProcessGUCArray(ArrayType *array, GucSource source);
208208
extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
209209
extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
210210

211+
extern void pg_timezone_abbrev_initialize(void);
212+
211213
#ifdef EXEC_BACKEND
212214
extern void write_nondefault_variables(GucContext context);
213215
extern void read_nondefault_variables(void);

0 commit comments

Comments
 (0)