]> granicus.if.org Git - postgresql/blob - src/include/utils/portal.h
Add TRUNCATE command, with psql help and sgml additions.
[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.19 1999/09/23 17:03:33 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 "nodes/memnodes.h"
30
31 typedef struct PortalBlockData
32 {
33         AllocSetData setData;
34         FixedItemData itemData;
35 } PortalBlockData;
36
37 typedef PortalBlockData *PortalBlock;
38
39 typedef struct PortalD PortalD;
40 typedef PortalD *Portal;
41
42 struct PortalD
43 {
44         char       *name;                       /* XXX PortalName */
45         struct PortalVariableMemoryData variable;
46         struct PortalHeapMemoryData heap;
47         QueryDesc  *queryDesc;
48         TupleDesc       attinfo;
49         EState     *state;
50         void            (*cleanup) (Portal);
51 };
52
53 /*
54  * PortalIsValid
55  *              True iff portal is valid.
56  */
57 #define PortalIsValid(p) PointerIsValid(p)
58
59 /*
60  * Special portals (well, their names anyway)
61  */
62 #define VACPNAME                "<vacuum>"
63 #define TRUNCPNAME              "<truncate>"
64
65 extern bool PortalNameIsSpecial(char *pname);
66 extern void AtEOXact_portals(void);
67 extern void EnablePortalManager(bool on);
68 extern Portal GetPortalByName(char *name);
69 extern Portal BlankPortalAssignName(char *name);
70 extern void PortalSetQuery(Portal portal, QueryDesc *queryDesc,
71                            TupleDesc attinfo, EState *state,
72                            void (*cleanup) (Portal portal));
73 extern QueryDesc *PortalGetQueryDesc(Portal portal);
74 extern EState *PortalGetState(Portal portal);
75 extern Portal CreatePortal(char *name);
76 extern void PortalDestroy(Portal *portalP);
77 extern void StartPortalAllocMode(AllocMode mode, Size limit);
78 extern void EndPortalAllocMode(void);
79 extern void PortalResetHeapMemory(Portal portal);
80 extern PortalVariableMemory PortalGetVariableMemory(Portal portal);
81 extern PortalHeapMemory PortalGetHeapMemory(Portal portal);
82
83 /* estimate of the maximum number of open portals a user would have,
84  * used in initially sizing the PortalHashTable in      EnablePortalManager()
85  */
86 #define PORTALS_PER_USER           10
87
88
89 #endif   /* PORTAL_H */