1 /*-------------------------------------------------------------------------
4 * definitions for query plan nodes
7 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: plannodes.h,v 1.37 2000/01/27 18:11:44 tgl Exp $
12 *-------------------------------------------------------------------------
17 #include "nodes/execnodes.h"
19 /* ----------------------------------------------------------------
20 * Executor State types are used in the plannode structures
21 * so we have to include their definitions too.
23 * Node Type node information used by executor
27 * Result ResultState resstate;
28 * Append AppendState appendstate;
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 * ----------------------------------------------------------------
68 /* planner's estimates of cost and result size */
73 EState *state; /* at execution time, state's of
74 * individual nodes point to one EState
75 * for the whole top-level plan */
77 List *qual; /* Node* or List* ?? */
78 struct Plan *lefttree;
79 struct Plan *righttree;
80 List *extParam; /* indices of _all_ _external_ PARAM_EXEC
81 * for this plan in global
82 * es_param_exec_vals. Params from
83 * setParam from initPlan-s are not
84 * included, but their execParam-s are
86 List *locParam; /* someones from setParam-s */
87 List *chgParam; /* list of changed ones from the above */
88 List *initPlan; /* Init Plan nodes (un-correlated expr
90 List *subPlan; /* Other SubPlan nodes */
93 * We really need in some TopPlan node to store range table and
94 * resultRelation from Query there and get rid of Query itself from
95 * Executor. Some other stuff like below could be put there, too.
97 int nParamExec; /* Number of them in entire query. This is
98 * to get Executor know about how many
99 * param_exec there are in query plan. */
103 * these are are defined to avoid confusion problems with "left"
104 * and "right" and "inner" and "outer". The convention is that
105 * the "left" plan is the "outer" plan and the "right" plan is
106 * the inner plan, but these make the code more readable.
109 #define innerPlan(node) (((Plan *)(node))->righttree)
110 #define outerPlan(node) (((Plan *)(node))->lefttree)
119 /* all plan nodes "derive" from the Plan structure by having the
120 Plan structure as the first field. This ensures that everything works
121 when nodes are cast to Plan's. (node pointers are frequently cast to Plan*
122 when passed around generically in the executor */
127 * returns tuples from outer plan that satisfy the qualifications
130 typedef struct Result
133 Node *resconstantqual;
134 ResultState *resstate;
141 typedef struct Append
145 List *unionrtables; /* List of range tables, one for each
147 Index inheritrelid; /* The range table has to be changed for
150 AppendState *appendstate;
161 Index scanrelid; /* relid is index into the range table */
162 CommonScanState *scanstate;
166 * sequential scan node
169 typedef Scan SeqScan;
175 typedef struct IndexScan
181 ScanDirection indxorderdir;
182 IndexScanState *indxstate;
189 typedef struct TidScan
194 TidScanState *tidstate;
210 * nest loop join node
213 typedef struct NestLoop
216 NestLoopState *nlstate;
223 typedef struct MergeJoin
227 MergeJoinState *mergestate;
231 * hash join (probe) node
234 typedef struct HashJoin
239 HashJoinState *hashjoinstate;
255 * use for queries with GROUP BY specified.
257 * If tuplePerGroup is true, one tuple (with group columns only) is
258 * returned for each group and NULL is returned when there are no more
259 * groups. Otherwise, all the tuples of a group are returned with a
260 * NULL returned at the end of each group. (see nodeGroup.c for details)
266 bool tuplePerGroup; /* what tuples to return (see above) */
267 int numCols; /* number of group columns */
268 AttrNumber *grpColIdx; /* indexes into the target list */
269 GroupState *grpstate;
277 typedef struct Noname
285 * materialization node
288 typedef struct Material
290 Plan plan; /* noname node flattened out */
293 MaterialState *matstate;
302 Plan plan; /* noname node flattened out */
305 SortState *sortstate;
312 typedef struct Unique
314 Plan plan; /* noname node flattened out */
317 int numCols; /* number of columns to check for uniqueness */
318 AttrNumber *uniqColIdx; /* indexes into the target list */
319 UniqueState *uniquestate;
330 HashState *hashstate;
334 /* -------------------
335 * Tee node information
337 * leftParent : the left parent of this node
338 * rightParent: the right parent of this node
339 * -------------------
347 char *teeTableName; /* the name of the table to materialize
349 List *rtentries; /* the range table for the plan below the
350 * Tee may be different than the parent
356 /* ---------------------
358 * ---------------------
360 typedef struct SubPlan
363 Plan *plan; /* subselect plan itself */
364 int plan_id; /* dummy thing because of we haven't equal
365 * funcs for plan nodes... actually, we
366 * could put *plan itself somewhere else
367 * (TopPlan node ?)... */
368 List *rtable; /* range table for subselect */
369 /* setParam and parParam are lists of integers (param IDs) */
370 List *setParam; /* non-correlated EXPR & EXISTS subqueries
371 * have to set some Params for paren Plan */
372 List *parParam; /* indices of corr. Vars from parent plan */
373 SubLink *sublink; /* SubLink node from parser; holds info about
374 * what to do with subselect's results */
376 * Remaining fields are working state for executor; not used in planning
378 bool shutdown; /* TRUE = need to shutdown plan */
379 HeapTuple curTuple; /* copy of most recent tuple from subplan */
382 #endif /* PLANNODES_H */