1 /*-------------------------------------------------------------------------
4 * definitions for query plan nodes
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: plannodes.h,v 1.25 1999/05/18 21:34:26 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;
240 * use for queries with GROUP BY specified.
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)
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;
262 typedef struct Noname
270 * materialization node
273 typedef struct Material
275 Plan plan; /* noname node flattened out */
278 MaterialState *matstate;
287 Plan plan; /* noname node flattened out */
290 SortState *sortstate;
299 typedef struct Unique
301 Plan plan; /* noname node flattened out */
304 char *uniqueAttr; /* NULL if all attrs, or unique attribute
306 AttrNumber uniqueAttrNum; /* attribute number of attribute to select
308 UniqueState *uniquestate;
319 HashState *hashstate;
323 /* -------------------
324 * Tee node information
326 * leftParent : the left parent of this node
327 * rightParent: the right parent of this node
328 * -------------------
336 char *teeTableName; /* the name of the table to materialize
338 List *rtentries; /* the range table for the plan below the
339 * Tee may be different than the parent
344 /* ---------------------
346 * ---------------------
348 typedef struct SubPlan
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
362 bool shutdown; /* shutdown plan if TRUE */
365 #endif /* PLANNODES_H */