1 /*-------------------------------------------------------------------------
4 * definitions for query plan nodes
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: plannodes.h,v 1.20 1999/01/23 23:28:09 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 * 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
212 Oid *mergerightorder;/* inner sort operator */
213 Oid *mergeleftorder; /* outer sort operator */
214 MergeJoinState *mergestate;
218 * hash join (probe) node
221 typedef struct HashJoin
226 HashJoinState *hashjoinstate;
227 HashJoinTable hashjointable;
228 IpcMemoryKey hashjointablekey;
229 int hashjointablesize;
246 * use for queries with GROUP BY specified.
248 * If tuplePerGroup is true, one tuple (with group columns only) is
249 * returned for each group and NULL is returned when there are no more
250 * groups. Otherwise, all the tuples of a group are returned with a
251 * NULL returned at the end of each group. (see nodeGroup.c for details)
257 bool tuplePerGroup; /* what tuples to return (see above) */
258 int numCols; /* number of group columns */
259 AttrNumber *grpColIdx; /* index into the target list */
260 GroupState *grpstate;
276 * materialization node
279 typedef struct Material
281 Plan plan; /* temp node flattened out */
284 MaterialState *matstate;
293 Plan plan; /* temp node flattened out */
296 SortState *sortstate;
305 typedef struct Unique
307 Plan plan; /* temp node flattened out */
310 char *uniqueAttr; /* NULL if all attrs, or unique attribute
312 AttrNumber uniqueAttrNum; /* attribute number of attribute to select
314 UniqueState *uniquestate;
325 HashState *hashstate;
326 HashJoinTable hashtable;
327 IpcMemoryKey hashtablekey;
331 /* -------------------
332 * Tee node information
334 * leftParent : the left parent of this node
335 * rightParent: the right parent of this node
336 * -------------------
344 char *teeTableName; /* the name of the table to materialize
346 List *rtentries; /* the range table for the plan below the
347 * Tee may be different than the parent
351 /* ---------------------
353 * ---------------------
355 typedef struct SubPlan
358 Plan *plan; /* subselect plan itself */
359 int plan_id; /* dummy thing because of we haven't equal
360 * funcs for plan nodes... actually, we
361 * could put *plan itself somewhere else
362 * (TopPlan node ?)... */
363 List *rtable; /* range table */
364 List *setParam; /* non-correlated EXPR & EXISTS subqueries
365 * have to set some Params for paren Plan */
366 List *parParam; /* indices of corr. Vars from parent plan */
367 SubLink *sublink; /* SubLink node for subselects in WHERE
369 bool shutdown; /* shutdown plan if TRUE */
372 #endif /* PLANNODES_H */