summaryrefslogtreecommitdiff
path: root/src/include/nodes
diff options
context:
space:
mode:
authorTom Lane2002-11-22 22:10:01 +0000
committerTom Lane2002-11-22 22:10:01 +0000
commite760d22391635d550afcf41799411c04f20fd031 (patch)
tree8a3ef0a570e3d21d5491c38698bd493caf627010 /src/include/nodes
parent95c9c22633f291e0f78a35614847fc80c87d0880 (diff)
Redesign internal logic of nodeLimit so that it does not need to fetch
one more row from the subplan than the COUNT would appear to require. This costs a little more logic but a number of people have complained about the old implementation.
Diffstat (limited to 'src/include/nodes')
-rw-r--r--src/include/nodes/execnodes.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index f955815926d..c9781b7255f 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execnodes.h,v 1.78 2002/11/15 02:50:10 momjian Exp $
+ * $Id: execnodes.h,v 1.79 2002/11/22 22:10:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -775,17 +775,28 @@ typedef struct SetOpState
* offset is the number of initial tuples to skip (0 does nothing).
* count is the number of tuples to return after skipping the offset tuples.
* If no limit count was specified, count is undefined and noCount is true.
+ * When lstate == LIMIT_INITIAL, offset/count/noCount haven't been set yet.
* ----------------
*/
+typedef enum
+{
+ LIMIT_INITIAL, /* initial state for LIMIT node */
+ LIMIT_EMPTY, /* there are no returnable rows */
+ LIMIT_INWINDOW, /* have returned a row in the window */
+ LIMIT_SUBPLANEOF, /* at EOF of subplan (within window) */
+ LIMIT_WINDOWEND, /* stepped off end of window */
+ LIMIT_WINDOWSTART /* stepped off beginning of window */
+} LimitStateCond;
+
typedef struct LimitState
{
CommonState cstate; /* its first field is NodeTag */
long offset; /* current OFFSET value */
long count; /* current COUNT, if any */
- long position; /* 1-based index of last tuple fetched */
- bool parmsSet; /* have we calculated offset/limit yet? */
bool noCount; /* if true, ignore count */
- bool atEnd; /* if true, we've reached EOF of subplan */
+ LimitStateCond lstate; /* state machine status, as above */
+ long position; /* 1-based index of last tuple returned */
+ TupleTableSlot *subSlot; /* tuple last obtained from subplan */
} LimitState;