From: Thomas G. Lockhart Date: Tue, 3 Feb 1998 16:06:49 +0000 (+0000) Subject: Supress call to tzset() in reset_timezone() if a new time zone has never X-Git-Tag: REL9_0_0~27605 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d6b5d8506dfbb23c8028991345c0e39d89c764db;p=pg-rex%2Fsyncrep.git Supress call to tzset() in reset_timezone() if a new time zone has never been set in the session. General cleanup of timezone support code. --- diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 8193b6cb91..7ab04df99c 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -2,7 +2,7 @@ * Routines for handling of 'SET var TO', * 'SHOW var' and 'RESET var' statements. * - * $Id: variable.c,v 1.2 1998/01/07 18:46:26 momjian Exp $ + * $Id: variable.c,v 1.3 1998/02/03 16:06:49 thomas Exp $ * */ @@ -23,19 +23,6 @@ extern int32 _use_geqo_rels_; extern bool _use_right_sided_plans_; /*-----------------------------------------------------------------------*/ -#if USE_EURODATES -#define DATE_EURO TRUE -#else -#define DATE_EURO FALSE -#endif - -/*-----------------------------------------------------------------------*/ -struct PGVariables PGVariables = -{ - {DATE_EURO, Date_Postgres} -}; - -/*-----------------------------------------------------------------------*/ static const char * get_token(char **tok, char **val, const char *str) { @@ -137,26 +124,6 @@ get_token(char **tok, char **val, const char *str) } /*-----------------------------------------------------------------------*/ -#if FALSE -static bool -parse_null(const char *value) -{ - return TRUE; -} - -static bool -show_null(const char *value) -{ - return TRUE; -} - -static bool -reset_null(const char *value) -{ - return TRUE; -} -#endif - bool parse_geqo(const char *value) { @@ -247,6 +214,7 @@ parse_r_plans(const char *value) return TRUE; } +/*-----------------------------------------------------------------------*/ bool show_r_plans() { @@ -270,6 +238,7 @@ reset_r_plans() return TRUE; } +/*-----------------------------------------------------------------------*/ bool parse_cost_heap(const char *value) { @@ -302,6 +271,7 @@ reset_cost_heap() return TRUE; } +/*-----------------------------------------------------------------------*/ bool parse_cost_index(const char *value) { @@ -334,6 +304,7 @@ reset_cost_index() return TRUE; } +/*-----------------------------------------------------------------------*/ bool parse_date(const char *value) { @@ -470,22 +441,13 @@ parse_timezone(const char *value) { /* Not yet tried to save original value from environment? */ if (defaultTZ == NULL) - { /* found something? then save it for later */ - if (getenv("TZ") != NULL) - { - defaultTZ = getenv("TZ"); - if (defaultTZ == NULL) - defaultTZ = (char *) -1; - else - strcpy(TZvalue, defaultTZ); - } + if ((defaultTZ = getenv("TZ")) != NULL) + strcpy(TZvalue, defaultTZ); + /* found nothing so mark with an invalid pointer */ else - { defaultTZ = (char *) -1; - } - } strcpy(tzbuf, "TZ="); strcat(tzbuf, tok); @@ -519,24 +481,34 @@ show_timezone() * clears the process-specific environment variables. * Other reasonable arguments to putenv() (e.g. "TZ=", "TZ", "") result * in a core dump (under Linux anyway). + * - thomas 1998-01-26 */ bool reset_timezone() { - if ((defaultTZ != NULL) && (defaultTZ != (char *) -1)) + /* no time zone has been set in this session? */ + if (defaultTZ == NULL) + { + } + + /* time zone was set and original explicit time zone available? */ + else if (defaultTZ != (char *) -1) { strcpy(tzbuf, "TZ="); strcat(tzbuf, TZvalue); if (putenv(tzbuf) != 0) elog(ERROR, "Unable to set TZ environment variable to %s", TZvalue); + tzset(); } + + /* otherwise, time zone was set but no original explicit time zone available */ else { strcpy(tzbuf, "="); if (putenv(tzbuf) != 0) elog(ERROR, "Unable to clear TZ environment variable", NULL); + tzset(); } - tzset(); return TRUE; } /* reset_timezone() */