22 * Routines for handling of 'SET var TO',
33 * 'SHOW var' and 'RESET var' statements.
44 *
5- * $Id: variable.c,v 1.18 1997/10/30 16:52:11 thomas Exp $
5+ * $Id: variable.c,v 1.19 1997/11/07 06:43:16 thomas Exp $
66 *
77 */
88
@@ -156,13 +156,19 @@ reset_null(const char *value)
156156}
157157#endif
158158
159- static bool
159+ bool
160160parse_geqo (const char * value )
161161{
162162const char * rest ;
163163char * tok ,
164164* val ;
165165
166+ if (value == NULL )
167+ {
168+ reset_geqo ();
169+ return TRUE;
170+ }
171+
166172rest = get_token (& tok ,& val ,value );
167173if (tok == NULL )
168174elog (WARN ,"Value undefined" );
@@ -197,7 +203,7 @@ parse_geqo(const char *value)
197203return TRUE;
198204}
199205
200- static bool
206+ bool
201207show_geqo ()
202208{
203209
@@ -208,8 +214,8 @@ show_geqo()
208214return TRUE;
209215}
210216
211- static bool
212- reset_geqo ()
217+ bool
218+ reset_geqo (void )
213219{
214220
215221#ifdef GEQO
@@ -221,9 +227,14 @@ reset_geqo()
221227return TRUE;
222228}
223229
224- static bool
230+ bool
225231parse_r_plans (const char * value )
226232{
233+ if (value == NULL )
234+ {
235+ reset_r_plans ();
236+ return TRUE;
237+ }
227238
228239if (strcasecmp (value ,"on" )== 0 )
229240_use_right_sided_plans_ = true;
@@ -235,7 +246,7 @@ parse_r_plans(const char *value)
235246return TRUE;
236247}
237248
238- static bool
249+ bool
239250show_r_plans ()
240251{
241252
@@ -246,7 +257,7 @@ show_r_plans()
246257return TRUE;
247258}
248259
249- static bool
260+ bool
250261reset_r_plans ()
251262{
252263
@@ -258,63 +269,83 @@ reset_r_plans()
258269return TRUE;
259270}
260271
261- static bool
272+ bool
262273parse_cost_heap (const char * value )
263274{
264- float32 res = float4in ((char * )value );
275+ float32 res ;
276+
277+ if (value == NULL )
278+ {
279+ reset_cost_heap ();
280+ return TRUE;
281+ }
265282
283+ res = float4in ((char * )value );
266284_cpu_page_wight_ = * res ;
267285
268286return TRUE;
269287}
270288
271- static bool
289+ bool
272290show_cost_heap ()
273291{
274292
275293elog (NOTICE ,"COST_HEAP is %f" ,_cpu_page_wight_ );
276294return TRUE;
277295}
278296
279- static bool
297+ bool
280298reset_cost_heap ()
281299{
282300_cpu_page_wight_ = _CPU_PAGE_WEIGHT_ ;
283301return TRUE;
284302}
285303
286- static bool
304+ bool
287305parse_cost_index (const char * value )
288306{
289- float32 res = float4in ((char * )value );
307+ float32 res ;
308+
309+ if (value == NULL )
310+ {
311+ reset_cost_index ();
312+ return TRUE;
313+ }
290314
315+ res = float4in ((char * )value );
291316_cpu_index_page_wight_ = * res ;
292317
293318return TRUE;
294319}
295320
296- static bool
321+ bool
297322show_cost_index ()
298323{
299324
300325elog (NOTICE ,"COST_INDEX is %f" ,_cpu_index_page_wight_ );
301326return TRUE;
302327}
303328
304- static bool
329+ bool
305330reset_cost_index ()
306331{
307332_cpu_index_page_wight_ = _CPU_INDEX_PAGE_WEIGHT_ ;
308333return TRUE;
309334}
310335
311- static bool
336+ bool
312337parse_date (const char * value )
313338{
314339char * tok ;
315340int dcnt = 0 ,
316341ecnt = 0 ;
317342
343+ if (value == NULL )
344+ {
345+ reset_date ();
346+ return TRUE;
347+ }
348+
318349while ((value = get_token (& tok ,NULL ,value ))!= 0 )
319350{
320351/* Ugh. Somebody ought to write a table driven version -- mjl */
@@ -364,7 +395,7 @@ parse_date(const char *value)
364395return TRUE;
365396}
366397
367- static bool
398+ bool
368399show_date ()
369400{
370401char buf [64 ];
@@ -391,7 +422,7 @@ show_date()
391422return TRUE;
392423}
393424
394- static bool
425+ bool
395426reset_date ()
396427{
397428DateStyle = USE_POSTGRES_DATES ;
@@ -400,13 +431,35 @@ reset_date()
400431return TRUE;
401432}
402433
403- static bool
434+ static char * defaultTZ = NULL ;
435+ static char TZvalue [10 ];
436+
437+ bool
404438parse_timezone (const char * value )
405439{
406440char * tok ;
407441
442+ if (value == NULL )
443+ {
444+ reset_timezone ();
445+ return TRUE;
446+ }
447+
408448while ((value = get_token (& tok ,NULL ,value ))!= 0 )
409449{
450+ if ((defaultTZ == NULL )&& (getenv ("TZ" )!= NULL ))
451+ {
452+ defaultTZ = getenv ("TZ" );
453+ if (defaultTZ == NULL )
454+ {
455+ defaultTZ = (char * )-1 ;
456+ }
457+ else
458+ {
459+ strcpy (TZvalue ,defaultTZ );
460+ }
461+ }
462+
410463setenv ("TZ" ,tok , TRUE);
411464tzset ();
412465PFREE (tok );
@@ -415,7 +468,7 @@ parse_timezone(const char *value)
415468return TRUE;
416469}/* parse_timezone() */
417470
418- static bool
471+ bool
419472show_timezone ()
420473{
421474char buf [64 ];
@@ -431,10 +484,17 @@ show_timezone()
431484return TRUE;
432485}/* show_timezone() */
433486
434- static bool
487+ bool
435488reset_timezone ()
436489{
437- unsetenv ("TZ" );
490+ if ((defaultTZ != NULL )&& (defaultTZ != (char * )-1 ))
491+ {
492+ setenv ("TZ" ,TZvalue , TRUE);
493+ }
494+ else
495+ {
496+ unsetenv ("TZ" );
497+ }
438498tzset ();
439499
440500return TRUE;
@@ -457,12 +517,10 @@ struct VariableParsers
457517"timezone" ,parse_timezone ,show_timezone ,reset_timezone
458518},
459519{
460- "cost_heap" ,parse_cost_heap ,
461- show_cost_heap ,reset_cost_heap
520+ "cost_heap" ,parse_cost_heap ,show_cost_heap ,reset_cost_heap
462521},
463522{
464- "cost_index" ,parse_cost_index ,
465- show_cost_index ,reset_cost_index
523+ "cost_index" ,parse_cost_index ,show_cost_index ,reset_cost_index
466524},
467525{
468526"geqo" ,parse_geqo ,show_geqo ,reset_geqo