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

Commit7016678

Browse files
author
Thomas G. Lockhart
committed
Enable SET value = DEFAULT by passing null parameter to parsers.
Enable SET TIME ZONE using TZ environment variable.
1 parentb2905ea commit7016678

File tree

1 file changed

+85
-27
lines changed

1 file changed

+85
-27
lines changed

‎src/backend/tcop/variable.c

Lines changed: 85 additions & 27 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.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-
staticbool
159+
bool
160160
parse_geqo(constchar*value)
161161
{
162162
constchar*rest;
163163
char*tok,
164164
*val;
165165

166+
if (value==NULL)
167+
{
168+
reset_geqo();
169+
return TRUE;
170+
}
171+
166172
rest=get_token(&tok,&val,value);
167173
if (tok==NULL)
168174
elog(WARN,"Value undefined");
@@ -197,7 +203,7 @@ parse_geqo(const char *value)
197203
return TRUE;
198204
}
199205

200-
staticbool
206+
bool
201207
show_geqo()
202208
{
203209

@@ -208,8 +214,8 @@ show_geqo()
208214
return TRUE;
209215
}
210216

211-
staticbool
212-
reset_geqo()
217+
bool
218+
reset_geqo(void)
213219
{
214220

215221
#ifdefGEQO
@@ -221,9 +227,14 @@ reset_geqo()
221227
return TRUE;
222228
}
223229

224-
staticbool
230+
bool
225231
parse_r_plans(constchar*value)
226232
{
233+
if (value==NULL)
234+
{
235+
reset_r_plans();
236+
return TRUE;
237+
}
227238

228239
if (strcasecmp(value,"on")==0)
229240
_use_right_sided_plans_= true;
@@ -235,7 +246,7 @@ parse_r_plans(const char *value)
235246
return TRUE;
236247
}
237248

238-
staticbool
249+
bool
239250
show_r_plans()
240251
{
241252

@@ -246,7 +257,7 @@ show_r_plans()
246257
return TRUE;
247258
}
248259

249-
staticbool
260+
bool
250261
reset_r_plans()
251262
{
252263

@@ -258,63 +269,83 @@ reset_r_plans()
258269
return TRUE;
259270
}
260271

261-
staticbool
272+
bool
262273
parse_cost_heap(constchar*value)
263274
{
264-
float32res=float4in((char*)value);
275+
float32res;
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

268286
return TRUE;
269287
}
270288

271-
staticbool
289+
bool
272290
show_cost_heap()
273291
{
274292

275293
elog(NOTICE,"COST_HEAP is %f",_cpu_page_wight_);
276294
return TRUE;
277295
}
278296

279-
staticbool
297+
bool
280298
reset_cost_heap()
281299
{
282300
_cpu_page_wight_=_CPU_PAGE_WEIGHT_;
283301
return TRUE;
284302
}
285303

286-
staticbool
304+
bool
287305
parse_cost_index(constchar*value)
288306
{
289-
float32res=float4in((char*)value);
307+
float32res;
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

293318
return TRUE;
294319
}
295320

296-
staticbool
321+
bool
297322
show_cost_index()
298323
{
299324

300325
elog(NOTICE,"COST_INDEX is %f",_cpu_index_page_wight_);
301326
return TRUE;
302327
}
303328

304-
staticbool
329+
bool
305330
reset_cost_index()
306331
{
307332
_cpu_index_page_wight_=_CPU_INDEX_PAGE_WEIGHT_;
308333
return TRUE;
309334
}
310335

311-
staticbool
336+
bool
312337
parse_date(constchar*value)
313338
{
314339
char*tok;
315340
intdcnt=0,
316341
ecnt=0;
317342

343+
if (value==NULL)
344+
{
345+
reset_date();
346+
return TRUE;
347+
}
348+
318349
while ((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)
364395
return TRUE;
365396
}
366397

367-
staticbool
398+
bool
368399
show_date()
369400
{
370401
charbuf[64];
@@ -391,7 +422,7 @@ show_date()
391422
return TRUE;
392423
}
393424

394-
staticbool
425+
bool
395426
reset_date()
396427
{
397428
DateStyle=USE_POSTGRES_DATES;
@@ -400,13 +431,35 @@ reset_date()
400431
return TRUE;
401432
}
402433

403-
staticbool
434+
staticchar*defaultTZ=NULL;
435+
staticcharTZvalue[10];
436+
437+
bool
404438
parse_timezone(constchar*value)
405439
{
406440
char*tok;
407441

442+
if (value==NULL)
443+
{
444+
reset_timezone();
445+
return TRUE;
446+
}
447+
408448
while ((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+
410463
setenv("TZ",tok, TRUE);
411464
tzset();
412465
PFREE(tok);
@@ -415,7 +468,7 @@ parse_timezone(const char *value)
415468
return TRUE;
416469
}/* parse_timezone() */
417470

418-
staticbool
471+
bool
419472
show_timezone()
420473
{
421474
charbuf[64];
@@ -431,10 +484,17 @@ show_timezone()
431484
return TRUE;
432485
}/* show_timezone() */
433486

434-
staticbool
487+
bool
435488
reset_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+
}
438498
tzset();
439499

440500
return 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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp