]> granicus.if.org Git - postgresql/blob - src/include/nodes/execnodes.h
Add:
[postgresql] / src / include / nodes / execnodes.h
1 /*-------------------------------------------------------------------------
2  *
3  * execnodes.h
4  *        definitions for executor state nodes
5  *
6  *
7  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: execnodes.h,v 1.39 2000/01/26 05:58:15 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef EXECNODES_H
15 #define EXECNODES_H
16
17 #include "access/funcindex.h"
18 #include "access/relscan.h"
19 #include "access/sdir.h"
20 #include "executor/hashjoin.h"
21 #include "executor/tuptable.h"
22 #include "nodes/params.h"
23 #include "nodes/primnodes.h"
24
25 /* ----------------
26  *        IndexInfo information
27  *
28  *              this class holds the information saying what attributes
29  *              are the key attributes for this index. -cim 10/15/89
30  *
31  *              NumKeyAttributes                number of key attributes for this index
32  *              KeyAttributeNumbers             array of attribute numbers used as keys
33  *              Predicate                               partial-index predicate for this index
34  * ----------------
35  */
36 typedef struct IndexInfo
37 {
38         NodeTag         type;
39         int                     ii_NumKeyAttributes;
40         AttrNumber *ii_KeyAttributeNumbers;
41         FuncIndexInfoPtr ii_FuncIndexInfo;
42         Node       *ii_Predicate;
43 } IndexInfo;
44
45 /* ----------------
46  *        RelationInfo information
47  *
48  *              whenever we update an existing relation, we have to
49  *              update indices on the relation.  The RelationInfo class
50  *              is used to hold all the information on result relations,
51  *              including indices.. -cim 10/15/89
52  *
53  *              RangeTableIndex                 result relation's range table index
54  *              RelationDesc                    relation descriptor for result relation
55  *              NumIndices                              number indices existing on result relation
56  *              IndexRelationDescs              array of relation descriptors for indices
57  *              IndexRelationInfo               array of key/attr info for indices
58  * ----------------
59  */
60 typedef struct RelationInfo
61 {
62         NodeTag         type;
63         Index           ri_RangeTableIndex;
64         Relation        ri_RelationDesc;
65         int                     ri_NumIndices;
66         RelationPtr ri_IndexRelationDescs;
67         IndexInfo **ri_IndexRelationInfo;
68 } RelationInfo;
69
70 /* ----------------
71  *        ExprContext
72  *
73  *              This class holds the "current context" information
74  *              needed to evaluate expressions for doing tuple qualifications
75  *              and tuple projections.  For example, if an expression refers
76  *              to an attribute in the current inner tuple then we need to know
77  *              what the current inner tuple is and so we look at the expression
78  *              context.
79  * ----------------
80  */
81 typedef struct ExprContext
82 {
83         NodeTag         type;
84         TupleTableSlot *ecxt_scantuple;
85         TupleTableSlot *ecxt_innertuple;
86         TupleTableSlot *ecxt_outertuple;
87         Relation        ecxt_relation;
88         Index           ecxt_relid;
89         ParamListInfo ecxt_param_list_info;
90         ParamExecData *ecxt_param_exec_vals;            /* this is for subselects */
91         List       *ecxt_range_table;
92         Datum      *ecxt_aggvalues;     /* precomputed values for Aggref nodes */
93         bool       *ecxt_aggnulls;      /* null flags for Aggref nodes */
94 } ExprContext;
95
96 /* ----------------
97  *              ProjectionInfo node information
98  *
99  *              This is all the information needed to preform projections
100  *              on a tuple.  Nodes which need to do projections create one
101  *              of these.  In theory, when a node wants to preform a projection
102  *              it should just update this information as necessary and then
103  *              call ExecProject().  -cim 6/3/91
104  *
105  *              targetlist              target list for projection
106  *              len                             length of target list
107  *              tupValue                array of pointers to projection results
108  *              exprContext             expression context for ExecTargetList
109  *              slot                    slot to place projection result in
110  * ----------------
111  */
112 typedef struct ProjectionInfo
113 {
114         NodeTag         type;
115         List       *pi_targetlist;
116         int                     pi_len;
117         Datum      *pi_tupValue;
118         ExprContext *pi_exprContext;
119         TupleTableSlot *pi_slot;
120 } ProjectionInfo;
121
122 /* ----------------
123  *        JunkFilter
124  *
125  *        this class is used to store information regarding junk attributes.
126  *        A junk attribute is an attribute in a tuple that is needed only for
127  *        storing intermediate information in the executor, and does not belong
128  *        in the tuple proper.  For example, when we do a delete or replace
129  *        query, the planner adds an entry to the targetlist so that the tuples
130  *        returned to ExecutePlan() contain an extra attribute: the t_ctid of
131  *        the tuple to be deleted/replaced.  This is needed for amdelete() and
132  *        amreplace().  In doing a delete this does not make much of a
133  *        difference, but in doing a replace we have to make sure we disgard
134  *        all the junk in a tuple before calling amreplace().  Otherwise the
135  *        inserted tuple will not have the correct schema.      This solves a
136  *        problem with hash-join and merge-sort replace plans.  -cim 10/10/90
137  *
138  *        targetList:           the original target list (including junk attributes).
139  *        length:                       the length of 'targetList'.
140  *        tupType:                      the tuple descriptor for the "original" tuple
141  *                                              (including the junk attributes).
142  *        cleanTargetList:      the "clean" target list (junk attributes removed).
143  *        cleanLength:          the length of 'cleanTargetList'
144  *        cleanTupTyp:          the tuple descriptor of the "clean" tuple (with
145  *                                              junk attributes removed).
146  *        cleanMap:                     A map with the correspondance between the non junk
147  *                                              attributes of the "original" tuple and the
148  *                                              attributes of the "clean" tuple.
149  * ----------------
150  */
151 typedef struct JunkFilter
152 {
153         NodeTag         type;
154         List       *jf_targetList;
155         int                     jf_length;
156         TupleDesc       jf_tupType;
157         List       *jf_cleanTargetList;
158         int                     jf_cleanLength;
159         TupleDesc       jf_cleanTupType;
160         AttrNumber *jf_cleanMap;
161 } JunkFilter;
162
163 /* ----------------
164  *        EState information
165  *
166  *              direction                                               direction of the scan
167  *
168  *              range_table                                             array of scan relation information
169  *
170  *              result_relation_information             for update queries
171  *
172  *              into_relation_descriptor                relation being retrieved "into"
173  *
174  *              param_list_info                                 information needed to transform
175  *                                                                              Param nodes into Const nodes
176  *
177  *              BaseId                                                  during InitPlan(), each node is
178  *                                                                              given a number.  this is the next
179  *                                                                              number to be assigned.
180  *
181  *              tupleTable                                              this is a pointer to an array
182  *                                                                              of pointers to tuples used by
183  *                                                                              the executor at any given moment.
184  *
185  *              junkFilter                                              contains information used to
186  *                                                                              extract junk attributes from a tuple.
187  *                                                                              (see JunkFilter above)
188  *
189  *              refcount                                                local buffer refcounts used in
190  *                                                                              an ExecMain cycle.      this is introduced
191  *                                                                              to avoid ExecStart's unpinning each
192  *                                                                              other's buffers when called recursively
193  * ----------------
194  */
195 typedef struct EState
196 {
197         NodeTag         type;
198         ScanDirection es_direction;
199         Snapshot        es_snapshot;
200         List       *es_range_table;
201         RelationInfo *es_result_relation_info;
202         List      **es_result_relation_constraints;
203         Relation        es_into_relation_descriptor;
204         ParamListInfo es_param_list_info;
205         ParamExecData *es_param_exec_vals;      /* this is for subselects */
206         int                     es_BaseId;
207         TupleTable      es_tupleTable;
208         JunkFilter *es_junkFilter;
209         uint32          es_processed;   /* # of tuples processed */
210         Oid                     es_lastoid;             /* last oid processed (by INSERT) */
211         List       *es_rowMark;         /* not good place, but there is no other */
212         /* Below is to re-evaluate plan qual in READ COMMITTED mode */
213         struct Plan *es_origPlan;
214         Pointer         es_evalPlanQual;
215         bool       *es_evTupleNull;
216         HeapTuple  *es_evTuple;
217         bool            es_useEvalPlan;
218 } EState;
219
220 /* ----------------
221  *              Executor Type information needed by plannodes.h
222  *
223  *|             Note: the bogus classes CommonState and CommonScanState exist only
224  *|                       because our inheritance system only allows single inheritance
225  *|                       and we have to have unique slot names.  Hence two or more
226  *|                       classes which want to have a common slot must ALL inherit
227  *|                       the slot from some other class.  (This is a big hack to
228  *|                       allow our classes to share slot names..)
229  *|
230  *|             Example:
231  *|                       the class Result and the class NestLoop nodes both want
232  *|                       a slot called "OuterTuple" so they both have to inherit
233  *|                       it from some other class.  In this case they inherit
234  *|                       it from CommonState.  "CommonState" and "CommonScanState" are
235  *|                       the best names I could come up with for this sort of
236  *|                       stuff.
237  *|
238  *|                       As a result, many classes have extra slots which they
239  *|                       don't use.  These slots are denoted (unused) in the
240  *|                       comment preceeding the class definition.      If you
241  *|                       comes up with a better idea of a way of doing things
242  *|                       along these lines, then feel free to make your idea
243  *|                       known to me.. -cim 10/15/89
244  * ----------------
245  */
246
247 /* ----------------------------------------------------------------
248  *                               Common Executor State Information
249  * ----------------------------------------------------------------
250  */
251
252 /* BaseNode removed -- base_id moved into CommonState           - jolly */
253
254 /* ----------------
255  *       CommonState information
256  *
257  *|             this is a bogus class used to hold slots so other
258  *|             nodes can inherit them...
259  *
260  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
261  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
262  *              ExprContext                node's current expression context
263  *              ProjInfo                   info this node uses to form tuple projections
264  *              NumScanAttributes  size of ScanAttributes array
265  *              ScanAttributes     attribute numbers of interest in this tuple
266  *
267  * ----------------
268  */
269 typedef struct CommonState
270 {
271         NodeTag         type;                   /* its first field is NodeTag */
272         int                     cs_base_id;
273         TupleTableSlot *cs_OuterTupleSlot;
274         TupleTableSlot *cs_ResultTupleSlot;
275         ExprContext *cs_ExprContext;
276         ProjectionInfo *cs_ProjInfo;
277         bool            cs_TupFromTlist;
278 } CommonState;
279
280
281 /* ----------------------------------------------------------------
282  *                               Control Node State Information
283  * ----------------------------------------------------------------
284  */
285
286 /* ----------------
287  *       ResultState information
288  *
289  *              done                       flag which tells us to quit when we
290  *                                                 have already returned a constant tuple.
291  *
292  *       CommonState information
293  *
294  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
295  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
296  *              ExprContext                node's current expression context
297  *              ProjInfo                   info this node uses to form tuple projections
298  *              NumScanAttributes  size of ScanAttributes array
299  *              ScanAttributes     attribute numbers of interest in this tuple
300  * ----------------
301  */
302 typedef struct ResultState
303 {
304         CommonState cstate;                     /* its first field is NodeTag */
305         bool            rs_done;
306         bool            rs_checkqual;
307 } ResultState;
308
309 /* ----------------
310  *       AppendState information
311  *
312  *              append nodes have this field "unionplans" which is this
313  *              list of plans to execute in sequence..  these variables
314  *              keep track of things..
315  *
316  *              whichplan               which plan is being executed
317  *              nplans                  how many plans are in the list
318  *              initialized             array of ExecInitNode() results
319  *              rtentries               range table for the current plan
320  *              result_relation_info_list  array of each subplan's result relation info
321  *              junkFilter_list  array of each subplan's junk filter
322  *
323  *       CommonState information
324  *
325  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
326  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
327  *              ExprContext                node's current expression context
328  *              ProjInfo                   info this node uses to form tuple projections
329  *              NumScanAttributes  size of ScanAttributes array
330  *              ScanAttributes     attribute numbers of interest in this tuple
331  * ----------------
332  */
333 typedef struct AppendState
334 {
335         CommonState cstate;                     /* its first field is NodeTag */
336         int                     as_whichplan;
337         int                     as_nplans;
338         bool       *as_initialized;
339         List       *as_rtentries;
340         List       *as_result_relation_info_list;
341         List       *as_junkFilter_list;
342 } AppendState;
343
344 /* ----------------------------------------------------------------
345  *                               Scan State Information
346  * ----------------------------------------------------------------
347  */
348
349 /* ----------------
350  *       CommonScanState information
351  *
352  *              CommonScanState is a class like CommonState, but is used more
353  *              by the nodes like SeqScan and Sort which want to
354  *              keep track of an underlying relation.
355  *
356  *              currentRelation    relation being scanned
357  *              currentScanDesc    current scan descriptor for scan
358  *              ScanTupleSlot      pointer to slot in tuple table holding scan tuple
359  *
360  *       CommonState information
361  *
362  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
363  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
364  *              ExprContext                node's current expression context
365  *              ProjInfo                   info this node uses to form tuple projections
366  *              NumScanAttributes  size of ScanAttributes array
367  *              ScanAttributes     attribute numbers of interest in this tuple
368  * ----------------
369  */
370 typedef struct CommonScanState
371 {
372         CommonState cstate;                     /* its first field is NodeTag */
373         Relation        css_currentRelation;
374         HeapScanDesc css_currentScanDesc;
375         TupleTableSlot *css_ScanTupleSlot;
376 } CommonScanState;
377
378 /* ----------------
379  *       IndexScanState information
380  *
381  *|             index scans don't use CommonScanState because
382  *|             the underlying AM abstractions for heap scans and
383  *|             index scans are too different..  It would be nice
384  *|             if the current abstraction was more useful but ... -cim 10/15/89
385  *
386  *              IndexPtr                   current index in use
387  *              NumIndices                 number of indices in this scan
388  *              ScanKeys                   Skey structures to scan index rels
389  *              NumScanKeys                array of no of keys in each Skey struct
390  *              RuntimeKeyInfo     array of array of flags for Skeys evaled at runtime
391  *              RelationDescs      ptr to array of relation descriptors
392  *              ScanDescs                  ptr to array of scan descriptors
393  *
394  *       CommonState information
395  *
396  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
397  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
398  *              ExprContext                node's current expression context
399  *              ProjInfo                   info this node uses to form tuple projections
400  *              NumScanAttributes  size of ScanAttributes array
401  *              ScanAttributes     attribute numbers of interest in this tuple
402  * ----------------
403  */
404 typedef struct IndexScanState
405 {
406         CommonState cstate;                     /* its first field is NodeTag */
407         int                     iss_NumIndices;
408         int                     iss_IndexPtr;
409         int                     iss_MarkIndexPtr;
410         ScanKey    *iss_ScanKeys;
411         int                *iss_NumScanKeys;
412         Pointer         iss_RuntimeKeyInfo;
413         RelationPtr iss_RelationDescs;
414         IndexScanDescPtr iss_ScanDescs;
415         HeapTupleData iss_htup;
416 } IndexScanState;
417
418 /* ----------------
419  *       TidScanState information
420  *
421  *|             tid scans don't use CommonScanState because
422  *|             the underlying AM abstractions for heap scans and
423  *|             tid scans are too different..  It would be nice
424  *|             if the current abstraction was more useful but ... -cim 10/15/89
425  *
426  *              TidPtr             current tid in use
427  *              NumTids            number of tids in this scan
428  *              tidList            evaluated item pointers
429  *
430  *       CommonState information
431  *
432  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
433  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
434  *              ExprContext                node's current expression context
435  *              ProjInfo                   info this node uses to form tuple projections
436  *              NumScanAttributes  size of ScanAttributes array
437  *              ScanAttributes     attribute numbers of interest in this tuple
438  * ----------------
439  */
440 typedef struct TidScanState
441 {
442         CommonState cstate;                     /* its first field is NodeTag */
443         int                     tss_NumTids;
444         int                     tss_TidPtr;
445         int                     tss_MarkTidPtr;
446         ItemPointer             *tss_TidList;
447         HeapTupleData           tss_htup;
448 } TidScanState;
449
450 /* ----------------------------------------------------------------
451  *                               Join State Information
452  * ----------------------------------------------------------------
453  */
454
455 /* ----------------
456  *       JoinState information
457  *
458  *       CommonState information
459  *
460  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
461  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
462  *              ExprContext                node's current expression context
463  *              ProjInfo                   info this node uses to form tuple projections
464  *              NumScanAttributes  size of ScanAttributes array
465  *              ScanAttributes     attribute numbers of interest in this tuple
466  * ----------------
467  */
468 typedef CommonState JoinState;
469
470 /* ----------------
471  *       NestLoopState information
472  *
473  *              PortalFlag                 Set to enable portals to work.
474  *
475  *       JoinState information
476  *
477  *       CommonState information
478  *
479  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
480  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
481  *              ExprContext                node's current expression context
482  *              ProjInfo                   info this node uses to form tuple projections
483  *              NumScanAttributes  size of ScanAttributes array
484  *              ScanAttributes     attribute numbers of interest in this tuple
485  * ----------------
486  */
487 typedef struct NestLoopState
488 {
489         JoinState       jstate;                 /* its first field is NodeTag */
490         bool            nl_PortalFlag;
491 } NestLoopState;
492
493 /* ----------------
494  *       MergeJoinState information
495  *
496  *              OuterSkipQual      outerKey1 < innerKey1 ...
497  *              InnerSkipQual      outerKey1 > innerKey1 ...
498  *              JoinState                  current "state" of join. see executor.h
499  *              MarkedTupleSlot    pointer to slot in tuple table for marked tuple
500  *
501  *       JoinState information
502  *
503  *       CommonState information
504  *
505  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
506  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
507  *              ExprContext                node's current expression context
508  *              ProjInfo                   info this node uses to form tuple projections
509  *              NumScanAttributes  size of ScanAttributes array
510  *              ScanAttributes     attribute numbers of interest in this tuple
511  * ----------------
512  */
513 typedef struct MergeJoinState
514 {
515         JoinState       jstate;                 /* its first field is NodeTag */
516         List       *mj_OuterSkipQual;
517         List       *mj_InnerSkipQual;
518         int                     mj_JoinState;
519         TupleTableSlot *mj_MarkedTupleSlot;
520 } MergeJoinState;
521
522 /* ----------------
523  *       HashJoinState information
524  *
525  *              hj_HashTable                    hash table for the hashjoin
526  *              hj_CurBucketNo                  bucket# for current outer tuple
527  *              hj_CurTuple                             last inner tuple matched to current outer
528  *                                                              tuple, or NULL if starting search
529  *                                                              (CurBucketNo and CurTuple are meaningless
530  *                                                               unless OuterTupleSlot is nonempty!)
531  *              hj_InnerHashKey                 the inner hash key in the hashjoin condition
532  *              hj_OuterTupleSlot               tuple slot for outer tuples
533  *              hj_HashTupleSlot                tuple slot for hashed tuples
534  *
535  *       JoinState information
536  *
537  *       CommonState information
538  *
539  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
540  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
541  *              ExprContext                node's current expression context
542  *              ProjInfo                   info this node uses to form tuple projections
543  *              NumScanAttributes  size of ScanAttributes array
544  *              ScanAttributes     attribute numbers of interest in this tuple
545  * ----------------
546  */
547 typedef struct HashJoinState
548 {
549         JoinState       jstate;                 /* its first field is NodeTag */
550         HashJoinTable hj_HashTable;
551         int                     hj_CurBucketNo;
552         HashJoinTuple hj_CurTuple;
553         Var                *hj_InnerHashKey;
554         TupleTableSlot *hj_OuterTupleSlot;
555         TupleTableSlot *hj_HashTupleSlot;
556 } HashJoinState;
557
558
559 /* ----------------------------------------------------------------
560  *                               Materialization State Information
561  * ----------------------------------------------------------------
562  */
563
564 /* ----------------
565  *       MaterialState information
566  *
567  *              materialize nodes are used to materialize the results
568  *              of a subplan into a temporary relation.
569  *
570  *              Flag                    indicated whether subplan has been materialized
571  *              TempRelation    temporary relation containing result of executing
572  *                                              the subplan.
573  *
574  *       CommonScanState information
575  *
576  *              currentRelation    relation descriptor of sorted relation
577  *              currentScanDesc    current scan descriptor for scan
578  *              ScanTupleSlot      pointer to slot in tuple table holding scan tuple
579  *
580  *       CommonState information
581  *
582  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
583  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
584  *              ExprContext                node's current expression context
585  *              ProjInfo                   info this node uses to form tuple projections
586  *              NumScanAttributes  size of ScanAttributes array
587  *              ScanAttributes     attribute numbers of interest in this tuple
588  * ----------------
589  */
590 typedef struct MaterialState
591 {
592         CommonScanState csstate;        /* its first field is NodeTag */
593         bool            mat_Flag;
594         Relation        mat_TempRelation;
595 } MaterialState;
596
597 /* ---------------------
598  *      AggregateState information
599  *
600  *      Note: the associated ExprContext contains ecxt_aggvalues and ecxt_aggnulls
601  *      arrays, which hold the computed agg values for the current input group
602  *      during evaluation of an Agg node's output tuple(s).
603  * -------------------------
604  */
605 typedef struct AggStatePerAggData *AggStatePerAgg; /* private in nodeAgg.c */
606
607 typedef struct AggState
608 {
609         CommonScanState csstate;        /* its first field is NodeTag */
610         List       *aggs;                       /* all Aggref nodes in targetlist & quals */
611         int                     numaggs;                /* length of list (could be zero!) */
612         AggStatePerAgg peragg;          /* per-Aggref working state */
613         bool            agg_done;               /* indicates completion of Agg scan */
614 } AggState;
615
616 /* ---------------------
617  *      GroupState information
618  *
619  * -------------------------
620  */
621 typedef struct GroupState
622 {
623         CommonScanState csstate;        /* its first field is NodeTag */
624         bool            grp_useFirstTuple;              /* first tuple not processed yet */
625         bool            grp_done;
626         HeapTuple       grp_firstTuple;
627 } GroupState;
628
629 /* ----------------
630  *       SortState information
631  *
632  *              sort_Done               indicates whether sort has been performed yet
633  *              sort_Keys               scan key structures describing the sort keys
634  *              tuplesortstate  private state of tuplesort.c
635  *
636  *       CommonScanState information
637  *
638  *              currentRelation    relation descriptor of sorted relation
639  *              currentScanDesc    current scan descriptor for scan
640  *              ScanTupleSlot      pointer to slot in tuple table holding scan tuple
641  *
642  *       CommonState information
643  *
644  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
645  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
646  *              ExprContext                node's current expression context
647  *              ProjInfo                   info this node uses to form tuple projections
648  *              NumScanAttributes  size of ScanAttributes array
649  *              ScanAttributes     attribute numbers of interest in this tuple
650  * ----------------
651  */
652 typedef struct SortState
653 {
654         CommonScanState csstate;        /* its first field is NodeTag */
655         bool            sort_Done;
656         ScanKey         sort_Keys;
657         void       *tuplesortstate;
658 } SortState;
659
660 /* ----------------
661  *       UniqueState information
662  *
663  *              Unique nodes are used "on top of" sort nodes to discard
664  *              duplicate tuples returned from the sort phase.  Basically
665  *              all it does is compare the current tuple from the subplan
666  *              with the previously fetched tuple stored in OuterTuple and
667  *              if the two are identical, then we just fetch another tuple
668  *              from the sort and try again.
669  *
670  *       CommonState information
671  *
672  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
673  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
674  *              ExprContext                node's current expression context
675  *              ProjInfo                   info this node uses to form tuple projections
676  *              NumScanAttributes  size of ScanAttributes array
677  *              ScanAttributes     attribute numbers of interest in this tuple
678  * ----------------
679  */
680 typedef CommonState UniqueState;
681
682
683 /* ----------------
684  *       HashState information
685  *
686  *              hashtable                       hash table for the hashjoin
687  *
688  *       CommonState information
689  *
690  *              OuterTupleSlot     pointer to slot containing current "outer" tuple
691  *              ResultTupleSlot    pointer to slot in tuple table for projected tuple
692  *              ExprContext                node's current expression context
693  *              ProjInfo                   info this node uses to form tuple projections
694  *              NumScanAttributes  size of ScanAttributes array
695  *              ScanAttributes     attribute numbers of interest in this tuple
696  * ----------------
697  */
698 typedef struct HashState
699 {
700         CommonState cstate;                     /* its first field is NodeTag */
701         HashJoinTable hashtable;
702 } HashState;
703
704 #ifdef NOT_USED
705 /* -----------------------
706  *      TeeState information
707  *        leftPlace  :    next item in the queue unseen by the left parent
708  *        rightPlace :    next item in the queue unseen by the right parent
709  *        lastPlace  :    last item in the queue
710  *        bufferRelname :  name of the relation used as the buffer queue
711  *        bufferRel             :  the relation used as the buffer queue
712  *        mcxt                  :  for now, tee's have their own memory context
713  *                                         may be cleaned up later if portals are cleaned up
714  *
715  * initially, a Tee starts with [left/right]Place variables set to      -1.
716  * on cleanup, queue is free'd when both leftPlace and rightPlace = -1
717  * -------------------------
718 */
719 typedef struct TeeState
720 {
721         CommonState cstate;                     /* its first field is NodeTag */
722         int                     tee_leftPlace,
723                                 tee_rightPlace,
724                                 tee_lastPlace;
725         char       *tee_bufferRelname;
726         Relation        tee_bufferRel;
727         MemoryContext tee_mcxt;
728         HeapScanDesc tee_leftScanDesc,
729                                 tee_rightScanDesc;
730 }                       TeeState;
731
732 #endif
733
734 #endif   /* EXECNODES_H */