1 /*-------------------------------------------------------------------------
4 * definitions for query plan nodes
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: plannodes.h,v 1.6 1997/08/06 03:42:04 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 * ----------------------------------------------------------------
70 EState *state; /* at execution time, state's of individual
71 nodes point to one EState for the
72 whole top-level plan */
74 List *qual; /* Node* or List* ?? */
75 struct Plan *lefttree;
76 struct Plan *righttree;
80 * these are are defined to avoid confusion problems with "left"
81 * and "right" and "inner" and "outer". The convention is that
82 * the "left" plan is the "outer" plan and the "right" plan is
83 * the inner plan, but these make the code more readable.
86 #define innerPlan(node) (((Plan *)(node))->righttree)
87 #define outerPlan(node) (((Plan *)(node))->lefttree)
96 /* all plan nodes "derive" from the Plan structure by having the
97 Plan structure as the first field. This ensures that everything works
98 when nodes are cast to Plan's. (node pointers are frequently cast to Plan*
99 when passed around generically in the executor */
106 typedef Plan Existential;
110 * returns tuples from outer plan that satisfy the qualifications
113 typedef struct Result {
115 Node *resconstantqual;
116 ResultState *resstate;
123 typedef struct Append {
127 List *unionrtentries;
128 AppendState *unionstate;
136 typedef struct Scan {
138 Index scanrelid; /* relid is index into the range table */
139 CommonScanState *scanstate;
143 * sequential scan node
146 typedef Scan SeqScan;
152 typedef struct IndexScan {
156 IndexScanState *indxstate;
172 * nest loop join node
175 typedef struct NestLoop {
177 NestLoopState *nlstate;
184 typedef struct MergeJoin {
188 Oid *mergerightorder; /* inner sort operator */
189 Oid *mergeleftorder; /* outer sort operator */
190 MergeJoinState *mergestate;
194 * hash join (probe) node
197 typedef struct HashJoin {
201 HashJoinState *hashjoinstate;
202 HashJoinTable hashjointable;
203 IpcMemoryKey hashjointablekey;
204 int hashjointablesize;
221 * use for queries with GROUP BY specified.
223 * If tuplePerGroup is true, one tuple (with group columns only) is
224 * returned for each group and NULL is returned when there are no more
225 * groups. Otherwise, all the tuples of a group are returned with a
226 * NULL returned at the end of each group. (see nodeGroup.c for details)
229 typedef struct Group {
231 bool tuplePerGroup; /* what tuples to return (see above) */
232 int numCols; /* number of group columns */
233 AttrNumber *grpColIdx; /* index into the target list */
234 GroupState *grpstate;
242 typedef struct Temp {
249 * materialization node
252 typedef struct Material {
253 Plan plan; /* temp node flattened out */
256 MaterialState *matstate;
263 typedef struct Sort {
264 Plan plan; /* temp node flattened out */
267 SortState *sortstate;
276 typedef struct Unique {
277 Plan plan; /* temp node flattened out */
280 char *uniqueAttr; /* NULL if all attrs,
281 or unique attribute name */
282 AttrNumber uniqueAttrNum; /* attribute number of attribute
283 to select distinct on */
284 UniqueState *uniquestate;
291 typedef struct Hash {
294 HashState *hashstate;
295 HashJoinTable hashtable;
296 IpcMemoryKey hashtablekey;
300 /* ---------------------
302 * ---------------------
304 typedef struct Choose {
306 List *chooseplanlist;
309 /* -------------------
310 * Tee node information
312 * leftParent : the left parent of this node
313 * rightParent: the right parent of this node
314 * -------------------
321 char *teeTableName; /* the name of the table to materialize
323 List *rtentries; /* the range table for the plan below the Tee
324 may be different than the parent plans */
327 #endif /* PLANNODES_H */