Skip to content
Snippets Groups Projects
Commit d6b5d850 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart
Browse files

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.
parent a90b6a44
No related branches found
No related tags found
No related merge requests found
......@@ -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 $
*
*/
......@@ -22,19 +22,6 @@ extern bool _use_geqo_;
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
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();
}
return TRUE;
} /* reset_timezone() */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment