mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.51 2002/12/30 22:10:54 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.52 2003/03/10 03:53:51 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -33,16 +33,25 @@
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "executor/executor.h"
|
||||
#include "utils/hsearch.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/portal.h"
|
||||
|
||||
|
||||
/*
|
||||
* estimate of the maximum number of open portals a user would have,
|
||||
* used in initially sizing the PortalHashTable in EnablePortalManager()
|
||||
*/
|
||||
#define PORTALS_PER_USER 64
|
||||
|
||||
|
||||
/* ----------------
|
||||
* Global state
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
#define MAX_PORTALNAME_LEN 64
|
||||
#define MAX_PORTALNAME_LEN NAMEDATALEN
|
||||
|
||||
typedef struct portalhashent
|
||||
{
|
||||
@@ -158,7 +167,8 @@ PortalSetQuery(Portal portal,
|
||||
AssertArg(PortalIsValid(portal));
|
||||
|
||||
portal->queryDesc = queryDesc;
|
||||
portal->atStart = true; /* Allow fetch forward only */
|
||||
portal->backwardOK = ExecSupportsBackwardScan(queryDesc->plantree);
|
||||
portal->atStart = true; /* Allow fetch forward only, to start */
|
||||
portal->atEnd = false;
|
||||
portal->cleanup = cleanup;
|
||||
}
|
||||
@@ -201,6 +211,7 @@ CreatePortal(const char *name)
|
||||
|
||||
/* initialize portal query */
|
||||
portal->queryDesc = NULL;
|
||||
portal->backwardOK = false;
|
||||
portal->atStart = true; /* disallow fetches until query is set */
|
||||
portal->atEnd = true;
|
||||
portal->cleanup = NULL;
|
||||
|
||||
Reference in New Issue
Block a user