mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
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:
parent
0dd738148c
commit
be74113f76
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Routines for handling of 'SET var TO', 'SHOW var' and 'RESET var'
|
* Routines for handling of 'SET var TO',
|
||||||
* statements.
|
* '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
|
static bool
|
||||||
parse_null(const char *value)
|
parse_null(const char *value)
|
||||||
{
|
{
|
||||||
@ -153,6 +154,7 @@ reset_null(const char *value)
|
|||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_geqo(const char *value)
|
parse_geqo(const char *value)
|
||||||
@ -398,6 +400,46 @@ reset_date()
|
|||||||
return TRUE;
|
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
|
struct VariableParsers
|
||||||
{
|
{
|
||||||
@ -412,7 +454,7 @@ struct VariableParsers
|
|||||||
"datestyle", parse_date, show_date, reset_date
|
"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,
|
"cost_heap", parse_cost_heap,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user