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.15 1998/10/08 23:50:28 tgl Exp $
5
+ * $Id: variable.c,v 1.16 1998/10/14 05:09:58 momjian Exp $
6
6
*
7
7
*/
8
8
18
18
#ifdef MULTIBYTE
19
19
#include "mb/pg_wchar.h"
20
20
#endif
21
+ #ifdef QUERY_LIMIT
22
+ #include "executor/executor.h"
23
+ #include "executor/execdefs.h"
24
+ #endif
21
25
22
26
static bool show_date (void );
23
27
static bool reset_date (void );
@@ -40,6 +44,11 @@ static bool parse_geqo(const char *);
40
44
static bool show_ksqo (void );
41
45
static bool reset_ksqo (void );
42
46
static bool parse_ksqo (const char * );
47
+ #ifdef QUERY_LIMIT
48
+ static bool show_query_limit (void );
49
+ static bool reset_query_limit (void );
50
+ static bool parse_query_limit (const char * );
51
+ #endif
43
52
44
53
extern Cost _cpu_page_wight_ ;
45
54
extern Cost _cpu_index_page_wight_ ;
@@ -48,7 +57,11 @@ extern int32 _use_geqo_rels_;
48
57
extern bool _use_right_sided_plans_ ;
49
58
extern bool _use_keyset_query_optimizer ;
50
59
51
- /*-----------------------------------------------------------------------*/
60
+ /*
61
+ *
62
+ * Get_Token
63
+ *
64
+ */
52
65
static const char *
53
66
get_token (char * * tok , char * * val , const char * str )
54
67
{
@@ -149,7 +162,11 @@ get_token(char **tok, char **val, const char *str)
149
162
return str ;
150
163
}
151
164
152
- /*-----------------------------------------------------------------------*/
165
+ /*
166
+ *
167
+ * GEQO
168
+ *
169
+ */
153
170
static bool
154
171
parse_geqo (const char * value )
155
172
{
@@ -221,6 +238,11 @@ reset_geqo(void)
221
238
return TRUE;
222
239
}
223
240
241
+ /*
242
+ *
243
+ * R_PLANS
244
+ *
245
+ */
224
246
static bool
225
247
parse_r_plans (const char * value )
226
248
{
@@ -240,7 +262,6 @@ parse_r_plans(const char *value)
240
262
return TRUE;
241
263
}
242
264
243
- /*-----------------------------------------------------------------------*/
244
265
static bool
245
266
show_r_plans ()
246
267
{
@@ -264,7 +285,11 @@ reset_r_plans()
264
285
return TRUE;
265
286
}
266
287
267
- /*-----------------------------------------------------------------------*/
288
+ /*
289
+ *
290
+ * COST_HEAP
291
+ *
292
+ */
268
293
static bool
269
294
parse_cost_heap (const char * value )
270
295
{
@@ -297,7 +322,11 @@ reset_cost_heap()
297
322
return TRUE;
298
323
}
299
324
300
- /*-----------------------------------------------------------------------*/
325
+ /*
326
+ *
327
+ * COST_INDEX
328
+ *
329
+ */
301
330
static bool
302
331
parse_cost_index (const char * value )
303
332
{
@@ -330,7 +359,11 @@ reset_cost_index()
330
359
return TRUE;
331
360
}
332
361
333
- /*-----------------------------------------------------------------------*/
362
+ /*
363
+ *
364
+ * DATE_STYLE
365
+ *
366
+ */
334
367
static bool
335
368
parse_date (const char * value )
336
369
{
@@ -448,6 +481,11 @@ static char *defaultTZ = NULL;
448
481
static char TZvalue [64 ];
449
482
static char tzbuf [64 ];
450
483
484
+ /*
485
+ *
486
+ * TIMEZONE
487
+ *
488
+ */
451
489
/* parse_timezone()
452
490
* Handle SET TIME ZONE...
453
491
* Try to save existing TZ environment variable for later use in RESET TIME ZONE.
@@ -545,7 +583,53 @@ reset_timezone()
545
583
return TRUE;
546
584
} /* reset_timezone() */
547
585
586
+ /*
587
+ *
588
+ * Query_limit
589
+ *
590
+ */
591
+ #ifdef QUERY_LIMIT
592
+ static bool
593
+ parse_query_limit (const char * value )
594
+ {
595
+ int32 limit ;
596
+
597
+ if (value == NULL ) {
598
+ reset_query_limit ();
599
+ return (TRUE);
600
+ }
601
+ limit = pg_atoi (value , sizeof (int32 ), '\0' );
602
+ if (limit <= -1 ) {
603
+ elog (ERROR , "Bad value for # of query limit (%s)" , value );
604
+ }
605
+ ExecutorLimit (limit );
606
+ return (TRUE);
607
+ }
608
+
609
+ static bool
610
+ show_query_limit (void )
611
+ {
612
+ int limit ;
613
+
614
+ limit = ExecutorGetLimit ();
615
+ if (limit == ALL_TUPLES ) {
616
+ elog (NOTICE , "No query limit is set" );
617
+ } else {
618
+ elog (NOTICE , "query limit is %d" ,limit );
619
+ }
620
+ return (TRUE);
621
+ }
622
+
623
+ static bool
624
+ reset_query_limit (void )
625
+ {
626
+ ExecutorLimit (ALL_TUPLES );
627
+ return (TRUE);
628
+ }
629
+ #endif
630
+
548
631
/*-----------------------------------------------------------------------*/
632
+
549
633
struct VariableParsers
550
634
{
551
635
const char * name ;
@@ -584,6 +668,11 @@ struct VariableParsers
584
668
{
585
669
"ksqo" , parse_ksqo , show_ksqo , reset_ksqo
586
670
},
671
+ #ifdef QUERY_LIMIT
672
+ {
673
+ "query_limit" , parse_query_limit , show_query_limit , reset_query_limit
674
+ },
675
+ #endif
587
676
{
588
677
NULL , NULL , NULL , NULL
589
678
}
0 commit comments