diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-03-10 03:53:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-03-10 03:53:52 +0000 |
commit | aa83bc04e089e13f2746ba55720e5993268c46f5 (patch) | |
tree | 1b5c0082e22385789d3581792af4e1a823f835ba /src/include/nodes/parsenodes.h | |
parent | b9e8ffcd5d1a3d45b2f697ea944931f56367c86b (diff) |
Restructure parsetree representation of DECLARE CURSOR: now it's a
utility statement (DeclareCursorStmt) with a SELECT query dangling from
it, rather than a SELECT query with a few unusual fields in it. Add
code to determine whether a planned query can safely be run backwards.
If DECLARE CURSOR specifies SCROLL, ensure that the plan can be run
backwards by adding a Materialize plan node if it can't. Without SCROLL,
you get an error if you try to fetch backwards from a cursor that can't
handle it. (There is still some discussion about what the exact
behavior should be, but this is necessary infrastructure in any case.)
Along the way, make EXPLAIN DECLARE CURSOR work.
Diffstat (limited to 'src/include/nodes/parsenodes.h')
-rw-r--r-- | src/include/nodes/parsenodes.h | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 381c11c3893..c84348ded9e 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.231 2003/02/16 02:30:39 tgl Exp $ + * $Id: parsenodes.h,v 1.232 2003/03/10 03:53:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -38,9 +38,6 @@ typedef enum QuerySource * for further processing by the optimizer * utility statements (i.e. non-optimizable statements) * have the *utilityStmt field set. - * - * we need the isPortal flag because portal names can be null too; can - * get rid of it if we support CURSOR as a commandType. */ typedef struct Query { @@ -54,10 +51,8 @@ typedef struct Query * statement */ int resultRelation; /* target relation (index into rtable) */ - RangeVar *into; /* target relation or portal (cursor) for - * portal just name is meaningful */ - bool isPortal; /* is this a retrieve into portal? */ - bool isBinary; /* binary portal? */ + + RangeVar *into; /* target relation for SELECT INTO */ bool hasAggs; /* has aggregates in tlist or havingQual */ bool hasSubLinks; /* has subquery SubLink */ @@ -597,6 +592,8 @@ typedef struct SelectStmt /* * These fields are used only in "leaf" SelectStmts. + * + * into and intoColNames are a kluge; they belong somewhere else... */ List *distinctClause; /* NULL, list of DISTINCT ON exprs, or * lcons(NIL,NIL) for all (SELECT @@ -611,11 +608,9 @@ typedef struct SelectStmt /* * These fields are used in both "leaf" SelectStmts and upper-level - * SelectStmts. portalname/binary may only be set at the top level. + * SelectStmts. */ List *sortClause; /* sort clause (a list of SortGroupBy's) */ - char *portalname; /* the portal (cursor) to create */ - bool binary; /* a binary (internal) portal? */ Node *limitOffset; /* # of result tuples to skip */ Node *limitCount; /* # of result tuples to return */ List *forUpdate; /* FOR UPDATE clause */ @@ -816,16 +811,6 @@ typedef struct PrivTarget } PrivTarget; /* ---------------------- - * Close Portal Statement - * ---------------------- - */ -typedef struct ClosePortalStmt -{ - NodeTag type; - char *portalname; /* name of the portal (cursor) */ -} ClosePortalStmt; - -/* ---------------------- * Copy Statement * ---------------------- */ @@ -1212,7 +1197,33 @@ typedef struct CommentStmt } CommentStmt; /* ---------------------- - * Fetch Statement + * Declare Cursor Statement + * ---------------------- + */ +#define CURSOR_OPT_BINARY 0x0001 +#define CURSOR_OPT_SCROLL 0x0002 +#define CURSOR_OPT_INSENSITIVE 0x0004 + +typedef struct DeclareCursorStmt +{ + NodeTag type; + char *portalname; /* name of the portal (cursor) */ + int options; /* bitmask of options (see above) */ + Node *query; /* the SELECT query */ +} DeclareCursorStmt; + +/* ---------------------- + * Close Portal Statement + * ---------------------- + */ +typedef struct ClosePortalStmt +{ + NodeTag type; + char *portalname; /* name of the portal (cursor) */ +} ClosePortalStmt; + +/* ---------------------- + * Fetch Statement (also Move) * ---------------------- */ typedef enum FetchDirection |