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

Commit8cec4cf

Browse files
committed
New QUERY_LIMIT set command.
1 parent39f2ec5 commit8cec4cf

File tree

6 files changed

+161
-18
lines changed

6 files changed

+161
-18
lines changed

‎doc/src/sgml/ref/set.sgml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,44 @@ Equivalent to specifying <command>SET R_PLANS=Off</command>.
415415
The frontend may be initialized by setting the PGRPLANS
416416
environment variable.
417417

418+
<varlistentry>
419+
<term>
420+
QUERY_LIMIT
421+
</term>
422+
<listitem>
423+
<para>
424+
Sets the number of rows returned by a query.
425+
426+
<variablelist>
427+
<varlistentry>
428+
<term>
429+
Value
430+
</term>
431+
<listitem>
432+
<para>
433+
Maximum number of rows to return for a query. The default is unlimited.
434+
<varlistentry>
435+
<term>
436+
<replaceable class="parameter">#</replaceable>
437+
</term>
438+
<listitem>
439+
<para>
440+
Sets the maximum number of rows returned by a
441+
query to <replaceable class="parameter">#</replaceable>.
442+
<varlistentry>
443+
<term>
444+
DEFAULT
445+
</term>
446+
<listitem>
447+
<para>
448+
Sets the number of rows returned by a query to unlimited.
449+
</varlistentry>
450+
451+
<para>
452+
By default, there is no limit to the number of rows
453+
returned by a query.
454+
</variablelist>
455+
418456
</VARLISTENTRY>
419457
</VARIABLELIST>
420458
</REFSECT2>

‎src/backend/commands/variable.c

Lines changed: 96 additions & 7 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.15 1998/10/08 23:50:28 tgl Exp $
5+
* $Id: variable.c,v 1.16 1998/10/14 05:09:58 momjian Exp $
66
*
77
*/
88

@@ -18,6 +18,10 @@
1818
#ifdefMULTIBYTE
1919
#include"mb/pg_wchar.h"
2020
#endif
21+
#ifdefQUERY_LIMIT
22+
#include"executor/executor.h"
23+
#include"executor/execdefs.h"
24+
#endif
2125

2226
staticboolshow_date(void);
2327
staticboolreset_date(void);
@@ -40,6 +44,11 @@ static bool parse_geqo(const char *);
4044
staticboolshow_ksqo(void);
4145
staticboolreset_ksqo(void);
4246
staticboolparse_ksqo(constchar*);
47+
#ifdefQUERY_LIMIT
48+
staticboolshow_query_limit(void);
49+
staticboolreset_query_limit(void);
50+
staticboolparse_query_limit(constchar*);
51+
#endif
4352

4453
externCost_cpu_page_wight_;
4554
externCost_cpu_index_page_wight_;
@@ -48,7 +57,11 @@ extern int32 _use_geqo_rels_;
4857
externbool_use_right_sided_plans_;
4958
externbool_use_keyset_query_optimizer;
5059

51-
/*-----------------------------------------------------------------------*/
60+
/*
61+
*
62+
* Get_Token
63+
*
64+
*/
5265
staticconstchar*
5366
get_token(char**tok,char**val,constchar*str)
5467
{
@@ -149,7 +162,11 @@ get_token(char **tok, char **val, const char *str)
149162
returnstr;
150163
}
151164

152-
/*-----------------------------------------------------------------------*/
165+
/*
166+
*
167+
* GEQO
168+
*
169+
*/
153170
staticbool
154171
parse_geqo(constchar*value)
155172
{
@@ -221,6 +238,11 @@ reset_geqo(void)
221238
return TRUE;
222239
}
223240

241+
/*
242+
*
243+
* R_PLANS
244+
*
245+
*/
224246
staticbool
225247
parse_r_plans(constchar*value)
226248
{
@@ -240,7 +262,6 @@ parse_r_plans(const char *value)
240262
return TRUE;
241263
}
242264

243-
/*-----------------------------------------------------------------------*/
244265
staticbool
245266
show_r_plans()
246267
{
@@ -264,7 +285,11 @@ reset_r_plans()
264285
return TRUE;
265286
}
266287

267-
/*-----------------------------------------------------------------------*/
288+
/*
289+
*
290+
* COST_HEAP
291+
*
292+
*/
268293
staticbool
269294
parse_cost_heap(constchar*value)
270295
{
@@ -297,7 +322,11 @@ reset_cost_heap()
297322
return TRUE;
298323
}
299324

300-
/*-----------------------------------------------------------------------*/
325+
/*
326+
*
327+
* COST_INDEX
328+
*
329+
*/
301330
staticbool
302331
parse_cost_index(constchar*value)
303332
{
@@ -330,7 +359,11 @@ reset_cost_index()
330359
return TRUE;
331360
}
332361

333-
/*-----------------------------------------------------------------------*/
362+
/*
363+
*
364+
* DATE_STYLE
365+
*
366+
*/
334367
staticbool
335368
parse_date(constchar*value)
336369
{
@@ -448,6 +481,11 @@ static char *defaultTZ = NULL;
448481
staticcharTZvalue[64];
449482
staticchartzbuf[64];
450483

484+
/*
485+
*
486+
* TIMEZONE
487+
*
488+
*/
451489
/* parse_timezone()
452490
* Handle SET TIME ZONE...
453491
* Try to save existing TZ environment variable for later use in RESET TIME ZONE.
@@ -545,7 +583,53 @@ reset_timezone()
545583
return TRUE;
546584
}/* reset_timezone() */
547585

586+
/*
587+
*
588+
* Query_limit
589+
*
590+
*/
591+
#ifdefQUERY_LIMIT
592+
staticbool
593+
parse_query_limit(constchar*value)
594+
{
595+
int32limit;
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+
staticbool
610+
show_query_limit(void)
611+
{
612+
intlimit;
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+
staticbool
624+
reset_query_limit(void)
625+
{
626+
ExecutorLimit(ALL_TUPLES);
627+
return(TRUE);
628+
}
629+
#endif
630+
548631
/*-----------------------------------------------------------------------*/
632+
549633
structVariableParsers
550634
{
551635
constchar*name;
@@ -584,6 +668,11 @@ struct VariableParsers
584668
{
585669
"ksqo",parse_ksqo,show_ksqo,reset_ksqo
586670
},
671+
#ifdefQUERY_LIMIT
672+
{
673+
"query_limit",parse_query_limit,show_query_limit,reset_query_limit
674+
},
675+
#endif
587676
{
588677
NULL,NULL,NULL,NULL
589678
}

‎src/backend/executor/execMain.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.57 1998/10/01 02:03:58 tgl Exp $
29+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.58 1998/10/14 05:10:00 momjian Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -83,14 +83,18 @@ static intqueryLimit = ALL_TUPLES;
8383
#undef ALL_TUPLES
8484
#defineALL_TUPLES queryLimit
8585

86-
intExecutorLimit(intlimit);
87-
8886
int
8987
ExecutorLimit(intlimit)
9088
{
9189
returnqueryLimit=limit;
9290
}
9391

92+
int
93+
ExecutorGetLimit()
94+
{
95+
returnqueryLimit;
96+
}
97+
9498
#endif
9599

96100
/* ----------------------------------------------------------------

‎src/bin/psql/psqlHelp.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: psqlHelp.h,v 1.53 1998/10/08 01:10:28 tgl Exp $
8+
* $Id: psqlHelp.h,v 1.54 1998/10/14 05:10:02 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -296,10 +296,10 @@ static struct _helpStruct QL_HELP[] = {
296296
"set run-time environment back to default",
297297
#ifdefMULTIBYTE
298298
"\
299-
\tRESET DateStyle|GEQO|R_PLANS|CLIENT_ENCODING"},
299+
\tRESET DateStyle|GEQO|R_PLANS|QUERY_LIMIT|CLIENT_ENCODING"},
300300
#else
301301
"\
302-
\tRESET DateStyle|GEQO|R_PLANS"},
302+
\tRESET DateStyle|GEQO|R_PLANS|QUERY_LIMIT"},
303303
#endif
304304
{"revoke",
305305
"revoke access control from a user or group",
@@ -329,21 +329,23 @@ static struct _helpStruct QL_HELP[] = {
329329
\tSET DateStyle TO 'ISO'|'SQL'|'Postgres'|'European'|'US'|'NonEuropean'\n\
330330
set GEQO TO 'ON[=#]'|'OFF'\n\
331331
set R_PLANS TO 'ON'|'OFF'\n\
332+
set QUERY_LIMIT TO #\n\
332333
set CLIENT_ENCODING TO 'EUC_JP'|'SJIS'|'EUC_CN'|'EUC_KR'|'EUC_TW'|'MULE_INTERNAL'|'LATIN1'|'LATIN2'|'LATIN3'|'LATIN4'|'LATIN5'"},
333334
#else
334335
"\
335336
\tSET DateStyle TO 'ISO'|'SQL'|'Postgres'|'European'|'US'|'NonEuropean'\n\
336337
set GEQO TO 'ON[=#]'|'OFF'\n\
337-
set R_PLANS TO 'ON'| 'OFF'"},
338+
set R_PLANS TO 'ON'| 'OFF'\n\
339+
set QUERY_LIMIT TO #"},
338340
#endif
339341
{"show",
340342
"show current run-time environment",
341343
#ifdefMULTIBYTE
342344
"\
343-
\tSHOW DateStyle|GEQO|R_PLANS|CLIENT_ENCODING"},
345+
\tSHOW DateStyle|GEQO|R_PLANS|QUERY_LIMIT|CLIENT_ENCODING"},
344346
#else
345347
"\
346-
\tSHOW DateStyle|GEQO|R_PLANS"},
348+
\tSHOW DateStyle|GEQO|R_PLANS|QUERY_LIMIT"},
347349
#endif
348350
{"unlisten",
349351
"stop listening for notification on a condition name",

‎src/include/executor/executor.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: executor.h,v 1.26 1998/10/08 18:30:29 momjian Exp $
9+
* $Id: executor.h,v 1.27 1998/10/14 05:10:05 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -86,6 +86,10 @@ extern TupleDesc ExecutorStart(QueryDesc *queryDesc, EState *estate);
8686
externTupleTableSlot*ExecutorRun(QueryDesc*queryDesc,EState*estate,intfeature,intcount);
8787
externvoidExecutorEnd(QueryDesc*queryDesc,EState*estate);
8888
externHeapTupleExecConstraints(char*caller,Relationrel,HeapTupletuple);
89+
#ifdefQUERY_LIMIT
90+
externintExecutorLimit(intlimit);
91+
externintExecutorGetLimit(void);
92+
#endif
8993

9094
/*
9195
* prototypes from functions in execProcnode.c

‎src/man/set.l

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" This is -*-nroff-*-
22
.\" XXX standard disclaimer belongs here....
3-
.\" $Header: /cvsroot/pgsql/src/man/Attic/set.l,v 1.10 1998/10/1402:36:44 momjian Exp $
3+
.\" $Header: /cvsroot/pgsql/src/man/Attic/set.l,v 1.11 1998/10/1405:10:12 momjian Exp $
44
.TH SET SQL 05/14/97 PostgreSQL PostgreSQL
55
.SH NAME
66
set - set run-time parameters for session
@@ -76,6 +76,12 @@ by default. It's not used by GEQO anyway.
7676
off- do not use right-hand plan evaluation
7777
.fi
7878

79+
.PP
80+
.IR QUERY_LIMIT
81+
restricts the number of rows returned by a query.
82+
The default is unlimited.
83+
84+
7985
.SH EXAMPLES
8086
.nf
8187
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp