]> granicus.if.org Git - postgresql/blob - src/include/nodes/plannodes.h
Remove no-longer-used fields in Hash and HashJoin nodes.
[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.25 1999/05/18 21:34:26 tgl 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  *              Result                                  ResultState                             resstate;
27  *              Append                                  AppendState                             appendstate;
28  *
29  * scan nodes
30  *
31  *              Scan ***                                CommonScanState                 scanstate;
32  *              IndexScan                               IndexScanState                  indxstate;
33  *
34  *                (*** nodes which inherit Scan also inherit scanstate)
35  *
36  * join nodes
37  *
38  *              NestLoop                                NestLoopState                   nlstate;
39  *              MergeJoin                               MergeJoinState                  mergestate;
40  *              HashJoin                                HashJoinState                   hashjoinstate;
41  *
42  * materialize nodes
43  *
44  *              Material                                MaterialState                   matstate;
45  *              Sort                                    SortState                               sortstate;
46  *              Unique                                  UniqueState                             uniquestate;
47  *              Hash                                    HashState                               hashstate;
48  *
49  * ----------------------------------------------------------------
50  */
51
52
53 /* ----------------------------------------------------------------
54  *                                              node definitions
55  * ----------------------------------------------------------------
56  */
57
58 /* ----------------
59  *              Plan node
60  * ----------------
61  */
62
63 typedef struct Plan
64 {
65         NodeTag         type;
66         Cost            cost;
67         int                     plan_size;
68         int                     plan_width;
69         int                     plan_tupperpage;
70         EState     *state;                      /* at execution time, state's of
71                                                                  * individual nodes point to one EState
72                                                                  * for the whole top-level plan */
73         List       *targetlist;
74         List       *qual;                       /* Node* or List* ?? */
75         struct Plan *lefttree;
76         struct Plan *righttree;
77         List       *extParam;           /* indices of _all_ _external_ PARAM_EXEC
78                                                                  * for this plan in global
79                                                                  * es_param_exec_vals. Params from
80                                                                  * setParam from initPlan-s are not
81                                                                  * included, but their execParam-s are
82                                                                  * here!!! */
83         List       *locParam;           /* someones from setParam-s */
84         List       *chgParam;           /* list of changed ones from the above */
85         List       *initPlan;           /* Init Plan nodes (un-correlated expr
86                                                                  * subselects) */
87         List       *subPlan;            /* Other SubPlan nodes */
88
89         /*
90          * We really need in some TopPlan node to store range table and
91          * resultRelation from Query there and get rid of Query itself from
92          * Executor. Some other stuff like below could be put there, too.
93          */
94         int                     nParamExec;             /* Number of them in entire query. This is
95                                                                  * to get Executor know about how many
96                                                                  * param_exec there are in query plan. */
97 } Plan;
98
99 /* ----------------
100  *      these are are defined to avoid confusion problems with "left"
101  *      and "right" and "inner" and "outer".  The convention is that
102  *      the "left" plan is the "outer" plan and the "right" plan is
103  *      the inner plan, but these make the code more readable.
104  * ----------------
105  */
106 #define innerPlan(node)                 (((Plan *)(node))->righttree)
107 #define outerPlan(node)                 (((Plan *)(node))->lefttree)
108
109
110 /*
111  * ===============
112  * Top-level nodes
113  * ===============
114  */
115
116 /* all plan nodes "derive" from the Plan structure by having the
117    Plan structure as the first field.  This ensures that everything works
118    when nodes are cast to Plan's.  (node pointers are frequently cast to Plan*
119    when passed around generically in the executor */
120
121
122 /* ----------------
123  *       result node -
124  *              returns tuples from outer plan that satisfy the qualifications
125  * ----------------
126  */
127 typedef struct Result
128 {
129         Plan            plan;
130         Node       *resconstantqual;
131         ResultState *resstate;
132 } Result;
133
134 /* ----------------
135  *              append node
136  * ----------------
137  */
138 typedef struct Append
139 {
140         Plan            plan;
141         List       *appendplans;
142         List       *unionrtables;       /* List of range tables, one for each
143                                                                  * union query. */
144         Index           inheritrelid;   /* The range table has to be changed for
145                                                                  * inheritance. */
146         List       *inheritrtable;
147         AppendState *appendstate;
148 } Append;
149
150 /*
151  * ==========
152  * Scan nodes
153  * ==========
154  */
155 typedef struct Scan
156 {
157         Plan            plan;
158         Index           scanrelid;              /* relid is index into the range table */
159         CommonScanState *scanstate;
160 } Scan;
161
162 /* ----------------
163  *              sequential scan node
164  * ----------------
165  */
166 typedef Scan SeqScan;
167
168 /* ----------------
169  *              index scan node
170  * ----------------
171  */
172 typedef struct IndexScan
173 {
174         Scan            scan;
175         List       *indxid;
176         List       *indxqual;
177         List       *indxqualorig;
178         IndexScanState *indxstate;
179 } IndexScan;
180
181 /*
182  * ==========
183  * Join nodes
184  * ==========
185  */
186
187 /* ----------------
188  *              Join node
189  * ----------------
190  */
191 typedef Plan Join;
192
193 /* ----------------
194  *              nest loop join node
195  * ----------------
196  */
197 typedef struct NestLoop
198 {
199         Join            join;
200         NestLoopState *nlstate;
201 } NestLoop;
202
203 /* ----------------
204  *              merge join node
205  * ----------------
206  */
207 typedef struct MergeJoin
208 {
209         Join            join;
210         List       *mergeclauses;
211         MergeJoinState *mergestate;
212 } MergeJoin;
213
214 /* ----------------
215  *              hash join (probe) node
216  * ----------------
217  */
218 typedef struct HashJoin
219 {
220         Join            join;
221         List       *hashclauses;
222         Oid                     hashjoinop;
223         HashJoinState *hashjoinstate;
224         bool            hashdone;
225 } HashJoin;
226
227 /* ---------------
228  *              aggregate node
229  * ---------------
230  */
231 typedef struct Agg
232 {
233         Plan            plan;
234         List       *aggs;
235         AggState   *aggstate;
236 } Agg;
237
238 /* ---------------
239  *       group node -
240  *              use for queries with GROUP BY specified.
241  *
242  *              If tuplePerGroup is true, one tuple (with group columns only) is
243  *              returned for each group and NULL is returned when there are no more
244  *              groups. Otherwise, all the tuples of a group are returned with a
245  *              NULL returned at the end of each group. (see nodeGroup.c for details)
246  * ---------------
247  */
248 typedef struct Group
249 {
250         Plan            plan;
251         bool            tuplePerGroup;  /* what tuples to return (see above) */
252         int                     numCols;                /* number of group columns */
253         AttrNumber *grpColIdx;          /* index into the target list */
254         GroupState *grpstate;
255 } Group;
256
257 /*
258  * ==========
259  * Noname nodes
260  * ==========
261  */
262 typedef struct Noname
263 {
264         Plan            plan;
265         Oid                     nonameid;
266         int                     keycount;
267 } Noname;
268
269 /* ----------------
270  *              materialization node
271  * ----------------
272  */
273 typedef struct Material
274 {
275         Plan            plan;                   /* noname node flattened out */
276         Oid                     nonameid;
277         int                     keycount;
278         MaterialState *matstate;
279 } Material;
280
281 /* ----------------
282  *              sort node
283  * ----------------
284  */
285 typedef struct Sort
286 {
287         Plan            plan;                   /* noname node flattened out */
288         Oid                     nonameid;
289         int                     keycount;
290         SortState  *sortstate;
291         void       *psortstate;
292         bool            cleaned;
293 } Sort;
294
295 /* ----------------
296  *              unique node
297  * ----------------
298  */
299 typedef struct Unique
300 {
301         Plan            plan;                   /* noname node flattened out */
302         Oid                     nonameid;
303         int                     keycount;
304         char       *uniqueAttr;         /* NULL if all attrs, or unique attribute
305                                                                  * name */
306         AttrNumber      uniqueAttrNum;  /* attribute number of attribute to select
307                                                                  * distinct on */
308         UniqueState *uniquestate;
309 } Unique;
310
311 /* ----------------
312  *              hash build node
313  * ----------------
314  */
315 typedef struct Hash
316 {
317         Plan            plan;
318         Var                *hashkey;
319         HashState  *hashstate;
320 } Hash;
321
322 #ifdef NOT_USED
323 /* -------------------
324  *              Tee node information
325  *
326  *        leftParent :                          the left parent of this node
327  *        rightParent:                          the right parent of this node
328  * -------------------
329 */
330 typedef struct Tee
331 {
332         Plan            plan;
333         Plan       *leftParent;
334         Plan       *rightParent;
335         TeeState   *teestate;
336         char       *teeTableName;       /* the name of the table to materialize
337                                                                  * the tee into */
338         List       *rtentries;          /* the range table for the plan below the
339                                                                  * Tee may be different than the parent
340                                                                  * plans */
341 } Tee;
342 #endif
343
344 /* ---------------------
345  *              SubPlan node
346  * ---------------------
347  */
348 typedef struct SubPlan
349 {
350         NodeTag         type;
351         Plan       *plan;                       /* subselect plan itself */
352         int                     plan_id;                /* dummy thing because of we haven't equal
353                                                                  * funcs for plan nodes... actually, we
354                                                                  * could put *plan itself somewhere else
355                                                                  * (TopPlan node ?)... */
356         List       *rtable;                     /* range table */
357         List       *setParam;           /* non-correlated EXPR & EXISTS subqueries
358                                                                  * have to set some Params for paren Plan */
359         List       *parParam;           /* indices of corr. Vars from parent plan */
360         SubLink    *sublink;            /* SubLink node for subselects in WHERE
361                                                                  * and HAVING */
362         bool            shutdown;               /* shutdown plan if TRUE */
363 } SubPlan;
364
365 #endif   /* PLANNODES_H */