aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/commands/portalcmds.h10
-rw-r--r--src/include/executor/executor.h3
-rw-r--r--src/include/nodes/parsenodes.h13
-rw-r--r--src/include/utils/portal.h19
4 files changed, 32 insertions, 13 deletions
diff --git a/src/include/commands/portalcmds.h b/src/include/commands/portalcmds.h
index 3f2a4221add..74855ddf605 100644
--- a/src/include/commands/portalcmds.h
+++ b/src/include/commands/portalcmds.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: portalcmds.h,v 1.5 2003/03/10 03:53:51 tgl Exp $
+ * $Id: portalcmds.h,v 1.6 2003/03/11 19:40:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,10 +19,12 @@
extern void PerformCursorOpen(DeclareCursorStmt *stmt, CommandDest dest);
-extern void PerformPortalFetch(char *name, bool forward, long count,
- CommandDest dest, char *completionTag);
+extern void PerformPortalFetch(FetchStmt *stmt, CommandDest dest,
+ char *completionTag);
-extern long DoPortalFetch(Portal portal, bool forward, long count,
+extern long DoPortalFetch(Portal portal,
+ FetchDirection fdirection,
+ long count,
CommandDest dest);
extern void PerformPortalClose(char *name);
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 785d21718b2..40a696e2976 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.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: executor.h,v 1.90 2003/03/10 03:53:51 tgl Exp $
+ * $Id: executor.h,v 1.91 2003/03/11 19:40:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -86,6 +86,7 @@ extern void ExecutorStart(QueryDesc *queryDesc);
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc,
ScanDirection direction, long count);
extern void ExecutorEnd(QueryDesc *queryDesc);
+extern void ExecutorRewind(QueryDesc *queryDesc);
extern void ExecCheckRTPerms(List *rangeTable, CmdType operation);
extern void ExecEndPlan(PlanState *planstate, EState *estate);
extern void ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index c84348ded9e..216ed04c762 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.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: parsenodes.h,v 1.232 2003/03/10 03:53:51 tgl Exp $
+ * $Id: parsenodes.h,v 1.233 2003/03/11 19:40:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1228,16 +1228,21 @@ typedef struct ClosePortalStmt
*/
typedef enum FetchDirection
{
+ /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
FETCH_FORWARD,
- FETCH_BACKWARD
- /* ABSOLUTE someday? */
+ FETCH_BACKWARD,
+ /* for these, howMany indicates a position; only one row is fetched */
+ FETCH_ABSOLUTE,
+ FETCH_RELATIVE
} FetchDirection;
+#define FETCH_ALL LONG_MAX
+
typedef struct FetchStmt
{
NodeTag type;
FetchDirection direction; /* see above */
- long howMany; /* number of rows */
+ long howMany; /* number of rows, or position argument */
char *portalname; /* name of portal (cursor) */
bool ismove; /* TRUE if MOVE */
} FetchStmt;
diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h
index 21469dd52df..c9ca8547ce2 100644
--- a/src/include/utils/portal.h
+++ b/src/include/utils/portal.h
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: portal.h,v 1.38 2003/03/10 03:53:52 tgl Exp $
+ * $Id: portal.h,v 1.39 2003/03/11 19:40:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,10 +27,21 @@ typedef struct PortalData
char *name; /* Portal's name */
MemoryContext heap; /* subsidiary memory */
QueryDesc *queryDesc; /* Info about query associated with portal */
- bool backwardOK; /* is fetch backwards allowed at all? */
- bool atStart; /* T => fetch backwards is not allowed now */
- bool atEnd; /* T => fetch forwards is not allowed now */
void (*cleanup) (Portal); /* Cleanup routine (optional) */
+ bool backwardOK; /* is fetch backwards allowed? */
+ /*
+ * atStart, atEnd and portalPos indicate the current cursor position.
+ * portalPos is zero before the first row, N after fetching N'th row of
+ * query. After we run off the end, portalPos = # of rows in query, and
+ * atEnd is true. If portalPos overflows, set posOverflow (this causes
+ * us to stop relying on its value for navigation). Note that atStart
+ * implies portalPos == 0, but not the reverse (portalPos could have
+ * overflowed).
+ */
+ bool atStart;
+ bool atEnd;
+ bool posOverflow;
+ long portalPos;
} PortalData;
/*