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/executor/spi.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/executor/spi.c')
-rw-r--r-- | src/backend/executor/spi.c | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 1ab6ae67d50..07a05561a64 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -3,7 +3,7 @@ * spi.c * Server Programming Interface * - * $Id: spi.c,v 1.47 2000/06/28 03:31:34 tgl Exp $ + * $Id: spi.c,v 1.48 2000/10/26 21:35:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -762,8 +762,6 @@ _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount) bool isRetrieveIntoRelation = false; char *intoName = NULL; int res; - Const tcount_const; - Node *count = NULL; switch (operation) { @@ -798,39 +796,6 @@ _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount) return SPI_ERROR_OPUNKNOWN; } - /* ---------------- - * Get the query LIMIT tuple count - * ---------------- - */ - if (parseTree->limitCount != NULL) - { - /* ---------------- - * A limit clause in the parsetree overrides the - * tcount parameter - * ---------------- - */ - count = parseTree->limitCount; - } - else - { - /* ---------------- - * No LIMIT clause in parsetree. Use a local Const node - * to put tcount into it - * ---------------- - */ - memset(&tcount_const, 0, sizeof(tcount_const)); - tcount_const.type = T_Const; - tcount_const.consttype = INT4OID; - tcount_const.constlen = sizeof(int4); - tcount_const.constvalue = (Datum) tcount; - tcount_const.constisnull = FALSE; - tcount_const.constbyval = TRUE; - tcount_const.constisset = FALSE; - tcount_const.constiscast = FALSE; - - count = (Node *) &tcount_const; - } - if (state == NULL) /* plan preparation */ return res; #ifdef SPI_EXECUTOR_STATS @@ -848,7 +813,7 @@ _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount) elog(FATAL, "SPI_select: retrieve into portal not implemented"); } - ExecutorRun(queryDesc, state, EXEC_FOR, parseTree->limitOffset, count); + ExecutorRun(queryDesc, state, EXEC_FOR, (long) tcount); _SPI_current->processed = state->es_processed; if (operation == CMD_SELECT && queryDesc->dest == SPI) |