From 2f35b4efdbec6c161ca9bd491d6345134910c425 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 26 Oct 2000 21:38:24 +0000 Subject: Re-implement LIMIT/OFFSET as a plan node type, instead of a hack in ExecutorRun. This allows LIMIT to work in a view. Also, LIMIT in a cursor declaration will behave in a reasonable fashion, whereas before it was overridden by the FETCH count. --- src/backend/utils/adt/ruleutils.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/adt/ruleutils.c') diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 7ab3985f3e7..70dfe9706bc 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.66 2000/10/05 21:52:08 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.67 2000/10/26 21:37:45 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -886,8 +886,8 @@ get_select_query_def(Query *query, deparse_context *context) /* ---------- * If the Query node has a setOperations tree, then it's the top - * level of a UNION/INTERSECT/EXCEPT query; only the ORDER BY field - * is interesting in the top query itself. + * level of a UNION/INTERSECT/EXCEPT query; only the ORDER BY and + * LIMIT fields are interesting in the top query itself. * ---------- */ if (query->setOperations) @@ -931,6 +931,18 @@ get_select_query_def(Query *query, deparse_context *context) sep = ", "; } } + + /* Add the LIMIT clause if given */ + if (query->limitOffset != NULL) + { + appendStringInfo(buf, " OFFSET "); + get_rule_expr(query->limitOffset, context); + } + if (query->limitCount != NULL) + { + appendStringInfo(buf, " LIMIT "); + get_rule_expr(query->limitCount, context); + } } static void -- cgit v1.2.3