2
2
* Routines for handling of 'SET var TO',
3
3
* 'SHOW var' and 'RESET var' statements.
4
4
*
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 $
6
6
*
7
7
*/
8
8
@@ -22,19 +22,6 @@ extern bool _use_geqo_;
22
22
extern int32 _use_geqo_rels_ ;
23
23
extern bool _use_right_sided_plans_ ;
24
24
25
- /*-----------------------------------------------------------------------*/
26
- #if USE_EURODATES
27
- #define DATE_EURO TRUE
28
- #else
29
- #define DATE_EURO FALSE
30
- #endif
31
-
32
- /*-----------------------------------------------------------------------*/
33
- struct PGVariables PGVariables =
34
- {
35
- {DATE_EURO , Date_Postgres }
36
- };
37
-
38
25
/*-----------------------------------------------------------------------*/
39
26
static const char *
40
27
get_token (char * * tok , char * * val , const char * str )
@@ -137,26 +124,6 @@ get_token(char **tok, char **val, const char *str)
137
124
}
138
125
139
126
/*-----------------------------------------------------------------------*/
140
- #if FALSE
141
- static bool
142
- parse_null (const char * value )
143
- {
144
- return TRUE;
145
- }
146
-
147
- static bool
148
- show_null (const char * value )
149
- {
150
- return TRUE;
151
- }
152
-
153
- static bool
154
- reset_null (const char * value )
155
- {
156
- return TRUE;
157
- }
158
- #endif
159
-
160
127
bool
161
128
parse_geqo (const char * value )
162
129
{
@@ -247,6 +214,7 @@ parse_r_plans(const char *value)
247
214
return TRUE;
248
215
}
249
216
217
+ /*-----------------------------------------------------------------------*/
250
218
bool
251
219
show_r_plans ()
252
220
{
@@ -270,6 +238,7 @@ reset_r_plans()
270
238
return TRUE;
271
239
}
272
240
241
+ /*-----------------------------------------------------------------------*/
273
242
bool
274
243
parse_cost_heap (const char * value )
275
244
{
@@ -302,6 +271,7 @@ reset_cost_heap()
302
271
return TRUE;
303
272
}
304
273
274
+ /*-----------------------------------------------------------------------*/
305
275
bool
306
276
parse_cost_index (const char * value )
307
277
{
@@ -334,6 +304,7 @@ reset_cost_index()
334
304
return TRUE;
335
305
}
336
306
307
+ /*-----------------------------------------------------------------------*/
337
308
bool
338
309
parse_date (const char * value )
339
310
{
@@ -470,22 +441,13 @@ parse_timezone(const char *value)
470
441
{
471
442
/* Not yet tried to save original value from environment? */
472
443
if (defaultTZ == NULL )
473
- {
474
444
/* 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
+
483
448
/* found nothing so mark with an invalid pointer */
484
449
else
485
- {
486
450
defaultTZ = (char * ) -1 ;
487
- }
488
- }
489
451
490
452
strcpy (tzbuf , "TZ=" );
491
453
strcat (tzbuf , tok );
@@ -519,24 +481,34 @@ show_timezone()
519
481
* clears the process-specific environment variables.
520
482
* Other reasonable arguments to putenv() (e.g. "TZ=", "TZ", "") result
521
483
* in a core dump (under Linux anyway).
484
+ * - thomas 1998-01-26
522
485
*/
523
486
bool
524
487
reset_timezone ()
525
488
{
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
+ else if (defaultTZ != (char * ) -1 )
527
496
{
528
497
strcpy (tzbuf , "TZ=" );
529
498
strcat (tzbuf , TZvalue );
530
499
if (putenv (tzbuf ) != 0 )
531
500
elog (ERROR , "Unable to set TZ environment variable to %s" , TZvalue );
501
+ tzset ();
532
502
}
503
+
504
+ /* otherwise, time zone was set but no original explicit time zone available */
533
505
else
534
506
{
535
507
strcpy (tzbuf , "=" );
536
508
if (putenv (tzbuf ) != 0 )
537
509
elog (ERROR , "Unable to clear TZ environment variable" , NULL );
510
+ tzset ();
538
511
}
539
- tzset ();
540
512
541
513
return TRUE;
542
514
} /* reset_timezone() */
0 commit comments