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.
This commit is contained in:
Tom Lane 2006-07-29 03:02:56 +00:00
parent 46d9c2ec8f
commit 033a477e9e
5 changed files with 57 additions and 11 deletions

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.220 2006/07/14 14:52:17 momjian Exp $ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.221 2006/07/29 03:02:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -358,6 +358,8 @@ BootstrapMain(int argc, char *argv[])
proc_exit(1); proc_exit(1);
/* If timezone is not set, determine what the OS uses */ /* If timezone is not set, determine what the OS uses */
pg_timezone_initialize(); pg_timezone_initialize();
/* If timezone_abbreviations is not set, select default */
pg_timezone_abbrev_initialize();
} }
/* Validate we have been given a reasonable-looking DataDir */ /* Validate we have been given a reasonable-looking DataDir */

View File

@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.496 2006/07/25 01:23:34 tgl Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.497 2006/07/29 03:02:55 tgl Exp $
* *
* NOTES * NOTES
* *
@ -691,10 +691,16 @@ PostmasterMain(int argc, char *argv[])
* should be done during GUC initialization, but because it can take as * should be done during GUC initialization, but because it can take as
* much as several seconds, we delay it until after we've created the * much as several seconds, we delay it until after we've created the
* postmaster.pid file. This prevents problems with boot scripts that * postmaster.pid file. This prevents problems with boot scripts that
* expect the pidfile to appear quickly.) * expect the pidfile to appear quickly. Also, we avoid problems with
* trying to locate the timezone files too early in initialization.)
*/ */
pg_timezone_initialize(); pg_timezone_initialize();
/*
* Likewise, init timezone_abbreviations if not already set.
*/
pg_timezone_abbrev_initialize();
/* /*
* Initialize SSL library, if specified. * Initialize SSL library, if specified.
*/ */

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.492 2006/07/14 14:52:23 momjian Exp $ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.493 2006/07/29 03:02:56 tgl Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
@ -2758,6 +2758,8 @@ PostgresMain(int argc, char *argv[], const char *username)
proc_exit(1); proc_exit(1);
/* If timezone is not set, determine what the OS uses */ /* If timezone is not set, determine what the OS uses */
pg_timezone_initialize(); pg_timezone_initialize();
/* If timezone_abbreviations is not set, select default */
pg_timezone_abbrev_initialize();
} }
if (PostAuthDelay) if (PostAuthDelay)

View File

@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.332 2006/07/27 08:30:41 petere Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.333 2006/07/29 03:02:56 tgl Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
@ -221,10 +221,10 @@ static char *regex_flavor_string;
static char *server_encoding_string; static char *server_encoding_string;
static char *server_version_string; static char *server_version_string;
static char *timezone_string; static char *timezone_string;
static char *timezone_abbreviations_string;
static char *XactIsoLevel_string; static char *XactIsoLevel_string;
static char *data_directory; static char *data_directory;
static char *custom_variable_classes; static char *custom_variable_classes;
static char *timezone_abbreviations;
static int max_function_args; static int max_function_args;
static int max_index_keys; static int max_index_keys;
static int max_identifier_length; static int max_identifier_length;
@ -2101,8 +2101,8 @@ static struct config_string ConfigureNamesString[] =
gettext_noop("Selects a file of timezone abbreviations"), gettext_noop("Selects a file of timezone abbreviations"),
NULL, NULL,
}, },
&timezone_abbreviations, &timezone_abbreviations_string,
"Default", assign_timezone_abbreviations, NULL "UNKNOWN", assign_timezone_abbreviations, NULL
}, },
{ {
@ -6288,9 +6288,27 @@ assign_backslash_quote(const char *newval, bool doit, GucSource source)
static const char * static const char *
assign_timezone_abbreviations(const char *newval, bool doit, GucSource source) assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
{ {
/*
* The powerup value shown above for timezone_abbreviations is "UNKNOWN".
* When we see this we just do nothing. If this value isn't overridden
* from the config file then pg_timezone_abbrev_initialize() will
* eventually replace it with "Default". This hack has two purposes:
* to avoid wasting cycles loading values that might soon be overridden
* from the config file, and to avoid trying to read the timezone abbrev
* files during InitializeGUCOptions(). The latter doesn't work in an
* EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and
* so we can't locate PGSHAREDIR. (Essentially the same hack is used
* to delay initializing TimeZone ... if we have any more, we should
* try to clean up and centralize this mechanism ...)
*/
if (strcmp(newval, "UNKNOWN") == 0)
{
return newval;
}
/* Loading abbrev file is expensive, so only do it when value changes */ /* Loading abbrev file is expensive, so only do it when value changes */
if (timezone_abbreviations == NULL || if (timezone_abbreviations_string == NULL ||
strcmp(timezone_abbreviations, newval) != 0) strcmp(timezone_abbreviations_string, newval) != 0)
{ {
int elevel; int elevel;
@ -6309,6 +6327,22 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
return newval; return newval;
} }
/*
* pg_timezone_abbrev_initialize --- set default value if not done already
*
* This is called after initial loading of postgresql.conf. If no
* timezone_abbreviations setting was found therein, select default.
*/
void
pg_timezone_abbrev_initialize(void)
{
if (strcmp(timezone_abbreviations_string, "UNKNOWN") == 0)
{
SetConfigOption("timezone_abbreviations", "Default",
PGC_POSTMASTER, PGC_S_ARGV);
}
}
static bool static bool
assign_tcp_keepalives_idle(int newval, bool doit, GucSource source) assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
{ {

View File

@ -7,7 +7,7 @@
* Copyright (c) 2000-2006, PostgreSQL Global Development Group * Copyright (c) 2000-2006, PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.70 2006/07/25 03:51:22 tgl Exp $ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.71 2006/07/29 03:02:56 tgl Exp $
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
#ifndef GUC_H #ifndef GUC_H
@ -208,6 +208,8 @@ extern void ProcessGUCArray(ArrayType *array, GucSource source);
extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value); extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *value);
extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name); extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
extern void pg_timezone_abbrev_initialize(void);
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
extern void write_nondefault_variables(GucContext context); extern void write_nondefault_variables(GucContext context);
extern void read_nondefault_variables(void); extern void read_nondefault_variables(void);