Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd6b5d85

Browse files
author
Thomas G. Lockhart
committed
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.
1 parenta90b6a4 commitd6b5d85

File tree

1 file changed

+20
-48
lines changed

1 file changed

+20
-48
lines changed

‎src/backend/commands/variable.c‎

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Routines for handling of 'SET var TO',
33
* 'SHOW var' and 'RESET var' statements.
44
*
5-
* $Id: variable.c,v 1.2 1998/01/07 18:46:26 momjian Exp $
5+
* $Id: variable.c,v 1.3 1998/02/03 16:06:49 thomas Exp $
66
*
77
*/
88

@@ -22,19 +22,6 @@ extern bool _use_geqo_;
2222
externint32_use_geqo_rels_;
2323
externbool_use_right_sided_plans_;
2424

25-
/*-----------------------------------------------------------------------*/
26-
#ifUSE_EURODATES
27-
#defineDATE_EUROTRUE
28-
#else
29-
#defineDATE_EURO FALSE
30-
#endif
31-
32-
/*-----------------------------------------------------------------------*/
33-
structPGVariablesPGVariables=
34-
{
35-
{DATE_EURO,Date_Postgres}
36-
};
37-
3825
/*-----------------------------------------------------------------------*/
3926
staticconstchar*
4027
get_token(char**tok,char**val,constchar*str)
@@ -137,26 +124,6 @@ get_token(char **tok, char **val, const char *str)
137124
}
138125

139126
/*-----------------------------------------------------------------------*/
140-
#ifFALSE
141-
staticbool
142-
parse_null(constchar*value)
143-
{
144-
return TRUE;
145-
}
146-
147-
staticbool
148-
show_null(constchar*value)
149-
{
150-
return TRUE;
151-
}
152-
153-
staticbool
154-
reset_null(constchar*value)
155-
{
156-
return TRUE;
157-
}
158-
#endif
159-
160127
bool
161128
parse_geqo(constchar*value)
162129
{
@@ -247,6 +214,7 @@ parse_r_plans(const char *value)
247214
return TRUE;
248215
}
249216

217+
/*-----------------------------------------------------------------------*/
250218
bool
251219
show_r_plans()
252220
{
@@ -270,6 +238,7 @@ reset_r_plans()
270238
return TRUE;
271239
}
272240

241+
/*-----------------------------------------------------------------------*/
273242
bool
274243
parse_cost_heap(constchar*value)
275244
{
@@ -302,6 +271,7 @@ reset_cost_heap()
302271
return TRUE;
303272
}
304273

274+
/*-----------------------------------------------------------------------*/
305275
bool
306276
parse_cost_index(constchar*value)
307277
{
@@ -334,6 +304,7 @@ reset_cost_index()
334304
return TRUE;
335305
}
336306

307+
/*-----------------------------------------------------------------------*/
337308
bool
338309
parse_date(constchar*value)
339310
{
@@ -470,22 +441,13 @@ parse_timezone(const char *value)
470441
{
471442
/* Not yet tried to save original value from environment? */
472443
if (defaultTZ==NULL)
473-
{
474444
/* found something? then save it for later */
475-
if (getenv("TZ")!=NULL)
476-
{
477-
defaultTZ=getenv("TZ");
478-
if (defaultTZ==NULL)
479-
defaultTZ= (char*)-1;
480-
else
481-
strcpy(TZvalue,defaultTZ);
482-
}
445+
if ((defaultTZ=getenv("TZ"))!=NULL)
446+
strcpy(TZvalue,defaultTZ);
447+
483448
/* found nothing so mark with an invalid pointer */
484449
else
485-
{
486450
defaultTZ= (char*)-1;
487-
}
488-
}
489451

490452
strcpy(tzbuf,"TZ=");
491453
strcat(tzbuf,tok);
@@ -519,24 +481,34 @@ show_timezone()
519481
* clears the process-specific environment variables.
520482
* Other reasonable arguments to putenv() (e.g. "TZ=", "TZ", "") result
521483
* in a core dump (under Linux anyway).
484+
* - thomas 1998-01-26
522485
*/
523486
bool
524487
reset_timezone()
525488
{
526-
if ((defaultTZ!=NULL)&& (defaultTZ!= (char*)-1))
489+
/* no time zone has been set in this session? */
490+
if (defaultTZ==NULL)
491+
{
492+
}
493+
494+
/* time zone was set and original explicit time zone available? */
495+
elseif (defaultTZ!= (char*)-1)
527496
{
528497
strcpy(tzbuf,"TZ=");
529498
strcat(tzbuf,TZvalue);
530499
if (putenv(tzbuf)!=0)
531500
elog(ERROR,"Unable to set TZ environment variable to %s",TZvalue);
501+
tzset();
532502
}
503+
504+
/* otherwise, time zone was set but no original explicit time zone available */
533505
else
534506
{
535507
strcpy(tzbuf,"=");
536508
if (putenv(tzbuf)!=0)
537509
elog(ERROR,"Unable to clear TZ environment variable",NULL);
510+
tzset();
538511
}
539-
tzset();
540512

541513
return TRUE;
542514
}/* reset_timezone() */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp