1 /*-------------------------------------------------------------------------
4 * POSTGRES portal definitions.
7 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: portal.h,v 1.31 2001/11/05 17:46:36 momjian Exp $
12 *-------------------------------------------------------------------------
16 * A portal is an abstraction which represents the execution state of
17 * a running query (specifically, a CURSOR).
22 #include "executor/execdesc.h"
23 #include "nodes/memnodes.h"
26 typedef struct PortalData *Portal;
28 typedef struct PortalData
30 char *name; /* Portal's name */
31 MemoryContext heap; /* subsidiary memory */
32 QueryDesc *queryDesc; /* Info about query associated with portal */
34 EState *state; /* Execution state of query */
35 bool atStart; /* T => fetch backwards is not allowed */
36 bool atEnd; /* T => fetch forwards is not allowed */
37 void (*cleanup) (Portal); /* Cleanup routine (optional) */
42 * True iff portal is valid.
44 #define PortalIsValid(p) PointerIsValid(p)
47 * Access macros for Portal ... use these in preference to field access.
49 #define PortalGetQueryDesc(portal) ((portal)->queryDesc)
50 #define PortalGetTupleDesc(portal) ((portal)->attinfo)
51 #define PortalGetState(portal) ((portal)->state)
52 #define PortalGetHeapMemory(portal) ((portal)->heap)
55 * estimate of the maximum number of open portals a user would have,
56 * used in initially sizing the PortalHashTable in EnablePortalManager()
58 #define PORTALS_PER_USER 64
61 extern void EnablePortalManager(void);
62 extern void AtEOXact_portals(void);
63 extern Portal CreatePortal(char *name);
64 extern void PortalDrop(Portal portal);
65 extern Portal GetPortalByName(char *name);
66 extern void PortalSetQuery(Portal portal, QueryDesc *queryDesc,
67 TupleDesc attinfo, EState *state,
68 void (*cleanup) (Portal portal));