]> granicus.if.org Git - postgresql/blob - src/include/utils/portal.h
New pgindent run with fixes suggested by Tom. Patch manually reviewed,
[postgresql] / src / include / utils / portal.h
1 /*-------------------------------------------------------------------------
2  *
3  * portal.h
4  *        POSTGRES portal definitions.
5  *
6  *
7  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: portal.h,v 1.31 2001/11/05 17:46:36 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 /*
15  * Note:
16  *              A portal is an abstraction which represents the execution state of
17  * a running query (specifically, a CURSOR).
18  */
19 #ifndef PORTAL_H
20 #define PORTAL_H
21
22 #include "executor/execdesc.h"
23 #include "nodes/memnodes.h"
24
25
26 typedef struct PortalData *Portal;
27
28 typedef struct PortalData
29 {
30         char       *name;                       /* Portal's name */
31         MemoryContext heap;                     /* subsidiary memory */
32         QueryDesc  *queryDesc;          /* Info about query associated with portal */
33         TupleDesc       attinfo;
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) */
38 } PortalData;
39
40 /*
41  * PortalIsValid
42  *              True iff portal is valid.
43  */
44 #define PortalIsValid(p) PointerIsValid(p)
45
46 /*
47  * Access macros for Portal ... use these in preference to field access.
48  */
49 #define PortalGetQueryDesc(portal)      ((portal)->queryDesc)
50 #define PortalGetTupleDesc(portal)      ((portal)->attinfo)
51 #define PortalGetState(portal)  ((portal)->state)
52 #define PortalGetHeapMemory(portal)  ((portal)->heap)
53
54 /*
55  * estimate of the maximum number of open portals a user would have,
56  * used in initially sizing the PortalHashTable in EnablePortalManager()
57  */
58 #define PORTALS_PER_USER           64
59
60
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));
69
70 #endif   /* PORTAL_H */