]> granicus.if.org Git - postgresql/blob - src/include/nodes/plannodes.h
Add typdefs to pgindent run.
[postgresql] / src / include / nodes / plannodes.h
1 /*-------------------------------------------------------------------------
2  *
3  * plannodes.h--
4  *        definitions for query plan nodes
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: plannodes.h,v 1.9 1997/09/08 20:58:48 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef PLANNODES_H
14 #define PLANNODES_H
15
16 #include <nodes/execnodes.h>
17
18 /* ----------------------------------------------------------------
19  *      Executor State types are used in the plannode structures
20  *      so we have to include their definitions too.
21  *
22  *              Node Type                               node information used by executor
23  *
24  * control nodes
25  *
26  *              Existential                             ExistentialState                exstate;
27  *              Result                                  ResultState                             resstate;
28  *              Append                                  AppendState                             unionstate;
29  *
30  * scan nodes
31  *
32  *              Scan ***                                CommonScanState                 scanstate;
33  *              IndexScan                               IndexScanState                  indxstate;
34  *
35  *                (*** nodes which inherit Scan also inherit scanstate)
36  *
37  * join nodes
38  *
39  *              NestLoop                                NestLoopState                   nlstate;
40  *              MergeJoin                               MergeJoinState                  mergestate;
41  *              HashJoin                                HashJoinState                   hashjoinstate;
42  *
43  * materialize nodes
44  *
45  *              Material                                MaterialState                   matstate;
46  *              Sort                                    SortState                               sortstate;
47  *              Unique                                  UniqueState                             uniquestate;
48  *              Hash                                    HashState                               hashstate;
49  *
50  * ----------------------------------------------------------------
51  */
52
53
54 /* ----------------------------------------------------------------
55  *                                              node definitions
56  * ----------------------------------------------------------------
57  */
58
59 /* ----------------
60  *              Plan node
61  * ----------------
62  */
63
64 typedef struct Plan
65 {
66         NodeTag         type;
67         Cost            cost;
68         int                     plan_size;
69         int                     plan_width;
70         int                     plan_tupperpage;
71         EState     *state;                      /* at execution time, state's of
72                                                                  * individual nodes point to one EState
73                                                                  * for the whole top-level plan */
74         List       *targetlist;
75         List       *qual;                       /* Node* or List* ?? */
76         struct Plan *lefttree;
77         struct Plan *righttree;
78 }                       Plan;
79
80 /* ----------------
81  *      these are are defined to avoid confusion problems with "left"
82  *      and "right" and "inner" and "outer".  The convention is that
83  *      the "left" plan is the "outer" plan and the "right" plan is
84  *      the inner plan, but these make the code more readable.
85  * ----------------
86  */
87 #define innerPlan(node)                 (((Plan *)(node))->righttree)
88 #define outerPlan(node)                 (((Plan *)(node))->lefttree)
89
90
91 /*
92  * ===============
93  * Top-level nodes
94  * ===============
95  */
96
97 /* all plan nodes "derive" from the Plan structure by having the
98    Plan structure as the first field.  This ensures that everything works
99    when nodes are cast to Plan's.  (node pointers are frequently cast to Plan*
100    when passed around generically in the executor */
101
102
103 /* ----------------
104  *              existential node
105  * ----------------
106  */
107 typedef Plan Existential;
108
109 /* ----------------
110  *       result node -
111  *              returns tuples from outer plan that satisfy the qualifications
112  * ----------------
113  */
114 typedef struct Result
115 {
116         Plan            plan;
117         Node       *resconstantqual;
118         ResultState *resstate;
119 }                       Result;
120
121 /* ----------------
122  *              append node
123  * ----------------
124  */
125 typedef struct Append
126 {
127         Plan            plan;
128         List       *unionplans;
129         Index           unionrelid;
130         List       *unionrtentries;
131         AppendState *unionstate;
132 } Append;
133
134 /*
135  * ==========
136  * Scan nodes
137  * ==========
138  */
139 typedef struct Scan
140 {
141         Plan            plan;
142         Index           scanrelid;              /* relid is index into the range table */
143         CommonScanState *scanstate;
144 }                       Scan;
145
146 /* ----------------
147  *              sequential scan node
148  * ----------------
149  */
150 typedef Scan SeqScan;
151
152 /* ----------------
153  *              index scan node
154  * ----------------
155  */
156 typedef struct IndexScan
157 {
158         Scan            scan;
159         List       *indxid;
160         List       *indxqual;
161         IndexScanState *indxstate;
162 }                       IndexScan;
163
164 /*
165  * ==========
166  * Join nodes
167  * ==========
168  */
169
170 /* ----------------
171  *              Join node
172  * ----------------
173  */
174 typedef Plan Join;
175
176 /* ----------------
177  *              nest loop join node
178  * ----------------
179  */
180 typedef struct NestLoop
181 {
182         Join            join;
183         NestLoopState *nlstate;
184 }                       NestLoop;
185
186 /* ----------------
187  *              merge join node
188  * ----------------
189  */
190 typedef struct MergeJoin
191 {
192         Join            join;
193         List       *mergeclauses;
194         Oid                     mergesortop;
195         Oid                *mergerightorder;/* inner sort operator */
196         Oid                *mergeleftorder; /* outer sort operator */
197         MergeJoinState *mergestate;
198 }                       MergeJoin;
199
200 /* ----------------
201  *              hash join (probe) node
202  * ----------------
203  */
204 typedef struct HashJoin
205 {
206         Join            join;
207         List       *hashclauses;
208         Oid                     hashjoinop;
209         HashJoinState *hashjoinstate;
210         HashJoinTable hashjointable;
211         IpcMemoryKey hashjointablekey;
212         int                     hashjointablesize;
213         bool            hashdone;
214 }                       HashJoin;
215
216 /* ---------------
217  *              aggregate node
218  * ---------------
219  */
220 typedef struct Agg
221 {
222         Plan            plan;
223         int                     numAgg;
224         Aggreg    **aggs;
225         AggState   *aggstate;
226 } Agg;
227
228 /* ---------------
229  *       group node -
230  *              use for queries with GROUP BY specified.
231  *
232  *              If tuplePerGroup is true, one tuple (with group columns only) is
233  *              returned for each group and NULL is returned when there are no more
234  *              groups. Otherwise, all the tuples of a group are returned with a
235  *              NULL returned at the end of each group. (see nodeGroup.c for details)
236  * ---------------
237  */
238 typedef struct Group
239 {
240         Plan            plan;
241         bool            tuplePerGroup;  /* what tuples to return (see above) */
242         int                     numCols;                /* number of group columns */
243         AttrNumber *grpColIdx;          /* index into the target list */
244         GroupState *grpstate;
245 }                       Group;
246
247 /*
248  * ==========
249  * Temp nodes
250  * ==========
251  */
252 typedef struct Temp
253 {
254         Plan            plan;
255         Oid                     tempid;
256         int                     keycount;
257 }                       Temp;
258
259 /* ----------------
260  *              materialization node
261  * ----------------
262  */
263 typedef struct Material
264 {
265         Plan            plan;                   /* temp node flattened out */
266         Oid                     tempid;
267         int                     keycount;
268         MaterialState *matstate;
269 }                       Material;
270
271 /* ----------------
272  *              sort node
273  * ----------------
274  */
275 typedef struct Sort
276 {
277         Plan            plan;                   /* temp node flattened out */
278         Oid                     tempid;
279         int                     keycount;
280         SortState  *sortstate;
281         void       *psortstate;
282         bool            cleaned;
283 }                       Sort;
284
285 /* ----------------
286  *              unique node
287  * ----------------
288  */
289 typedef struct Unique
290 {
291         Plan            plan;                   /* temp node flattened out */
292         Oid                     tempid;
293         int                     keycount;
294         char       *uniqueAttr;         /* NULL if all attrs, or unique attribute
295                                                                  * name */
296         AttrNumber      uniqueAttrNum;  /* attribute number of attribute to select
297                                                                  * distinct on */
298         UniqueState *uniquestate;
299 }                       Unique;
300
301 /* ----------------
302  *              hash build node
303  * ----------------
304  */
305 typedef struct Hash
306 {
307         Plan            plan;
308         Var                *hashkey;
309         HashState  *hashstate;
310         HashJoinTable hashtable;
311         IpcMemoryKey hashtablekey;
312         int                     hashtablesize;
313 }                       Hash;
314
315 /* ---------------------
316  *              choose node
317  * ---------------------
318  */
319 typedef struct Choose
320 {
321         Plan            plan;
322         List       *chooseplanlist;
323 }                       Choose;
324
325 /* -------------------
326  *              Tee node information
327  *
328  *        leftParent :                          the left parent of this node
329  *        rightParent:                          the right parent of this node
330  * -------------------
331 */
332 typedef struct Tee
333 {
334         Plan            plan;
335         Plan       *leftParent;
336         Plan       *rightParent;
337         TeeState   *teestate;
338         char       *teeTableName;       /* the name of the table to materialize
339                                                                  * the tee into */
340         List       *rtentries;          /* the range table for the plan below the
341                                                                  * Tee may be different than the parent
342                                                                  * plans */
343 }                       Tee;
344
345 #endif                                                  /* PLANNODES_H */