The frontend may be initialized by setting the PGRPLANS
environment variable.
+<varlistentry>
+<term>
+QUERY_LIMIT
+</term>
+<listitem>
+<para>
+Sets the number of rows returned by a query.
+
+<variablelist>
+<varlistentry>
+<term>
+Value
+</term>
+<listitem>
+<para>
+Maximum number of rows to return for a query. The default is unlimited.
+<varlistentry>
+<term>
+<replaceable class="parameter">#</replaceable>
+</term>
+<listitem>
+<para>
+Sets the maximum number of rows returned by a
+query to <replaceable class="parameter">#</replaceable>.
+<varlistentry>
+<term>
+DEFAULT
+</term>
+<listitem>
+<para>
+Sets the number of rows returned by a query to unlimited.
+</varlistentry>
+
+<para>
+ By default, there is no limit to the number of rows
+ returned by a query.
+</variablelist>
+
</VARLISTENTRY>
</VARIABLELIST>
</REFSECT2>
* Routines for handling of 'SET var TO',
* 'SHOW var' and 'RESET var' statements.
*
- * $Id: variable.c,v 1.15 1998/10/08 23:50:28 tgl Exp $
+ * $Id: variable.c,v 1.16 1998/10/14 05:09:58 momjian Exp $
*
*/
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
+#ifdef QUERY_LIMIT
+#include "executor/executor.h"
+#include "executor/execdefs.h"
+#endif
static bool show_date(void);
static bool reset_date(void);
static bool show_ksqo(void);
static bool reset_ksqo(void);
static bool parse_ksqo(const char *);
+#ifdef QUERY_LIMIT
+static bool show_query_limit(void);
+static bool reset_query_limit(void);
+static bool parse_query_limit(const char *);
+#endif
extern Cost _cpu_page_wight_;
extern Cost _cpu_index_page_wight_;
extern bool _use_right_sided_plans_;
extern bool _use_keyset_query_optimizer;
-/*-----------------------------------------------------------------------*/
+/*
+ *
+ * Get_Token
+ *
+ */
static const char *
get_token(char **tok, char **val, const char *str)
{
return str;
}
-/*-----------------------------------------------------------------------*/
+/*
+ *
+ * GEQO
+ *
+ */
static bool
parse_geqo(const char *value)
{
return TRUE;
}
+/*
+ *
+ * R_PLANS
+ *
+ */
static bool
parse_r_plans(const char *value)
{
return TRUE;
}
-/*-----------------------------------------------------------------------*/
static bool
show_r_plans()
{
return TRUE;
}
-/*-----------------------------------------------------------------------*/
+/*
+ *
+ * COST_HEAP
+ *
+ */
static bool
parse_cost_heap(const char *value)
{
return TRUE;
}
-/*-----------------------------------------------------------------------*/
+/*
+ *
+ * COST_INDEX
+ *
+ */
static bool
parse_cost_index(const char *value)
{
return TRUE;
}
-/*-----------------------------------------------------------------------*/
+/*
+ *
+ * DATE_STYLE
+ *
+ */
static bool
parse_date(const char *value)
{
static char TZvalue[64];
static char tzbuf[64];
+/*
+ *
+ * TIMEZONE
+ *
+ */
/* parse_timezone()
* Handle SET TIME ZONE...
* Try to save existing TZ environment variable for later use in RESET TIME ZONE.
return TRUE;
} /* reset_timezone() */
+/*
+ *
+ * Query_limit
+ *
+ */
+#ifdef QUERY_LIMIT
+static bool
+parse_query_limit(const char *value)
+{
+ int32 limit;
+
+ if (value == NULL) {
+ reset_query_limit();
+ return(TRUE);
+ }
+ limit = pg_atoi(value, sizeof(int32), '\0');
+ if (limit <= -1) {
+ elog(ERROR, "Bad value for # of query limit (%s)", value);
+ }
+ ExecutorLimit(limit);
+ return(TRUE);
+}
+
+static bool
+show_query_limit(void)
+{
+ int limit;
+
+ limit = ExecutorGetLimit();
+ if (limit == ALL_TUPLES) {
+ elog(NOTICE, "No query limit is set");
+ } else {
+ elog(NOTICE, "query limit is %d",limit);
+ }
+ return(TRUE);
+}
+
+static bool
+reset_query_limit(void)
+{
+ ExecutorLimit(ALL_TUPLES);
+ return(TRUE);
+}
+#endif
+
/*-----------------------------------------------------------------------*/
+
struct VariableParsers
{
const char *name;
{
"ksqo", parse_ksqo, show_ksqo, reset_ksqo
},
+#ifdef QUERY_LIMIT
+ {
+ "query_limit", parse_query_limit, show_query_limit, reset_query_limit
+ },
+#endif
{
NULL, NULL, NULL, NULL
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.57 1998/10/01 02:03:58 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.58 1998/10/14 05:10:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#undef ALL_TUPLES
#define ALL_TUPLES queryLimit
-int ExecutorLimit(int limit);
-
int
ExecutorLimit(int limit)
{
return queryLimit = limit;
}
+int
+ExecutorGetLimit()
+{
+ return queryLimit;
+}
+
#endif
/* ----------------------------------------------------------------
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: psqlHelp.h,v 1.53 1998/10/08 01:10:28 tgl Exp $
+ * $Id: psqlHelp.h,v 1.54 1998/10/14 05:10:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
"set run-time environment back to default",
#ifdef MULTIBYTE
"\
-\tRESET DateStyle|GEQO|R_PLANS|CLIENT_ENCODING"},
+\tRESET DateStyle|GEQO|R_PLANS|QUERY_LIMIT|CLIENT_ENCODING"},
#else
"\
-\tRESET DateStyle|GEQO|R_PLANS"},
+\tRESET DateStyle|GEQO|R_PLANS|QUERY_LIMIT"},
#endif
{"revoke",
"revoke access control from a user or group",
\tSET DateStyle TO 'ISO'|'SQL'|'Postgres'|'European'|'US'|'NonEuropean'\n\
set GEQO TO 'ON[=#]'|'OFF'\n\
set R_PLANS TO 'ON'|'OFF'\n\
+set QUERY_LIMIT TO #\n\
set CLIENT_ENCODING TO 'EUC_JP'|'SJIS'|'EUC_CN'|'EUC_KR'|'EUC_TW'|'MULE_INTERNAL'|'LATIN1'|'LATIN2'|'LATIN3'|'LATIN4'|'LATIN5'"},
#else
"\
\tSET DateStyle TO 'ISO'|'SQL'|'Postgres'|'European'|'US'|'NonEuropean'\n\
set GEQO TO 'ON[=#]'|'OFF'\n\
-set R_PLANS TO 'ON'| 'OFF'"},
+set R_PLANS TO 'ON'| 'OFF'\n\
+set QUERY_LIMIT TO #"},
#endif
{"show",
"show current run-time environment",
#ifdef MULTIBYTE
"\
-\tSHOW DateStyle|GEQO|R_PLANS|CLIENT_ENCODING"},
+\tSHOW DateStyle|GEQO|R_PLANS|QUERY_LIMIT|CLIENT_ENCODING"},
#else
"\
-\tSHOW DateStyle|GEQO|R_PLANS"},
+\tSHOW DateStyle|GEQO|R_PLANS|QUERY_LIMIT"},
#endif
{"unlisten",
"stop listening for notification on a condition name",
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: executor.h,v 1.26 1998/10/08 18:30:29 momjian Exp $
+ * $Id: executor.h,v 1.27 1998/10/14 05:10:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, int count);
extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate);
extern HeapTuple ExecConstraints(char *caller, Relation rel, HeapTuple tuple);
+#ifdef QUERY_LIMIT
+extern int ExecutorLimit(int limit);
+extern int ExecutorGetLimit(void);
+#endif
/*
* prototypes from functions in execProcnode.c
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/set.l,v 1.10 1998/10/14 02:36:44 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/set.l,v 1.11 1998/10/14 05:10:12 momjian Exp $
.TH SET SQL 05/14/97 PostgreSQL PostgreSQL
.SH NAME
set - set run-time parameters for session
off - do not use right-hand plan evaluation
.fi
+.PP
+.IR QUERY_LIMIT
+restricts the number of rows returned by a query.
+The default is unlimited.
+
+
.SH EXAMPLES
.nf
--