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.39 2000/04/12 17:16:40 momjian 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 /* estimated execution costs for plan (see costsize.c for more info) */
69 Cost startup_cost; /* cost expended before fetching any
71 Cost total_cost; /* total cost (assuming all tuples
75 * planner's estimate of result size (note: LIMIT, if any, is not
76 * considered in setting plan_rows)
78 double plan_rows; /* number of rows plan is expected to emit */
79 int plan_width; /* average row width in bytes */
81 EState *state; /* at execution time, state's of
82 * individual nodes point to one EState
83 * for the whole top-level plan */
85 List *qual; /* Node* or List* ?? */
86 struct Plan *lefttree;
87 struct Plan *righttree;
88 List *extParam; /* indices of _all_ _external_ PARAM_EXEC
89 * for this plan in global
90 * es_param_exec_vals. Params from
91 * setParam from initPlan-s are not
92 * included, but their execParam-s are
94 List *locParam; /* someones from setParam-s */
95 List *chgParam; /* list of changed ones from the above */
96 List *initPlan; /* Init Plan nodes (un-correlated expr
98 List *subPlan; /* Other SubPlan nodes */
101 * We really need in some TopPlan node to store range table and
102 * resultRelation from Query there and get rid of Query itself from
103 * Executor. Some other stuff like below could be put there, too.
105 int nParamExec; /* Number of them in entire query. This is
106 * to get Executor know about how many
107 * param_exec there are in query plan. */
111 * these are are defined to avoid confusion problems with "left"
112 * and "right" and "inner" and "outer". The convention is that
113 * the "left" plan is the "outer" plan and the "right" plan is
114 * the inner plan, but these make the code more readable.
117 #define innerPlan(node) (((Plan *)(node))->righttree)
118 #define outerPlan(node) (((Plan *)(node))->lefttree)
127 /* all plan nodes "derive" from the Plan structure by having the
128 Plan structure as the first field. This ensures that everything works
129 when nodes are cast to Plan's. (node pointers are frequently cast to Plan*
130 when passed around generically in the executor */
135 * returns tuples from outer plan that satisfy the qualifications
138 typedef struct Result
141 Node *resconstantqual;
142 ResultState *resstate;
149 typedef struct Append
153 List *unionrtables; /* List of range tables, one for each
155 Index inheritrelid; /* The range table has to be changed for
158 AppendState *appendstate;
169 Index scanrelid; /* relid is index into the range table */
170 CommonScanState *scanstate;
174 * sequential scan node
177 typedef Scan SeqScan;
183 typedef struct IndexScan
189 ScanDirection indxorderdir;
190 IndexScanState *indxstate;
197 typedef struct TidScan
202 TidScanState *tidstate;
218 * nest loop join node
221 typedef struct NestLoop
224 NestLoopState *nlstate;
231 typedef struct MergeJoin
235 MergeJoinState *mergestate;
239 * hash join (probe) node
242 typedef struct HashJoin
247 HashJoinState *hashjoinstate;
263 * use for queries with GROUP BY specified.
265 * If tuplePerGroup is true, one tuple (with group columns only) is
266 * returned for each group and NULL is returned when there are no more
267 * groups. Otherwise, all the tuples of a group are returned with a
268 * NULL returned at the end of each group. (see nodeGroup.c for details)
274 bool tuplePerGroup; /* what tuples to return (see above) */
275 int numCols; /* number of group columns */
276 AttrNumber *grpColIdx; /* indexes into the target list */
277 GroupState *grpstate;
285 typedef struct Noname
293 * materialization node
296 typedef struct Material
298 Plan plan; /* noname node flattened out */
301 MaterialState *matstate;
310 Plan plan; /* noname node flattened out */
313 SortState *sortstate;
320 typedef struct Unique
322 Plan plan; /* noname node flattened out */
325 int numCols; /* number of columns to check for
327 AttrNumber *uniqColIdx; /* indexes into the target list */
328 UniqueState *uniquestate;
339 HashState *hashstate;
343 /* -------------------
344 * Tee node information
346 * leftParent : the left parent of this node
347 * rightParent: the right parent of this node
348 * -------------------
356 char *teeTableName; /* the name of the table to materialize
358 List *rtentries; /* the range table for the plan below the
359 * Tee may be different than the parent
365 /* ---------------------
367 * ---------------------
369 typedef struct SubPlan
372 Plan *plan; /* subselect plan itself */
373 int plan_id; /* dummy thing because of we haven't equal
374 * funcs for plan nodes... actually, we
375 * could put *plan itself somewhere else
376 * (TopPlan node ?)... */
377 List *rtable; /* range table for subselect */
378 /* setParam and parParam are lists of integers (param IDs) */
379 List *setParam; /* non-correlated EXPR & EXISTS subqueries
380 * have to set some Params for paren Plan */
381 List *parParam; /* indices of corr. Vars from parent plan */
382 SubLink *sublink; /* SubLink node from parser; holds info
383 * about what to do with subselect's
387 * Remaining fields are working state for executor; not used in
390 bool shutdown; /* TRUE = need to shutdown plan */
391 HeapTuple curTuple; /* copy of most recent tuple from subplan */
394 #endif /* PLANNODES_H */