1 /*-------------------------------------------------------------------------
4 * definitions for query plan nodes
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: plannodes.h,v 1.9 1997/09/08 20:58:48 momjian Exp $
11 *-------------------------------------------------------------------------
16 #include <nodes/execnodes.h>
18 /* ----------------------------------------------------------------
19 * Executor State types are used in the plannode structures
20 * so we have to include their definitions too.
22 * Node Type node information used by executor
26 * Existential ExistentialState exstate;
27 * Result ResultState resstate;
28 * Append AppendState unionstate;
32 * Scan *** CommonScanState scanstate;
33 * IndexScan IndexScanState indxstate;
35 * (*** nodes which inherit Scan also inherit scanstate)
39 * NestLoop NestLoopState nlstate;
40 * MergeJoin MergeJoinState mergestate;
41 * HashJoin HashJoinState hashjoinstate;
45 * Material MaterialState matstate;
46 * Sort SortState sortstate;
47 * Unique UniqueState uniquestate;
48 * Hash HashState hashstate;
50 * ----------------------------------------------------------------
54 /* ----------------------------------------------------------------
56 * ----------------------------------------------------------------
71 EState *state; /* at execution time, state's of
72 * individual nodes point to one EState
73 * for the whole top-level plan */
75 List *qual; /* Node* or List* ?? */
76 struct Plan *lefttree;
77 struct Plan *righttree;
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.
87 #define innerPlan(node) (((Plan *)(node))->righttree)
88 #define outerPlan(node) (((Plan *)(node))->lefttree)
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 */
107 typedef Plan Existential;
111 * returns tuples from outer plan that satisfy the qualifications
114 typedef struct Result
117 Node *resconstantqual;
118 ResultState *resstate;
125 typedef struct Append
130 List *unionrtentries;
131 AppendState *unionstate;
142 Index scanrelid; /* relid is index into the range table */
143 CommonScanState *scanstate;
147 * sequential scan node
150 typedef Scan SeqScan;
156 typedef struct IndexScan
161 IndexScanState *indxstate;
177 * nest loop join node
180 typedef struct NestLoop
183 NestLoopState *nlstate;
190 typedef struct MergeJoin
195 Oid *mergerightorder;/* inner sort operator */
196 Oid *mergeleftorder; /* outer sort operator */
197 MergeJoinState *mergestate;
201 * hash join (probe) node
204 typedef struct HashJoin
209 HashJoinState *hashjoinstate;
210 HashJoinTable hashjointable;
211 IpcMemoryKey hashjointablekey;
212 int hashjointablesize;
230 * use for queries with GROUP BY specified.
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)
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;
260 * materialization node
263 typedef struct Material
265 Plan plan; /* temp node flattened out */
268 MaterialState *matstate;
277 Plan plan; /* temp node flattened out */
280 SortState *sortstate;
289 typedef struct Unique
291 Plan plan; /* temp node flattened out */
294 char *uniqueAttr; /* NULL if all attrs, or unique attribute
296 AttrNumber uniqueAttrNum; /* attribute number of attribute to select
298 UniqueState *uniquestate;
309 HashState *hashstate;
310 HashJoinTable hashtable;
311 IpcMemoryKey hashtablekey;
315 /* ---------------------
317 * ---------------------
319 typedef struct Choose
322 List *chooseplanlist;
325 /* -------------------
326 * Tee node information
328 * leftParent : the left parent of this node
329 * rightParent: the right parent of this node
330 * -------------------
338 char *teeTableName; /* the name of the table to materialize
340 List *rtentries; /* the range table for the plan below the
341 * Tee may be different than the parent
345 #endif /* PLANNODES_H */