]> granicus.if.org Git - postgresql/blob - src/include/utils/portal.h
Massive commit to run PGINDENT on all *.c and *.h files.
[postgresql] / src / include / utils / portal.h
1 /*-------------------------------------------------------------------------
2  *
3  * portal.h--
4  *        POSTGRES portal definitions.
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: portal.h,v 1.5 1997/09/07 05:02:51 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 /*
14  * Note:
15  *              A portal is an abstraction which represents the execution state of
16  * a running query (or a fixed sequence of queries).  The "blank portal" is
17  * a portal with an InvalidName.  This blank portal is in existance except
18  * between calls to BlankPortalAssignName and GetPortalByName(NULL).
19  *
20  * Note:
21  *              now that PQ calls can be made from within a backend, a portal
22  *              may also be used to keep track of the tuples resulting
23  *              from the execution of a query.  In this case, entryIndex
24  */
25 #ifndef PORTAL_H
26 #define PORTAL_H
27
28 #include <executor/execdesc.h>
29 #include <lib/fstack.h>
30 #include <nodes/memnodes.h>
31 #include <utils/memutils.h>
32
33 typedef struct PortalBlockData
34 {
35         AllocSetData    setData;
36         FixedItemData   itemData;
37 }                               PortalBlockData;
38
39 typedef PortalBlockData *PortalBlock;
40
41 typedef struct PortalD PortalD;
42 typedef PortalD *Portal;
43
44 struct PortalD
45 {
46         char               *name;               /* XXX PortalName */
47         struct PortalVariableMemory variable;
48         struct PortalHeapMemory heap;
49         QueryDesc          *queryDesc;
50         TupleDesc               attinfo;
51         EState             *state;
52         void                    (*cleanup) (Portal);
53 };
54
55 /*
56  * PortalIsValid --
57  *              True iff portal is valid.
58  */
59 #define PortalIsValid(p) PointerIsValid(p)
60
61 /*
62  * Special portals (well, their names anyway)
63  */
64 #define VACPNAME                "<vacuum>"
65
66 extern bool             PortalNameIsSpecial(char *pname);
67 extern void             AtEOXact_portals(void);
68 extern void             EnablePortalManager(bool on);
69 extern Portal   GetPortalByName(char *name);
70 extern Portal   BlankPortalAssignName(char *name);
71 extern void
72 PortalSetQuery(Portal portal, QueryDesc * queryDesc,
73                            TupleDesc attinfo, EState * state,
74                            void (*cleanup) (Portal portal));
75 extern QueryDesc *PortalGetQueryDesc(Portal portal);
76 extern EState  *PortalGetState(Portal portal);
77 extern Portal   CreatePortal(char *name);
78 extern void             PortalDestroy(Portal * portalP);
79 extern void             StartPortalAllocMode(AllocMode mode, Size limit);
80 extern void             EndPortalAllocMode(void);
81 extern PortalVariableMemory PortalGetVariableMemory(Portal portal);
82 extern PortalHeapMemory PortalGetHeapMemory(Portal portal);
83
84 /* estimate of the maximum number of open portals a user would have,
85  * used in initially sizing the PortalHashTable in      EnablePortalManager()
86  */
87 #define PORTALS_PER_USER           10
88
89
90 #endif                                                  /* PORTAL_H */