1 /*-------------------------------------------------------------------------
4 * definitions for query plan nodes
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: plannodes.h,v 1.23 1999/03/01 00:10:36 tgl 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 * Result ResultState resstate;
27 * Append AppendState appendstate;
31 * Scan *** CommonScanState scanstate;
32 * IndexScan IndexScanState indxstate;
34 * (*** nodes which inherit Scan also inherit scanstate)
38 * NestLoop NestLoopState nlstate;
39 * MergeJoin MergeJoinState mergestate;
40 * HashJoin HashJoinState hashjoinstate;
44 * Material MaterialState matstate;
45 * Sort SortState sortstate;
46 * Unique UniqueState uniquestate;
47 * Hash HashState hashstate;
49 * ----------------------------------------------------------------
53 /* ----------------------------------------------------------------
55 * ----------------------------------------------------------------
70 EState *state; /* at execution time, state's of
71 * individual nodes point to one EState
72 * for the whole top-level plan */
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
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
87 List *subPlan; /* Other SubPlan nodes */
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.
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. */
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.
106 #define innerPlan(node) (((Plan *)(node))->righttree)
107 #define outerPlan(node) (((Plan *)(node))->lefttree)
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 */
124 * returns tuples from outer plan that satisfy the qualifications
127 typedef struct Result
130 Node *resconstantqual;
131 ResultState *resstate;
138 typedef struct Append
142 List *unionrtables; /* List of range tables, one for each
144 Index inheritrelid; /* The range table has to be changed for
147 AppendState *appendstate;
158 Index scanrelid; /* relid is index into the range table */
159 CommonScanState *scanstate;
163 * sequential scan node
166 typedef Scan SeqScan;
172 typedef struct IndexScan
178 IndexScanState *indxstate;
194 * nest loop join node
197 typedef struct NestLoop
200 NestLoopState *nlstate;
207 typedef struct MergeJoin
211 MergeJoinState *mergestate;
215 * hash join (probe) node
218 typedef struct HashJoin
223 HashJoinState *hashjoinstate;
224 HashJoinTable hashjointable;
225 IpcMemoryKey hashjointablekey;
226 int hashjointablesize;
243 * use for queries with GROUP BY specified.
245 * If tuplePerGroup is true, one tuple (with group columns only) is
246 * returned for each group and NULL is returned when there are no more
247 * groups. Otherwise, all the tuples of a group are returned with a
248 * NULL returned at the end of each group. (see nodeGroup.c for details)
254 bool tuplePerGroup; /* what tuples to return (see above) */
255 int numCols; /* number of group columns */
256 AttrNumber *grpColIdx; /* index into the target list */
257 GroupState *grpstate;
265 typedef struct Noname
273 * materialization node
276 typedef struct Material
278 Plan plan; /* noname node flattened out */
281 MaterialState *matstate;
290 Plan plan; /* noname node flattened out */
293 SortState *sortstate;
302 typedef struct Unique
304 Plan plan; /* noname node flattened out */
307 char *uniqueAttr; /* NULL if all attrs, or unique attribute
309 AttrNumber uniqueAttrNum; /* attribute number of attribute to select
311 UniqueState *uniquestate;
322 HashState *hashstate;
323 HashJoinTable hashtable;
324 IpcMemoryKey hashtablekey;
328 /* -------------------
329 * Tee node information
331 * leftParent : the left parent of this node
332 * rightParent: the right parent of this node
333 * -------------------
341 char *teeTableName; /* the name of the table to materialize
343 List *rtentries; /* the range table for the plan below the
344 * Tee may be different than the parent
348 /* ---------------------
350 * ---------------------
352 typedef struct SubPlan
355 Plan *plan; /* subselect plan itself */
356 int plan_id; /* dummy thing because of we haven't equal
357 * funcs for plan nodes... actually, we
358 * could put *plan itself somewhere else
359 * (TopPlan node ?)... */
360 List *rtable; /* range table */
361 List *setParam; /* non-correlated EXPR & EXISTS subqueries
362 * have to set some Params for paren Plan */
363 List *parParam; /* indices of corr. Vars from parent plan */
364 SubLink *sublink; /* SubLink node for subselects in WHERE
366 bool shutdown; /* shutdown plan if TRUE */
369 #endif /* PLANNODES_H */