Add initial backend support for SET/SHOW/RESET TIME ZONE.

Uses TZ environment variable.
 Needs additional schemes for brain-dead SQL92 time offsets.
This commit is contained in:
Thomas G. Lockhart 1997-10-30 16:52:11 +00:00
parent 0dd738148c
commit be74113f76
1 changed files with 46 additions and 4 deletions

View File

@ -1,8 +1,8 @@
/*
* Routines for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* statements.
* Routines for handling of 'SET var TO',
* 'SHOW var' and 'RESET var' statements.
*
* $Id: variable.c,v 1.17 1997/10/25 01:10:22 momjian Exp $
* $Id: variable.c,v 1.18 1997/10/30 16:52:11 thomas Exp $
*
*/
@ -136,6 +136,7 @@ get_token(char **tok, char **val, const char *str)
}
/*-----------------------------------------------------------------------*/
#if FALSE
static bool
parse_null(const char *value)
{
@ -153,6 +154,7 @@ reset_null(const char *value)
{
return TRUE;
}
#endif
static bool
parse_geqo(const char *value)
@ -398,6 +400,46 @@ reset_date()
return TRUE;
}
static bool
parse_timezone(const char *value)
{
char *tok;
while ((value = get_token(&tok, NULL, value)) != 0)
{
setenv("TZ", tok, TRUE);
tzset();
PFREE(tok);
}
return TRUE;
} /* parse_timezone() */
static bool
show_timezone()
{
char buf[64];
char *tz;
tz = getenv("TZ");
strcpy(buf, "Time zone is ");
strcat(buf, ((tz != NULL)? tz: "unknown"));
elog(NOTICE, buf, NULL);
return TRUE;
} /* show_timezone() */
static bool
reset_timezone()
{
unsetenv("TZ");
tzset();
return TRUE;
} /* reset_timezone() */
/*-----------------------------------------------------------------------*/
struct VariableParsers
{
@ -412,7 +454,7 @@ struct VariableParsers
"datestyle", parse_date, show_date, reset_date
},
{
"timezone", parse_null, show_null, reset_null
"timezone", parse_timezone, show_timezone, reset_timezone
},
{
"cost_heap", parse_cost_heap,