diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-10-26 21:38:24 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-10-26 21:38:24 +0000 |
commit | 2f35b4efdbec6c161ca9bd491d6345134910c425 (patch) | |
tree | 2424351bcc12a8ddf2b716b28f53d2c37c79e507 /src/backend/utils/adt/ruleutils.c | |
parent | c9476bafdb1b97d0d21d92788f93298962145479 (diff) | |
download | postgresql-2f35b4efdbec6c161ca9bd491d6345134910c425.tar.gz postgresql-2f35b4efdbec6c161ca9bd491d6345134910c425.zip |
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.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 18 |
1 files changed, 15 insertions, 3 deletions
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 |