PostgreSQL Source Code  git master
execnodes.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * execnodes.h
4  * definitions for executor state nodes
5  *
6  *
7  * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/nodes/execnodes.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef EXECNODES_H
15 #define EXECNODES_H
16 
17 #include "access/genam.h"
18 #include "access/heapam.h"
19 #include "access/tupconvert.h"
20 #include "executor/instrument.h"
21 #include "lib/pairingheap.h"
22 #include "nodes/params.h"
23 #include "nodes/plannodes.h"
24 #include "utils/hsearch.h"
25 #include "utils/queryenvironment.h"
26 #include "utils/reltrigger.h"
27 #include "utils/sharedtuplestore.h"
28 #include "utils/sortsupport.h"
29 #include "utils/tuplestore.h"
30 #include "utils/tuplesort.h"
31 #include "nodes/tidbitmap.h"
33 
34 
35 struct PlanState; /* forward references in this file */
37 struct ExprState;
38 struct ExprContext;
39 struct ExprEvalStep; /* avoid including execExpr.h everywhere */
40 
41 
42 /* ----------------
43  * ExprState node
44  *
45  * ExprState is the top-level node for expression evaluation.
46  * It contains instructions (in ->steps) to evaluate the expression.
47  * ----------------
48  */
49 typedef Datum (*ExprStateEvalFunc) (struct ExprState *expression,
50  struct ExprContext *econtext,
51  bool *isNull);
52 
53 /* Bits in ExprState->flags (see also execExpr.h for private flag bits): */
54 /* expression is for use with ExecQual() */
55 #define EEO_FLAG_IS_QUAL (1 << 0)
56 
57 typedef struct ExprState
58 {
60 
61  uint8 flags; /* bitmask of EEO_FLAG_* bits, see above */
62 
63  /*
64  * Storage for result value of a scalar expression, or for individual
65  * column results within expressions built by ExecBuildProjectionInfo().
66  */
67 #define FIELDNO_EXPRSTATE_RESNULL 2
68  bool resnull;
69 #define FIELDNO_EXPRSTATE_RESVALUE 3
71 
72  /*
73  * If projecting a tuple result, this slot holds the result; else NULL.
74  */
75 #define FIELDNO_EXPRSTATE_RESULTSLOT 4
77 
78  /*
79  * Instructions to compute expression's return value.
80  */
82 
83  /*
84  * Function that actually evaluates the expression. This can be set to
85  * different values depending on the complexity of the expression.
86  */
88 
89  /* original expression tree, for debugging only */
91 
92  /* private state for an evalfunc */
94 
95  /*
96  * XXX: following fields only needed during "compilation" (ExecInitExpr);
97  * could be thrown away afterwards.
98  */
99 
100  int steps_len; /* number of steps currently */
101  int steps_alloc; /* allocated length of steps array */
102 
103  struct PlanState *parent; /* parent PlanState node, if any */
104  ParamListInfo ext_params; /* for compiling PARAM_EXTERN nodes */
105 
108 
111 } ExprState;
112 
113 
114 /* ----------------
115  * IndexInfo information
116  *
117  * this struct holds the information needed to construct new index
118  * entries for a particular index. Used for both index_build and
119  * retail creation of index entries.
120  *
121  * NumIndexAttrs total number of columns in this index
122  * NumIndexKeyAttrs number of key columns in index
123  * KeyAttrNumbers underlying-rel attribute numbers used as keys
124  * (zeroes indicate expressions). It also contains
125  * info about included columns.
126  * Expressions expr trees for expression entries, or NIL if none
127  * ExpressionsState exec state for expressions, or NIL if none
128  * Predicate partial-index predicate, or NIL if none
129  * PredicateState exec state for predicate, or NIL if none
130  * ExclusionOps Per-column exclusion operators, or NULL if none
131  * ExclusionProcs Underlying function OIDs for ExclusionOps
132  * ExclusionStrats Opclass strategy numbers for ExclusionOps
133  * UniqueOps Theses are like Exclusion*, but for unique indexes
134  * UniqueProcs
135  * UniqueStrats
136  * Unique is it a unique index?
137  * ReadyForInserts is it valid for inserts?
138  * Concurrent are we doing a concurrent index build?
139  * BrokenHotChain did we detect any broken HOT chains?
140  * ParallelWorkers # of workers requested (excludes leader)
141  * AmCache private cache area for index AM
142  * Context memory context holding this IndexInfo
143  *
144  * ii_Concurrent, ii_BrokenHotChain, and ii_ParallelWorkers are used only
145  * during index build; they're conventionally zeroed otherwise.
146  * ----------------
147  */
148 typedef struct IndexInfo
149 {
151  int ii_NumIndexAttrs; /* total number of columns in index */
152  int ii_NumIndexKeyAttrs; /* number of key columns in index */
153  AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS];
154  List *ii_Expressions; /* list of Expr */
155  List *ii_ExpressionsState; /* list of ExprState */
156  List *ii_Predicate; /* list of Expr */
158  Oid *ii_ExclusionOps; /* array with one entry per column */
159  Oid *ii_ExclusionProcs; /* array with one entry per column */
160  uint16 *ii_ExclusionStrats; /* array with one entry per column */
161  Oid *ii_UniqueOps; /* array with one entry per column */
162  Oid *ii_UniqueProcs; /* array with one entry per column */
163  uint16 *ii_UniqueStrats; /* array with one entry per column */
164  bool ii_Unique;
170  void *ii_AmCache;
172 } IndexInfo;
173 
174 /* ----------------
175  * ExprContext_CB
176  *
177  * List of callbacks to be called at ExprContext shutdown.
178  * ----------------
179  */
181 
182 typedef struct ExprContext_CB
183 {
188 
189 /* ----------------
190  * ExprContext
191  *
192  * This class holds the "current context" information
193  * needed to evaluate expressions for doing tuple qualifications
194  * and tuple projections. For example, if an expression refers
195  * to an attribute in the current inner tuple then we need to know
196  * what the current inner tuple is and so we look at the expression
197  * context.
198  *
199  * There are two memory contexts associated with an ExprContext:
200  * * ecxt_per_query_memory is a query-lifespan context, typically the same
201  * context the ExprContext node itself is allocated in. This context
202  * can be used for purposes such as storing function call cache info.
203  * * ecxt_per_tuple_memory is a short-term context for expression results.
204  * As the name suggests, it will typically be reset once per tuple,
205  * before we begin to evaluate expressions for that tuple. Each
206  * ExprContext normally has its very own per-tuple memory context.
207  *
208  * CurrentMemoryContext should be set to ecxt_per_tuple_memory before
209  * calling ExecEvalExpr() --- see ExecEvalExprSwitchContext().
210  * ----------------
211  */
212 typedef struct ExprContext
213 {
215 
216  /* Tuples that Var nodes in expression may refer to */
217 #define FIELDNO_EXPRCONTEXT_SCANTUPLE 1
219 #define FIELDNO_EXPRCONTEXT_INNERTUPLE 2
221 #define FIELDNO_EXPRCONTEXT_OUTERTUPLE 3
223 
224  /* Memory contexts for expression evaluation --- see notes above */
227 
228  /* Values to substitute for Param nodes in expression */
229  ParamExecData *ecxt_param_exec_vals; /* for PARAM_EXEC params */
230  ParamListInfo ecxt_param_list_info; /* for other param types */
231 
232  /*
233  * Values to substitute for Aggref nodes in the expressions of an Agg
234  * node, or for WindowFunc nodes within a WindowAgg node.
235  */
236 #define FIELDNO_EXPRCONTEXT_AGGVALUES 8
237  Datum *ecxt_aggvalues; /* precomputed values for aggs/windowfuncs */
238 #define FIELDNO_EXPRCONTEXT_AGGNULLS 9
239  bool *ecxt_aggnulls; /* null flags for aggs/windowfuncs */
240 
241  /* Value to substitute for CaseTestExpr nodes in expression */
242 #define FIELDNO_EXPRCONTEXT_CASEDATUM 10
244 #define FIELDNO_EXPRCONTEXT_CASENULL 11
246 
247  /* Value to substitute for CoerceToDomainValue nodes in expression */
248 #define FIELDNO_EXPRCONTEXT_DOMAINDATUM 12
250 #define FIELDNO_EXPRCONTEXT_DOMAINNULL 13
252 
253  /* Link to containing EState (NULL if a standalone ExprContext) */
255 
256  /* Functions to call back when ExprContext is shut down or rescanned */
258 } ExprContext;
259 
260 /*
261  * Set-result status used when evaluating functions potentially returning a
262  * set.
263  */
264 typedef enum
265 {
266  ExprSingleResult, /* expression does not return a set */
267  ExprMultipleResult, /* this result is an element of a set */
268  ExprEndResult /* there are no more elements in the set */
269 } ExprDoneCond;
270 
271 /*
272  * Return modes for functions returning sets. Note values must be chosen
273  * as separate bits so that a bitmask can be formed to indicate supported
274  * modes. SFRM_Materialize_Random and SFRM_Materialize_Preferred are
275  * auxiliary flags about SFRM_Materialize mode, rather than separate modes.
276  */
277 typedef enum
278 {
279  SFRM_ValuePerCall = 0x01, /* one value returned per call */
280  SFRM_Materialize = 0x02, /* result set instantiated in Tuplestore */
281  SFRM_Materialize_Random = 0x04, /* Tuplestore needs randomAccess */
282  SFRM_Materialize_Preferred = 0x08 /* caller prefers Tuplestore */
284 
285 /*
286  * When calling a function that might return a set (multiple rows),
287  * a node of this type is passed as fcinfo->resultinfo to allow
288  * return status to be passed back. A function returning set should
289  * raise an error if no such resultinfo is provided.
290  */
291 typedef struct ReturnSetInfo
292 {
294  /* values set by caller: */
295  ExprContext *econtext; /* context function is being called in */
296  TupleDesc expectedDesc; /* tuple descriptor expected by caller */
297  int allowedModes; /* bitmask: return modes caller can handle */
298  /* result status from function (but pre-initialized by caller): */
299  SetFunctionReturnMode returnMode; /* actual return mode */
300  ExprDoneCond isDone; /* status for ValuePerCall mode */
301  /* fields filled by function in Materialize return mode: */
302  Tuplestorestate *setResult; /* holds the complete returned tuple set */
303  TupleDesc setDesc; /* actual descriptor for returned tuples */
304 } ReturnSetInfo;
305 
306 /* ----------------
307  * ProjectionInfo node information
308  *
309  * This is all the information needed to perform projections ---
310  * that is, form new tuples by evaluation of targetlist expressions.
311  * Nodes which need to do projections create one of these.
312  *
313  * The target tuple slot is kept in ProjectionInfo->pi_state.resultslot.
314  * ExecProject() evaluates the tlist, forms a tuple, and stores it
315  * in the given slot. Note that the result will be a "virtual" tuple
316  * unless ExecMaterializeSlot() is then called to force it to be
317  * converted to a physical tuple. The slot must have a tupledesc
318  * that matches the output of the tlist!
319  * ----------------
320  */
321 typedef struct ProjectionInfo
322 {
324  /* instructions to evaluate projection */
326  /* expression context in which to evaluate expression */
329 
330 /* ----------------
331  * JunkFilter
332  *
333  * This class is used to store information regarding junk attributes.
334  * A junk attribute is an attribute in a tuple that is needed only for
335  * storing intermediate information in the executor, and does not belong
336  * in emitted tuples. For example, when we do an UPDATE query,
337  * the planner adds a "junk" entry to the targetlist so that the tuples
338  * returned to ExecutePlan() contain an extra attribute: the ctid of
339  * the tuple to be updated. This is needed to do the update, but we
340  * don't want the ctid to be part of the stored new tuple! So, we
341  * apply a "junk filter" to remove the junk attributes and form the
342  * real output tuple. The junkfilter code also provides routines to
343  * extract the values of the junk attribute(s) from the input tuple.
344  *
345  * targetList: the original target list (including junk attributes).
346  * cleanTupType: the tuple descriptor for the "clean" tuple (with
347  * junk attributes removed).
348  * cleanMap: A map with the correspondence between the non-junk
349  * attribute numbers of the "original" tuple and the
350  * attribute numbers of the "clean" tuple.
351  * resultSlot: tuple slot used to hold cleaned tuple.
352  * junkAttNo: not used by junkfilter code. Can be used by caller
353  * to remember the attno of a specific junk attribute
354  * (nodeModifyTable.c keeps the "ctid" or "wholerow"
355  * attno here).
356  * ----------------
357  */
358 typedef struct JunkFilter
359 {
366 } JunkFilter;
367 
368 /*
369  * OnConflictSetState
370  *
371  * Executor state of an ON CONFLICT DO UPDATE operation.
372  */
373 typedef struct OnConflictSetState
374 {
376 
377  ProjectionInfo *oc_ProjInfo; /* for ON CONFLICT DO UPDATE SET */
378  TupleDesc oc_ProjTupdesc; /* TupleDesc for the above projection */
379  ExprState *oc_WhereClause; /* state for the WHERE clause */
381 
382 /*
383  * ResultRelInfo
384  *
385  * Whenever we update an existing relation, we have to update indexes on the
386  * relation, and perhaps also fire triggers. ResultRelInfo holds all the
387  * information needed about a result relation, including indexes.
388  */
389 typedef struct ResultRelInfo
390 {
392 
393  /* result relation's range table index */
395 
396  /* relation descriptor for result relation */
398 
399  /* # of indices existing on result relation */
401 
402  /* array of relation descriptors for indices */
404 
405  /* array of key/attr info for indices */
407 
408  /* triggers to be fired, if any */
410 
411  /* cached lookup info for trigger functions */
413 
414  /* array of trigger WHEN expr states */
416 
417  /* optional runtime measurements for triggers */
419 
420  /* FDW callback functions, if foreign table */
422 
423  /* available to save private state of FDW */
424  void *ri_FdwState;
425 
426  /* true when modifying foreign table directly */
428 
429  /* list of WithCheckOption's to be checked */
431 
432  /* list of WithCheckOption expr states */
434 
435  /* array of constraint-checking expr states */
437 
438  /* for removing junk attributes from tuples */
440 
441  /* list of RETURNING expressions */
443 
444  /* for computing a RETURNING list */
446 
447  /* list of arbiter indexes to use to check conflicts */
449 
450  /* ON CONFLICT evaluation state */
452 
453  /* partition check expression */
455 
456  /* partition check expression state */
458 
459  /* relation descriptor for root partitioned table */
461 
462  /* true if ready for tuple routing */
464 } ResultRelInfo;
465 
466 /* ----------------
467  * EState information
468  *
469  * Master working state for an Executor invocation
470  * ----------------
471  */
472 typedef struct EState
473 {
475 
476  /* Basic state for all query types: */
477  ScanDirection es_direction; /* current scan direction */
478  Snapshot es_snapshot; /* time qual to use */
479  Snapshot es_crosscheck_snapshot; /* crosscheck time qual for RI */
480  List *es_range_table; /* List of RangeTblEntry */
481  PlannedStmt *es_plannedstmt; /* link to top of plan tree */
482  const char *es_sourceText; /* Source text from QueryDesc */
483 
484  JunkFilter *es_junkFilter; /* top-level junk filter, if any */
485 
486  /* If query can insert/delete tuples, the command ID to mark them with */
488 
489  /* Info about target table(s) for insert/update/delete queries: */
490  ResultRelInfo *es_result_relations; /* array of ResultRelInfos */
491  int es_num_result_relations; /* length of array */
492  ResultRelInfo *es_result_relation_info; /* currently active array elt */
493 
494  /*
495  * Info about the target partitioned target table root(s) for
496  * update/delete queries. They required only to fire any per-statement
497  * triggers defined on the table. It exists separately from
498  * es_result_relations, because partitioned tables don't appear in the
499  * plan tree for the update/delete cases.
500  */
501  ResultRelInfo *es_root_result_relations; /* array of ResultRelInfos */
502  int es_num_root_result_relations; /* length of the array */
503 
504  /*
505  * The following list contains ResultRelInfos created by the tuple
506  * routing code for partitions that don't already have one.
507  */
509 
510  /* Stuff used for firing triggers: */
511  List *es_trig_target_relations; /* trigger-only ResultRelInfos */
512  TupleTableSlot *es_trig_tuple_slot; /* for trigger output tuples */
513  TupleTableSlot *es_trig_oldtup_slot; /* for TriggerEnabled */
514  TupleTableSlot *es_trig_newtup_slot; /* for TriggerEnabled */
515 
516  /* Parameter info: */
517  ParamListInfo es_param_list_info; /* values of external params */
518  ParamExecData *es_param_exec_vals; /* values of internal params */
519 
520  QueryEnvironment *es_queryEnv; /* query environment */
521 
522  /* Other working state: */
523  MemoryContext es_query_cxt; /* per-query context in which EState lives */
524 
525  List *es_tupleTable; /* List of TupleTableSlots */
526 
527  List *es_rowMarks; /* List of ExecRowMarks */
528 
529  uint64 es_processed; /* # of tuples processed */
530  Oid es_lastoid; /* last oid processed (by INSERT) */
531 
532  int es_top_eflags; /* eflags passed to ExecutorStart */
533  int es_instrument; /* OR of InstrumentOption flags */
534  bool es_finished; /* true when ExecutorFinish is done */
535 
536  List *es_exprcontexts; /* List of ExprContexts within EState */
537 
538  List *es_subplanstates; /* List of PlanState for SubPlans */
539 
540  List *es_auxmodifytables; /* List of secondary ModifyTableStates */
541 
542  /*
543  * this ExprContext is for per-output-tuple operations, such as constraint
544  * checks and index-value computations. It will be reset for each output
545  * tuple. Note that it will be created only if needed.
546  */
548 
549  /*
550  * These fields are for re-evaluating plan quals when an updated tuple is
551  * substituted in READ COMMITTED mode. es_epqTuple[] contains tuples that
552  * scan plan nodes should return instead of whatever they'd normally
553  * return, or NULL if nothing to return; es_epqTupleSet[] is true if a
554  * particular array entry is valid; and es_epqScanDone[] is state to
555  * remember if the tuple has been returned already. Arrays are of size
556  * list_length(es_range_table) and are indexed by scan node scanrelid - 1.
557  */
558  HeapTuple *es_epqTuple; /* array of EPQ substitute tuples */
559  bool *es_epqTupleSet; /* true if EPQ tuple is provided */
560  bool *es_epqScanDone; /* true if EPQ tuple has been fetched */
561 
562  bool es_use_parallel_mode; /* can we use parallel workers? */
563 
564  /* The per-query shared memory area to use for parallel execution. */
566 
567  /*
568  * JIT information. es_jit_flags indicates whether JIT should be performed
569  * and with which options. es_jit is created on-demand when JITing is
570  * performed.
571  */
574 } EState;
575 
576 
577 /*
578  * ExecRowMark -
579  * runtime representation of FOR [KEY] UPDATE/SHARE clauses
580  *
581  * When doing UPDATE, DELETE, or SELECT FOR [KEY] UPDATE/SHARE, we will have an
582  * ExecRowMark for each non-target relation in the query (except inheritance
583  * parent RTEs, which can be ignored at runtime). Virtual relations such as
584  * subqueries-in-FROM will have an ExecRowMark with relation == NULL. See
585  * PlanRowMark for details about most of the fields. In addition to fields
586  * directly derived from PlanRowMark, we store an activity flag (to denote
587  * inactive children of inheritance trees), curCtid, which is used by the
588  * WHERE CURRENT OF code, and ermExtra, which is available for use by the plan
589  * node that sources the relation (e.g., for a foreign table the FDW can use
590  * ermExtra to hold information).
591  *
592  * EState->es_rowMarks is a list of these structs.
593  */
594 typedef struct ExecRowMark
595 {
596  Relation relation; /* opened and suitably locked relation */
597  Oid relid; /* its OID (or InvalidOid, if subquery) */
598  Index rti; /* its range table index */
599  Index prti; /* parent range table index, if child */
600  Index rowmarkId; /* unique identifier for resjunk columns */
601  RowMarkType markType; /* see enum in nodes/plannodes.h */
602  LockClauseStrength strength; /* LockingClause's strength, or LCS_NONE */
603  LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */
604  bool ermActive; /* is this mark relevant for current tuple? */
605  ItemPointerData curCtid; /* ctid of currently locked tuple, if any */
606  void *ermExtra; /* available for use by relation source node */
607 } ExecRowMark;
608 
609 /*
610  * ExecAuxRowMark -
611  * additional runtime representation of FOR [KEY] UPDATE/SHARE clauses
612  *
613  * Each LockRows and ModifyTable node keeps a list of the rowmarks it needs to
614  * deal with. In addition to a pointer to the related entry in es_rowMarks,
615  * this struct carries the column number(s) of the resjunk columns associated
616  * with the rowmark (see comments for PlanRowMark for more detail). In the
617  * case of ModifyTable, there has to be a separate ExecAuxRowMark list for
618  * each child plan, because the resjunk columns could be at different physical
619  * column positions in different subplans.
620  */
621 typedef struct ExecAuxRowMark
622 {
623  ExecRowMark *rowmark; /* related entry in es_rowMarks */
624  AttrNumber ctidAttNo; /* resno of ctid junk attribute, if any */
625  AttrNumber toidAttNo; /* resno of tableoid junk attribute, if any */
626  AttrNumber wholeAttNo; /* resno of whole-row junk attribute, if any */
628 
629 
630 /* ----------------------------------------------------------------
631  * Tuple Hash Tables
632  *
633  * All-in-memory tuple hash tables are used for a number of purposes.
634  *
635  * Note: tab_hash_funcs are for the key datatype(s) stored in the table,
636  * and tab_eq_funcs are non-cross-type equality operators for those types.
637  * Normally these are the only functions used, but FindTupleHashEntry()
638  * supports searching a hashtable using cross-data-type hashing. For that,
639  * the caller must supply hash functions for the LHS datatype as well as
640  * the cross-type equality operators to use. in_hash_funcs and cur_eq_func
641  * are set to point to the caller's function arrays while doing such a search.
642  * During LookupTupleHashEntry(), they point to tab_hash_funcs and
643  * tab_eq_func respectively.
644  * ----------------------------------------------------------------
645  */
648 
649 typedef struct TupleHashEntryData
650 {
651  MinimalTuple firstTuple; /* copy of first tuple in this group */
652  void *additional; /* user data */
653  uint32 status; /* hash status */
654  uint32 hash; /* hash value (cached) */
656 
657 /* define parameters necessary to generate the tuple hash table interface */
658 #define SH_PREFIX tuplehash
659 #define SH_ELEMENT_TYPE TupleHashEntryData
660 #define SH_KEY_TYPE MinimalTuple
661 #define SH_SCOPE extern
662 #define SH_DECLARE
663 #include "lib/simplehash.h"
664 
665 typedef struct TupleHashTableData
666 {
667  tuplehash_hash *hashtab; /* underlying hash table */
668  int numCols; /* number of columns in lookup key */
669  AttrNumber *keyColIdx; /* attr numbers of key columns */
670  FmgrInfo *tab_hash_funcs; /* hash functions for table datatype(s) */
671  ExprState *tab_eq_func; /* comparator for table datatype(s) */
672  MemoryContext tablecxt; /* memory context containing table */
673  MemoryContext tempcxt; /* context for function evaluations */
674  Size entrysize; /* actual size to make each hash entry */
675  TupleTableSlot *tableslot; /* slot for referencing table entries */
676  /* The following fields are set transiently for each table search: */
677  TupleTableSlot *inputslot; /* current input tuple's slot */
678  FmgrInfo *in_hash_funcs; /* hash functions for input datatype(s) */
679  ExprState *cur_eq_func; /* comparator for for input vs. table */
680  uint32 hash_iv; /* hash-function IV */
681  ExprContext *exprcontext; /* expression context */
683 
684 typedef tuplehash_iterator TupleHashIterator;
685 
686 /*
687  * Use InitTupleHashIterator/TermTupleHashIterator for a read/write scan.
688  * Use ResetTupleHashIterator if the table can be frozen (in this case no
689  * explicit scan termination is needed).
690  */
691 #define InitTupleHashIterator(htable, iter) \
692  tuplehash_start_iterate(htable->hashtab, iter)
693 #define TermTupleHashIterator(iter) \
694  ((void) 0)
695 #define ResetTupleHashIterator(htable, iter) \
696  InitTupleHashIterator(htable, iter)
697 #define ScanTupleHashTable(htable, iter) \
698  tuplehash_iterate(htable->hashtab, iter)
699 
700 
701 /* ----------------------------------------------------------------
702  * Expression State Nodes
703  *
704  * Formerly, there was a separate executor expression state node corresponding
705  * to each node in a planned expression tree. That's no longer the case; for
706  * common expression node types, all the execution info is embedded into
707  * step(s) in a single ExprState node. But we still have a few executor state
708  * node types for selected expression node types, mostly those in which info
709  * has to be shared with other parts of the execution state tree.
710  * ----------------------------------------------------------------
711  */
712 
713 /* ----------------
714  * AggrefExprState node
715  * ----------------
716  */
717 typedef struct AggrefExprState
718 {
720  Aggref *aggref; /* expression plan node */
721  int aggno; /* ID number for agg within its plan node */
723 
724 /* ----------------
725  * WindowFuncExprState node
726  * ----------------
727  */
728 typedef struct WindowFuncExprState
729 {
731  WindowFunc *wfunc; /* expression plan node */
732  List *args; /* ExprStates for argument expressions */
733  ExprState *aggfilter; /* FILTER expression */
734  int wfuncno; /* ID number for wfunc within its plan node */
736 
737 
738 /* ----------------
739  * SetExprState node
740  *
741  * State for evaluating a potentially set-returning expression (like FuncExpr
742  * or OpExpr). In some cases, like some of the expressions in ROWS FROM(...)
743  * the expression might not be a SRF, but nonetheless it uses the same
744  * machinery as SRFs; it will be treated as a SRF returning a single row.
745  * ----------------
746  */
747 typedef struct SetExprState
748 {
750  Expr *expr; /* expression plan node */
751  List *args; /* ExprStates for argument expressions */
752 
753  /*
754  * In ROWS FROM, functions can be inlined, removing the FuncExpr normally
755  * inside. In such a case this is the compiled expression (which cannot
756  * return a set), which'll be evaluated using regular ExecEvalExpr().
757  */
759 
760  /*
761  * Function manager's lookup info for the target function. If func.fn_oid
762  * is InvalidOid, we haven't initialized it yet (nor any of the following
763  * fields, except funcReturnsSet).
764  */
766 
767  /*
768  * For a set-returning function (SRF) that returns a tuplestore, we keep
769  * the tuplestore here and dole out the result rows one at a time. The
770  * slot holds the row currently being returned.
771  */
774 
775  /*
776  * In some cases we need to compute a tuple descriptor for the function's
777  * output. If so, it's stored here.
778  */
780  bool funcReturnsTuple; /* valid when funcResultDesc isn't NULL */
781 
782  /*
783  * Remember whether the function is declared to return a set. This is set
784  * by ExecInitExpr, and is valid even before the FmgrInfo is set up.
785  */
787 
788  /*
789  * setArgsValid is true when we are evaluating a set-returning function
790  * that uses value-per-call mode and we are in the middle of a call
791  * series; we want to pass the same argument values to the function again
792  * (and again, until it returns ExprEndResult). This indicates that
793  * fcinfo_data already contains valid argument data.
794  */
796 
797  /*
798  * Flag to remember whether we have registered a shutdown callback for
799  * this SetExprState. We do so only if funcResultStore or setArgsValid
800  * has been set at least once (since all the callback is for is to release
801  * the tuplestore or clear setArgsValid).
802  */
803  bool shutdown_reg; /* a shutdown callback is registered */
804 
805  /*
806  * Call parameter structure for the function. This has been initialized
807  * (by InitFunctionCallInfoData) if func.fn_oid is valid. It also saves
808  * argument values between calls, when setArgsValid is true.
809  */
811 } SetExprState;
812 
813 /* ----------------
814  * SubPlanState node
815  * ----------------
816  */
817 typedef struct SubPlanState
818 {
820  SubPlan *subplan; /* expression plan node */
821  struct PlanState *planstate; /* subselect plan's state tree */
822  struct PlanState *parent; /* parent plan node's state tree */
823  ExprState *testexpr; /* state of combining expression */
824  List *args; /* states of argument expression(s) */
825  HeapTuple curTuple; /* copy of most recent tuple from subplan */
826  Datum curArray; /* most recent array from ARRAY() subplan */
827  /* these are used when hashing the subselect's output: */
828  TupleDesc descRight; /* subselect desc after projection */
829  ProjectionInfo *projLeft; /* for projecting lefthand exprs */
830  ProjectionInfo *projRight; /* for projecting subselect output */
831  TupleHashTable hashtable; /* hash table for no-nulls subselect rows */
832  TupleHashTable hashnulls; /* hash table for rows with null(s) */
833  bool havehashrows; /* true if hashtable is not empty */
834  bool havenullrows; /* true if hashnulls is not empty */
835  MemoryContext hashtablecxt; /* memory context containing hash tables */
836  MemoryContext hashtempcxt; /* temp memory context for hash tables */
837  ExprContext *innerecontext; /* econtext for computing inner tuples */
838  AttrNumber *keyColIdx; /* control data for hash tables */
839  Oid *tab_eq_funcoids;/* equality func oids for table datatype(s) */
840  FmgrInfo *tab_hash_funcs; /* hash functions for table datatype(s) */
841  FmgrInfo *tab_eq_funcs; /* equality functions for table datatype(s) */
842  FmgrInfo *lhs_hash_funcs; /* hash functions for lefthand datatype(s) */
843  FmgrInfo *cur_eq_funcs; /* equality functions for LHS vs. table */
844  ExprState *cur_eq_comp; /* equality comparator for LHS vs. table */
845 } SubPlanState;
846 
847 /* ----------------
848  * AlternativeSubPlanState node
849  * ----------------
850  */
852 {
854  AlternativeSubPlan *subplan; /* expression plan node */
855  List *subplans; /* SubPlanStates of alternative subplans */
856  int active; /* list index of the one we're using */
858 
859 /*
860  * DomainConstraintState - one item to check during CoerceToDomain
861  *
862  * Note: we consider this to be part of an ExprState tree, so we give it
863  * a name following the xxxState convention. But there's no directly
864  * associated plan-tree node.
865  */
867 {
871 
872 typedef struct DomainConstraintState
873 {
875  DomainConstraintType constrainttype; /* constraint type */
876  char *name; /* name of constraint (for error msgs) */
877  Expr *check_expr; /* for CHECK, a boolean expression */
878  ExprState *check_exprstate; /* check_expr's eval state, or NULL */
880 
881 
882 /* ----------------------------------------------------------------
883  * Executor State Trees
884  *
885  * An executing query has a PlanState tree paralleling the Plan tree
886  * that describes the plan.
887  * ----------------------------------------------------------------
888  */
889 
890 /* ----------------
891  * ExecProcNodeMtd
892  *
893  * This is the method called by ExecProcNode to return the next tuple
894  * from an executor node. It returns NULL, or an empty TupleTableSlot,
895  * if no more tuples are available.
896  * ----------------
897  */
898 typedef TupleTableSlot *(*ExecProcNodeMtd) (struct PlanState *pstate);
899 
900 /* ----------------
901  * PlanState node
902  *
903  * We never actually instantiate any PlanState nodes; this is just the common
904  * abstract superclass for all PlanState-type nodes.
905  * ----------------
906  */
907 typedef struct PlanState
908 {
910 
911  Plan *plan; /* associated Plan node */
912 
913  EState *state; /* at execution time, states of individual
914  * nodes point to one EState for the whole
915  * top-level plan */
916 
917  ExecProcNodeMtd ExecProcNode; /* function to return next tuple */
918  ExecProcNodeMtd ExecProcNodeReal; /* actual function, if above is a
919  * wrapper */
920 
921  Instrumentation *instrument; /* Optional runtime stats for this node */
922  WorkerInstrumentation *worker_instrument; /* per-worker instrumentation */
923 
924  /*
925  * Common structural data for all Plan types. These links to subsidiary
926  * state trees parallel links in the associated plan tree (except for the
927  * subPlan list, which does not exist in the plan tree).
928  */
929  ExprState *qual; /* boolean qual condition */
930  struct PlanState *lefttree; /* input plan tree(s) */
932 
933  List *initPlan; /* Init SubPlanState nodes (un-correlated expr
934  * subselects) */
935  List *subPlan; /* SubPlanState nodes in my expressions */
936 
937  /*
938  * State for management of parameter-change-driven rescanning
939  */
940  Bitmapset *chgParam; /* set of IDs of changed Params */
941 
942  /*
943  * Other run-time state needed by most if not all node types.
944  */
945  TupleTableSlot *ps_ResultTupleSlot; /* slot for my result tuples */
946  ExprContext *ps_ExprContext; /* node's expression-evaluation context */
947  ProjectionInfo *ps_ProjInfo; /* info for doing tuple projection */
948 
949  /*
950  * Scanslot's descriptor if known. This is a bit of a hack, but otherwise
951  * it's hard for expression compilation to optimize based on the
952  * descriptor, without encoding knowledge about all executor nodes.
953  */
955 } PlanState;
956 
957 /* ----------------
958  * these are defined to avoid confusion problems with "left"
959  * and "right" and "inner" and "outer". The convention is that
960  * the "left" plan is the "outer" plan and the "right" plan is
961  * the inner plan, but these make the code more readable.
962  * ----------------
963  */
964 #define innerPlanState(node) (((PlanState *)(node))->righttree)
965 #define outerPlanState(node) (((PlanState *)(node))->lefttree)
966 
967 /* Macros for inline access to certain instrumentation counters */
968 #define InstrCountTuples2(node, delta) \
969  do { \
970  if (((PlanState *)(node))->instrument) \
971  ((PlanState *)(node))->instrument->ntuples2 += (delta); \
972  } while (0)
973 #define InstrCountFiltered1(node, delta) \
974  do { \
975  if (((PlanState *)(node))->instrument) \
976  ((PlanState *)(node))->instrument->nfiltered1 += (delta); \
977  } while(0)
978 #define InstrCountFiltered2(node, delta) \
979  do { \
980  if (((PlanState *)(node))->instrument) \
981  ((PlanState *)(node))->instrument->nfiltered2 += (delta); \
982  } while(0)
983 
984 /*
985  * EPQState is state for executing an EvalPlanQual recheck on a candidate
986  * tuple in ModifyTable or LockRows. The estate and planstate fields are
987  * NULL if inactive.
988  */
989 typedef struct EPQState
990 {
991  EState *estate; /* subsidiary EState */
992  PlanState *planstate; /* plan state tree ready to be executed */
993  TupleTableSlot *origslot; /* original output tuple to be rechecked */
994  Plan *plan; /* plan tree to be executed */
995  List *arowMarks; /* ExecAuxRowMarks (non-locking only) */
996  int epqParam; /* ID of Param to force scan node re-eval */
997 } EPQState;
998 
999 
1000 /* ----------------
1001  * ResultState information
1002  * ----------------
1003  */
1004 typedef struct ResultState
1005 {
1006  PlanState ps; /* its first field is NodeTag */
1008  bool rs_done; /* are we done? */
1009  bool rs_checkqual; /* do we need to check the qual? */
1010 } ResultState;
1011 
1012 /* ----------------
1013  * ProjectSetState information
1014  *
1015  * Note: at least one of the "elems" will be a SetExprState; the rest are
1016  * regular ExprStates.
1017  * ----------------
1018  */
1019 typedef struct ProjectSetState
1020 {
1021  PlanState ps; /* its first field is NodeTag */
1022  Node **elems; /* array of expression states */
1023  ExprDoneCond *elemdone; /* array of per-SRF is-done states */
1024  int nelems; /* length of elemdone[] array */
1025  bool pending_srf_tuples; /* still evaluating srfs in tlist? */
1026  MemoryContext argcontext; /* context for SRF arguments */
1027 } ProjectSetState;
1028 
1029 /* ----------------
1030  * ModifyTableState information
1031  * ----------------
1032  */
1033 typedef struct ModifyTableState
1034 {
1035  PlanState ps; /* its first field is NodeTag */
1036  CmdType operation; /* INSERT, UPDATE, or DELETE */
1037  bool canSetTag; /* do we set the command tag/es_processed? */
1038  bool mt_done; /* are we done? */
1039  PlanState **mt_plans; /* subplans (one per target rel) */
1040  int mt_nplans; /* number of plans in the array */
1041  int mt_whichplan; /* which one is being executed (0..n-1) */
1042  ResultRelInfo *resultRelInfo; /* per-subplan target relations */
1043  ResultRelInfo *rootResultRelInfo; /* root target relation (partitioned
1044  * table root) */
1045  List **mt_arowmarks; /* per-subplan ExecAuxRowMark lists */
1046  EPQState mt_epqstate; /* for evaluating EvalPlanQual rechecks */
1047  bool fireBSTriggers; /* do we need to fire stmt triggers? */
1048  TupleTableSlot *mt_existing; /* slot to store existing target tuple in */
1049  List *mt_excludedtlist; /* the excluded pseudo relation's tlist */
1050  TupleTableSlot *mt_conflproj; /* CONFLICT ... SET ... projection target */
1051 
1052  /* Tuple-routing support info */
1054 
1055  /* controls transition table population for specified operation */
1057 
1058  /* controls transition table population for INSERT...ON CONFLICT UPDATE */
1060 
1061  /* Per plan map for tuple conversion from child to root */
1064 
1065 /* ----------------
1066  * AppendState information
1067  *
1068  * nplans how many plans are in the array
1069  * whichplan which plan is being executed (0 .. n-1), or a
1070  * special negative value. See nodeAppend.c.
1071  * pruningstate details required to allow partitions to be
1072  * eliminated from the scan, or NULL if not possible.
1073  * valid_subplans for runtime pruning, valid appendplans indexes to
1074  * scan.
1075  * ----------------
1076  */
1077 
1078 struct AppendState;
1079 typedef struct AppendState AppendState;
1080 struct ParallelAppendState;
1082 struct PartitionPruneState;
1083 
1085 {
1086  PlanState ps; /* its first field is NodeTag */
1087  PlanState **appendplans; /* array of PlanStates for my inputs */
1090  int as_first_partial_plan; /* Index of 'appendplans' containing
1091  * the first partial plan */
1092  ParallelAppendState *as_pstate; /* parallel coordination info */
1093  Size pstate_len; /* size of parallel coordination info */
1096  bool (*choose_next_subplan) (AppendState *);
1097 };
1098 
1099 /* ----------------
1100  * MergeAppendState information
1101  *
1102  * nplans how many plans are in the array
1103  * nkeys number of sort key columns
1104  * sortkeys sort keys in SortSupport representation
1105  * slots current output tuple of each subplan
1106  * heap heap of active tuples
1107  * initialized true if we have fetched first tuple from each subplan
1108  * ----------------
1109  */
1110 typedef struct MergeAppendState
1111 {
1112  PlanState ps; /* its first field is NodeTag */
1113  PlanState **mergeplans; /* array of PlanStates for my inputs */
1116  SortSupport ms_sortkeys; /* array of length ms_nkeys */
1117  TupleTableSlot **ms_slots; /* array of length ms_nplans */
1118  struct binaryheap *ms_heap; /* binary heap of slot indices */
1119  bool ms_initialized; /* are subplans started? */
1121 
1122 /* ----------------
1123  * RecursiveUnionState information
1124  *
1125  * RecursiveUnionState is used for performing a recursive union.
1126  *
1127  * recursing T when we're done scanning the non-recursive term
1128  * intermediate_empty T if intermediate_table is currently empty
1129  * working_table working table (to be scanned by recursive term)
1130  * intermediate_table current recursive output (next generation of WT)
1131  * ----------------
1132  */
1133 typedef struct RecursiveUnionState
1134 {
1135  PlanState ps; /* its first field is NodeTag */
1140  /* Remaining fields are unused in UNION ALL case */
1141  Oid *eqfuncoids; /* per-grouping-field equality fns */
1142  FmgrInfo *hashfunctions; /* per-grouping-field hash fns */
1143  MemoryContext tempContext; /* short-term context for comparisons */
1144  TupleHashTable hashtable; /* hash table for tuples already seen */
1145  MemoryContext tableContext; /* memory context containing hash table */
1147 
1148 /* ----------------
1149  * BitmapAndState information
1150  * ----------------
1151  */
1152 typedef struct BitmapAndState
1153 {
1154  PlanState ps; /* its first field is NodeTag */
1155  PlanState **bitmapplans; /* array of PlanStates for my inputs */
1156  int nplans; /* number of input plans */
1157 } BitmapAndState;
1158 
1159 /* ----------------
1160  * BitmapOrState information
1161  * ----------------
1162  */
1163 typedef struct BitmapOrState
1164 {
1165  PlanState ps; /* its first field is NodeTag */
1166  PlanState **bitmapplans; /* array of PlanStates for my inputs */
1167  int nplans; /* number of input plans */
1168 } BitmapOrState;
1169 
1170 /* ----------------------------------------------------------------
1171  * Scan State Information
1172  * ----------------------------------------------------------------
1173  */
1174 
1175 /* ----------------
1176  * ScanState information
1177  *
1178  * ScanState extends PlanState for node types that represent
1179  * scans of an underlying relation. It can also be used for nodes
1180  * that scan the output of an underlying plan node --- in that case,
1181  * only ScanTupleSlot is actually useful, and it refers to the tuple
1182  * retrieved from the subplan.
1183  *
1184  * currentRelation relation being scanned (NULL if none)
1185  * currentScanDesc current scan descriptor for scan (NULL if none)
1186  * ScanTupleSlot pointer to slot in tuple table holding scan tuple
1187  * ----------------
1188  */
1189 typedef struct ScanState
1190 {
1191  PlanState ps; /* its first field is NodeTag */
1195 } ScanState;
1196 
1197 /* ----------------
1198  * SeqScanState information
1199  * ----------------
1200  */
1201 typedef struct SeqScanState
1202 {
1203  ScanState ss; /* its first field is NodeTag */
1204  Size pscan_len; /* size of parallel heap scan descriptor */
1205 } SeqScanState;
1206 
1207 /* ----------------
1208  * SampleScanState information
1209  * ----------------
1210  */
1211 typedef struct SampleScanState
1212 {
1214  List *args; /* expr states for TABLESAMPLE params */
1215  ExprState *repeatable; /* expr state for REPEATABLE expr */
1216  /* use struct pointer to avoid including tsmapi.h here */
1217  struct TsmRoutine *tsmroutine; /* descriptor for tablesample method */
1218  void *tsm_state; /* tablesample method can keep state here */
1219  bool use_bulkread; /* use bulkread buffer access strategy? */
1220  bool use_pagemode; /* use page-at-a-time visibility checking? */
1221  bool begun; /* false means need to call BeginSampleScan */
1222  uint32 seed; /* random seed */
1223 } SampleScanState;
1224 
1225 /*
1226  * These structs store information about index quals that don't have simple
1227  * constant right-hand sides. See comments for ExecIndexBuildScanKeys()
1228  * for discussion.
1229  */
1230 typedef struct
1231 {
1232  ScanKey scan_key; /* scankey to put value into */
1233  ExprState *key_expr; /* expr to evaluate to get value */
1234  bool key_toastable; /* is expr's result a toastable datatype? */
1236 
1237 typedef struct
1238 {
1239  ScanKey scan_key; /* scankey to put value into */
1240  ExprState *array_expr; /* expr to evaluate to get array value */
1241  int next_elem; /* next array element to use */
1242  int num_elems; /* number of elems in current array value */
1243  Datum *elem_values; /* array of num_elems Datums */
1244  bool *elem_nulls; /* array of num_elems is-null flags */
1246 
1247 /* ----------------
1248  * IndexScanState information
1249  *
1250  * indexqualorig execution state for indexqualorig expressions
1251  * indexorderbyorig execution state for indexorderbyorig expressions
1252  * ScanKeys Skey structures for index quals
1253  * NumScanKeys number of ScanKeys
1254  * OrderByKeys Skey structures for index ordering operators
1255  * NumOrderByKeys number of OrderByKeys
1256  * RuntimeKeys info about Skeys that must be evaluated at runtime
1257  * NumRuntimeKeys number of RuntimeKeys
1258  * RuntimeKeysReady true if runtime Skeys have been computed
1259  * RuntimeContext expr context for evaling runtime Skeys
1260  * RelationDesc index relation descriptor
1261  * ScanDesc index scan descriptor
1262  *
1263  * ReorderQueue tuples that need reordering due to re-check
1264  * ReachedEnd have we fetched all tuples from index already?
1265  * OrderByValues values of ORDER BY exprs of last fetched tuple
1266  * OrderByNulls null flags for OrderByValues
1267  * SortSupport for reordering ORDER BY exprs
1268  * OrderByTypByVals is the datatype of order by expression pass-by-value?
1269  * OrderByTypLens typlens of the datatypes of order by expressions
1270  * pscan_len size of parallel index scan descriptor
1271  * ----------------
1272  */
1273 typedef struct IndexScanState
1274 {
1275  ScanState ss; /* its first field is NodeTag */
1288 
1289  /* These are needed for re-checking ORDER BY expr ordering */
1298 } IndexScanState;
1299 
1300 /* ----------------
1301  * IndexOnlyScanState information
1302  *
1303  * indexqual execution state for indexqual expressions
1304  * ScanKeys Skey structures for index quals
1305  * NumScanKeys number of ScanKeys
1306  * OrderByKeys Skey structures for index ordering operators
1307  * NumOrderByKeys number of OrderByKeys
1308  * RuntimeKeys info about Skeys that must be evaluated at runtime
1309  * NumRuntimeKeys number of RuntimeKeys
1310  * RuntimeKeysReady true if runtime Skeys have been computed
1311  * RuntimeContext expr context for evaling runtime Skeys
1312  * RelationDesc index relation descriptor
1313  * ScanDesc index scan descriptor
1314  * VMBuffer buffer in use for visibility map testing, if any
1315  * ioss_PscanLen Size of parallel index-only scan descriptor
1316  * ----------------
1317  */
1318 typedef struct IndexOnlyScanState
1319 {
1320  ScanState ss; /* its first field is NodeTag */
1335 
1336 /* ----------------
1337  * BitmapIndexScanState information
1338  *
1339  * result bitmap to return output into, or NULL
1340  * ScanKeys Skey structures for index quals
1341  * NumScanKeys number of ScanKeys
1342  * RuntimeKeys info about Skeys that must be evaluated at runtime
1343  * NumRuntimeKeys number of RuntimeKeys
1344  * ArrayKeys info about Skeys that come from ScalarArrayOpExprs
1345  * NumArrayKeys number of ArrayKeys
1346  * RuntimeKeysReady true if runtime Skeys have been computed
1347  * RuntimeContext expr context for evaling runtime Skeys
1348  * RelationDesc index relation descriptor
1349  * ScanDesc index scan descriptor
1350  * ----------------
1351  */
1352 typedef struct BitmapIndexScanState
1353 {
1354  ScanState ss; /* its first field is NodeTag */
1367 
1368 /* ----------------
1369  * SharedBitmapState information
1370  *
1371  * BM_INITIAL TIDBitmap creation is not yet started, so first worker
1372  * to see this state will set the state to BM_INPROGRESS
1373  * and that process will be responsible for creating
1374  * TIDBitmap.
1375  * BM_INPROGRESS TIDBitmap creation is in progress; workers need to
1376  * sleep until it's finished.
1377  * BM_FINISHED TIDBitmap creation is done, so now all workers can
1378  * proceed to iterate over TIDBitmap.
1379  * ----------------
1380  */
1381 typedef enum
1382 {
1387 
1388 /* ----------------
1389  * ParallelBitmapHeapState information
1390  * tbmiterator iterator for scanning current pages
1391  * prefetch_iterator iterator for prefetching ahead of current page
1392  * mutex mutual exclusion for the prefetching variable
1393  * and state
1394  * prefetch_pages # pages prefetch iterator is ahead of current
1395  * prefetch_target current target prefetch distance
1396  * state current state of the TIDBitmap
1397  * cv conditional wait variable
1398  * phs_snapshot_data snapshot data shared to workers
1399  * ----------------
1400  */
1402 {
1410  char phs_snapshot_data[FLEXIBLE_ARRAY_MEMBER];
1412 
1413 /* ----------------
1414  * BitmapHeapScanState information
1415  *
1416  * bitmapqualorig execution state for bitmapqualorig expressions
1417  * tbm bitmap obtained from child index scan(s)
1418  * tbmiterator iterator for scanning current pages
1419  * tbmres current-page data
1420  * can_skip_fetch can we potentially skip tuple fetches in this scan?
1421  * skip_fetch are we skipping tuple fetches on this page?
1422  * vmbuffer buffer for visibility-map lookups
1423  * pvmbuffer ditto, for prefetched pages
1424  * exact_pages total number of exact pages retrieved
1425  * lossy_pages total number of lossy pages retrieved
1426  * prefetch_iterator iterator for prefetching ahead of current page
1427  * prefetch_pages # pages prefetch iterator is ahead of current
1428  * prefetch_target current target prefetch distance
1429  * prefetch_maximum maximum value for prefetch_target
1430  * pscan_len size of the shared memory for parallel bitmap
1431  * initialized is node is ready to iterate
1432  * shared_tbmiterator shared iterator
1433  * shared_prefetch_iterator shared iterator for prefetching
1434  * pstate shared state for parallel bitmap scan
1435  * ----------------
1436  */
1437 typedef struct BitmapHeapScanState
1438 {
1439  ScanState ss; /* its first field is NodeTag */
1460 
1461 /* ----------------
1462  * TidScanState information
1463  *
1464  * tidexprs list of TidExpr structs (see nodeTidscan.c)
1465  * isCurrentOf scan has a CurrentOfExpr qual
1466  * NumTids number of tids in this scan
1467  * TidPtr index of currently fetched tid
1468  * TidList evaluated item pointers (array of size NumTids)
1469  * htup currently-fetched tuple, if any
1470  * ----------------
1471  */
1472 typedef struct TidScanState
1473 {
1474  ScanState ss; /* its first field is NodeTag */
1481 } TidScanState;
1482 
1483 /* ----------------
1484  * SubqueryScanState information
1485  *
1486  * SubqueryScanState is used for scanning a sub-query in the range table.
1487  * ScanTupleSlot references the current output tuple of the sub-query.
1488  * ----------------
1489  */
1490 typedef struct SubqueryScanState
1491 {
1492  ScanState ss; /* its first field is NodeTag */
1495 
1496 /* ----------------
1497  * FunctionScanState information
1498  *
1499  * Function nodes are used to scan the results of a
1500  * function appearing in FROM (typically a function returning set).
1501  *
1502  * eflags node's capability flags
1503  * ordinality is this scan WITH ORDINALITY?
1504  * simple true if we have 1 function and no ordinality
1505  * ordinal current ordinal column value
1506  * nfuncs number of functions being executed
1507  * funcstates per-function execution states (private in
1508  * nodeFunctionscan.c)
1509  * argcontext memory context to evaluate function arguments in
1510  * ----------------
1511  */
1513 
1514 typedef struct FunctionScanState
1515 {
1516  ScanState ss; /* its first field is NodeTag */
1517  int eflags;
1519  bool simple;
1520  int64 ordinal;
1521  int nfuncs;
1522  struct FunctionScanPerFuncState *funcstates; /* array of length nfuncs */
1525 
1526 /* ----------------
1527  * ValuesScanState information
1528  *
1529  * ValuesScan nodes are used to scan the results of a VALUES list
1530  *
1531  * rowcontext per-expression-list context
1532  * exprlists array of expression lists being evaluated
1533  * array_len size of array
1534  * curr_idx current array index (0-based)
1535  *
1536  * Note: ss.ps.ps_ExprContext is used to evaluate any qual or projection
1537  * expressions attached to the node. We create a second ExprContext,
1538  * rowcontext, in which to build the executor expression state for each
1539  * Values sublist. Resetting this context lets us get rid of expression
1540  * state for each row, avoiding major memory leakage over a long values list.
1541  * ----------------
1542  */
1543 typedef struct ValuesScanState
1544 {
1545  ScanState ss; /* its first field is NodeTag */
1550 } ValuesScanState;
1551 
1552 /* ----------------
1553  * TableFuncScanState node
1554  *
1555  * Used in table-expression functions like XMLTABLE.
1556  * ----------------
1557  */
1558 typedef struct TableFuncScanState
1559 {
1560  ScanState ss; /* its first field is NodeTag */
1561  ExprState *docexpr; /* state for document expression */
1562  ExprState *rowexpr; /* state for row-generating expression */
1563  List *colexprs; /* state for column-generating expression */
1564  List *coldefexprs; /* state for column default expressions */
1565  List *ns_names; /* list of str nodes with namespace names */
1566  List *ns_uris; /* list of states of namespace uri exprs */
1567  Bitmapset *notnulls; /* nullability flag for each output column */
1568  void *opaque; /* table builder private space */
1569  const struct TableFuncRoutine *routine; /* table builder methods */
1570  FmgrInfo *in_functions; /* input function for each column */
1571  Oid *typioparams; /* typioparam for each column */
1572  int64 ordinal; /* row number to be output next */
1573  MemoryContext perValueCxt; /* short life context for value evaluation */
1574  Tuplestorestate *tupstore; /* output tuple store */
1576 
1577 /* ----------------
1578  * CteScanState information
1579  *
1580  * CteScan nodes are used to scan a CommonTableExpr query.
1581  *
1582  * Multiple CteScan nodes can read out from the same CTE query. We use
1583  * a tuplestore to hold rows that have been read from the CTE query but
1584  * not yet consumed by all readers.
1585  * ----------------
1586  */
1587 typedef struct CteScanState
1588 {
1589  ScanState ss; /* its first field is NodeTag */
1590  int eflags; /* capability flags to pass to tuplestore */
1591  int readptr; /* index of my tuplestore read pointer */
1592  PlanState *cteplanstate; /* PlanState for the CTE query itself */
1593  /* Link to the "leader" CteScanState (possibly this same node) */
1595  /* The remaining fields are only valid in the "leader" CteScanState */
1596  Tuplestorestate *cte_table; /* rows already read from the CTE query */
1597  bool eof_cte; /* reached end of CTE query? */
1598 } CteScanState;
1599 
1600 /* ----------------
1601  * NamedTuplestoreScanState information
1602  *
1603  * NamedTuplestoreScan nodes are used to scan a Tuplestore created and
1604  * named prior to execution of the query. An example is a transition
1605  * table for an AFTER trigger.
1606  *
1607  * Multiple NamedTuplestoreScan nodes can read out from the same Tuplestore.
1608  * ----------------
1609  */
1611 {
1612  ScanState ss; /* its first field is NodeTag */
1613  int readptr; /* index of my tuplestore read pointer */
1614  TupleDesc tupdesc; /* format of the tuples in the tuplestore */
1615  Tuplestorestate *relation; /* the rows */
1617 
1618 /* ----------------
1619  * WorkTableScanState information
1620  *
1621  * WorkTableScan nodes are used to scan the work table created by
1622  * a RecursiveUnion node. We locate the RecursiveUnion node
1623  * during executor startup.
1624  * ----------------
1625  */
1626 typedef struct WorkTableScanState
1627 {
1628  ScanState ss; /* its first field is NodeTag */
1631 
1632 /* ----------------
1633  * ForeignScanState information
1634  *
1635  * ForeignScan nodes are used to scan foreign-data tables.
1636  * ----------------
1637  */
1638 typedef struct ForeignScanState
1639 {
1640  ScanState ss; /* its first field is NodeTag */
1641  ExprState *fdw_recheck_quals; /* original quals not in ss.ps.qual */
1642  Size pscan_len; /* size of parallel coordination information */
1643  /* use struct pointer to avoid including fdwapi.h here */
1645  void *fdw_state; /* foreign-data wrapper can keep state here */
1647 
1648 /* ----------------
1649  * CustomScanState information
1650  *
1651  * CustomScan nodes are used to execute custom code within executor.
1652  *
1653  * Core code must avoid assuming that the CustomScanState is only as large as
1654  * the structure declared here; providers are allowed to make it the first
1655  * element in a larger structure, and typically would need to do so. The
1656  * struct is actually allocated by the CreateCustomScanState method associated
1657  * with the plan node. Any additional fields can be initialized there, or in
1658  * the BeginCustomScan method.
1659  * ----------------
1660  */
1661 struct CustomExecMethods;
1662 
1663 typedef struct CustomScanState
1664 {
1666  uint32 flags; /* mask of CUSTOMPATH_* flags, see
1667  * nodes/extensible.h */
1668  List *custom_ps; /* list of child PlanState nodes, if any */
1669  Size pscan_len; /* size of parallel coordination information */
1671 } CustomScanState;
1672 
1673 /* ----------------------------------------------------------------
1674  * Join State Information
1675  * ----------------------------------------------------------------
1676  */
1677 
1678 /* ----------------
1679  * JoinState information
1680  *
1681  * Superclass for state nodes of join plans.
1682  * ----------------
1683  */
1684 typedef struct JoinState
1685 {
1688  bool single_match; /* True if we should skip to next outer tuple
1689  * after finding one inner match */
1690  ExprState *joinqual; /* JOIN quals (in addition to ps.qual) */
1691 } JoinState;
1692 
1693 /* ----------------
1694  * NestLoopState information
1695  *
1696  * NeedNewOuter true if need new outer tuple on next call
1697  * MatchedOuter true if found a join match for current outer tuple
1698  * NullInnerTupleSlot prepared null tuple for left outer joins
1699  * ----------------
1700  */
1701 typedef struct NestLoopState
1702 {
1703  JoinState js; /* its first field is NodeTag */
1707 } NestLoopState;
1708 
1709 /* ----------------
1710  * MergeJoinState information
1711  *
1712  * NumClauses number of mergejoinable join clauses
1713  * Clauses info for each mergejoinable clause
1714  * JoinState current state of ExecMergeJoin state machine
1715  * SkipMarkRestore true if we may skip Mark and Restore operations
1716  * ExtraMarks true to issue extra Mark operations on inner scan
1717  * ConstFalseJoin true if we have a constant-false joinqual
1718  * FillOuter true if should emit unjoined outer tuples anyway
1719  * FillInner true if should emit unjoined inner tuples anyway
1720  * MatchedOuter true if found a join match for current outer tuple
1721  * MatchedInner true if found a join match for current inner tuple
1722  * OuterTupleSlot slot in tuple table for cur outer tuple
1723  * InnerTupleSlot slot in tuple table for cur inner tuple
1724  * MarkedTupleSlot slot in tuple table for marked tuple
1725  * NullOuterTupleSlot prepared null tuple for right outer joins
1726  * NullInnerTupleSlot prepared null tuple for left outer joins
1727  * OuterEContext workspace for computing outer tuple's join values
1728  * InnerEContext workspace for computing inner tuple's join values
1729  * ----------------
1730  */
1731 /* private in nodeMergejoin.c: */
1733 
1734 typedef struct MergeJoinState
1735 {
1736  JoinState js; /* its first field is NodeTag */
1738  MergeJoinClause mj_Clauses; /* array of length mj_NumClauses */
1754 } MergeJoinState;
1755 
1756 /* ----------------
1757  * HashJoinState information
1758  *
1759  * hashclauses original form of the hashjoin condition
1760  * hj_OuterHashKeys the outer hash keys in the hashjoin condition
1761  * hj_InnerHashKeys the inner hash keys in the hashjoin condition
1762  * hj_HashOperators the join operators in the hashjoin condition
1763  * hj_HashTable hash table for the hashjoin
1764  * (NULL if table not built yet)
1765  * hj_CurHashValue hash value for current outer tuple
1766  * hj_CurBucketNo regular bucket# for current outer tuple
1767  * hj_CurSkewBucketNo skew bucket# for current outer tuple
1768  * hj_CurTuple last inner tuple matched to current outer
1769  * tuple, or NULL if starting search
1770  * (hj_CurXXX variables are undefined if
1771  * OuterTupleSlot is empty!)
1772  * hj_OuterTupleSlot tuple slot for outer tuples
1773  * hj_HashTupleSlot tuple slot for inner (hashed) tuples
1774  * hj_NullOuterTupleSlot prepared null tuple for right/full outer joins
1775  * hj_NullInnerTupleSlot prepared null tuple for left/full outer joins
1776  * hj_FirstOuterTupleSlot first tuple retrieved from outer plan
1777  * hj_JoinState current state of ExecHashJoin state machine
1778  * hj_MatchedOuter true if found a join match for current outer
1779  * hj_OuterNotEmpty true if outer relation known not empty
1780  * ----------------
1781  */
1782 
1783 /* these structs are defined in executor/hashjoin.h: */
1786 
1787 typedef struct HashJoinState
1788 {
1789  JoinState js; /* its first field is NodeTag */
1791  List *hj_OuterHashKeys; /* list of ExprState nodes */
1792  List *hj_InnerHashKeys; /* list of ExprState nodes */
1793  List *hj_HashOperators; /* list of operator OIDs */
1794  HashJoinTable hj_HashTable;
1798  HashJoinTuple hj_CurTuple;
1807 } HashJoinState;
1808 
1809 
1810 /* ----------------------------------------------------------------
1811  * Materialization State Information
1812  * ----------------------------------------------------------------
1813  */
1814 
1815 /* ----------------
1816  * MaterialState information
1817  *
1818  * materialize nodes are used to materialize the results
1819  * of a subplan into a temporary file.
1820  *
1821  * ss.ss_ScanTupleSlot refers to output of underlying plan.
1822  * ----------------
1823  */
1824 typedef struct MaterialState
1825 {
1826  ScanState ss; /* its first field is NodeTag */
1827  int eflags; /* capability flags to pass to tuplestore */
1828  bool eof_underlying; /* reached end of underlying plan? */
1830 } MaterialState;
1831 
1832 /* ----------------
1833  * Shared memory container for per-worker sort information
1834  * ----------------
1835  */
1836 typedef struct SharedSortInfo
1837 {
1839  TuplesortInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
1840 } SharedSortInfo;
1841 
1842 /* ----------------
1843  * SortState information
1844  * ----------------
1845  */
1846 typedef struct SortState
1847 {
1848  ScanState ss; /* its first field is NodeTag */
1849  bool randomAccess; /* need random access to sort output? */
1850  bool bounded; /* is the result set bounded? */
1851  int64 bound; /* if bounded, how many tuples are needed */
1852  bool sort_Done; /* sort completed yet? */
1853  bool bounded_Done; /* value of bounded we did the sort with */
1854  int64 bound_Done; /* value of bound we did the sort with */
1855  void *tuplesortstate; /* private state of tuplesort.c */
1856  bool am_worker; /* are we a worker? */
1857  SharedSortInfo *shared_info; /* one entry per worker */
1858 } SortState;
1859 
1860 /* ---------------------
1861  * GroupState information
1862  * ---------------------
1863  */
1864 typedef struct GroupState
1865 {
1866  ScanState ss; /* its first field is NodeTag */
1867  ExprState *eqfunction; /* equality function */
1868  bool grp_done; /* indicates completion of Group scan */
1869 } GroupState;
1870 
1871 /* ---------------------
1872  * AggState information
1873  *
1874  * ss.ss_ScanTupleSlot refers to output of underlying plan.
1875  *
1876  * Note: ss.ps.ps_ExprContext contains ecxt_aggvalues and
1877  * ecxt_aggnulls arrays, which hold the computed agg values for the current
1878  * input group during evaluation of an Agg node's output tuple(s). We
1879  * create a second ExprContext, tmpcontext, in which to evaluate input
1880  * expressions and run the aggregate transition functions.
1881  * ---------------------
1882  */
1883 /* these structs are private in nodeAgg.c: */
1889 
1890 typedef struct AggState
1891 {
1892  ScanState ss; /* its first field is NodeTag */
1893  List *aggs; /* all Aggref nodes in targetlist & quals */
1894  int numaggs; /* length of list (could be zero!) */
1895  int numtrans; /* number of pertrans items */
1896  AggStrategy aggstrategy; /* strategy mode */
1897  AggSplit aggsplit; /* agg-splitting mode, see nodes.h */
1898  AggStatePerPhase phase; /* pointer to current phase data */
1899  int numphases; /* number of phases (including phase 0) */
1900  int current_phase; /* current phase number */
1901  AggStatePerAgg peragg; /* per-Aggref information */
1902  AggStatePerTrans pertrans; /* per-Trans state information */
1903  ExprContext *hashcontext; /* econtexts for long-lived data (hashtable) */
1904  ExprContext **aggcontexts; /* econtexts for long-lived data (per GS) */
1905  ExprContext *tmpcontext; /* econtext for input expressions */
1906 #define FIELDNO_AGGSTATE_CURAGGCONTEXT 14
1907  ExprContext *curaggcontext; /* currently active aggcontext */
1908  AggStatePerAgg curperagg; /* currently active aggregate, if any */
1909 #define FIELDNO_AGGSTATE_CURPERTRANS 16
1910  AggStatePerTrans curpertrans; /* currently active trans state, if any */
1911  bool input_done; /* indicates end of input */
1912  bool agg_done; /* indicates completion of Agg scan */
1913  int projected_set; /* The last projected grouping set */
1914 #define FIELDNO_AGGSTATE_CURRENT_SET 20
1915  int current_set; /* The current grouping set being evaluated */
1916  Bitmapset *grouped_cols; /* grouped cols in current projection */
1917  List *all_grouped_cols; /* list of all grouped cols in DESC order */
1918  /* These fields are for grouping set phase data */
1919  int maxsets; /* The max number of sets in any phase */
1920  AggStatePerPhase phases; /* array of all phases */
1921  Tuplesortstate *sort_in; /* sorted input to phases > 1 */
1922  Tuplesortstate *sort_out; /* input is copied here for next phase */
1923  TupleTableSlot *sort_slot; /* slot for sort results */
1924  /* these fields are used in AGG_PLAIN and AGG_SORTED modes: */
1925  AggStatePerGroup *pergroups; /* grouping set indexed array of per-group
1926  * pointers */
1927  HeapTuple grp_firstTuple; /* copy of first tuple of current group */
1928  /* these fields are used in AGG_HASHED and AGG_MIXED modes: */
1929  bool table_filled; /* hash table filled yet? */
1931  AggStatePerHash perhash; /* array of per-hashtable data */
1932  AggStatePerGroup *hash_pergroup; /* grouping set indexed array of
1933  * per-group pointers */
1934 
1935  /* support for evaluation of agg input expressions: */
1936 #define FIELDNO_AGGSTATE_ALL_PERGROUPS 34
1937  AggStatePerGroup *all_pergroups; /* array of first ->pergroups, than
1938  * ->hash_pergroup */
1939  ProjectionInfo *combinedproj; /* projection machinery */
1940 } AggState;
1941 
1942 /* ----------------
1943  * WindowAggState information
1944  * ----------------
1945  */
1946 /* these structs are private in nodeWindowAgg.c: */
1949 
1950 typedef struct WindowAggState
1951 {
1952  ScanState ss; /* its first field is NodeTag */
1953 
1954  /* these fields are filled in by ExecInitExpr: */
1955  List *funcs; /* all WindowFunc nodes in targetlist */
1956  int numfuncs; /* total number of window functions */
1957  int numaggs; /* number that are plain aggregates */
1958 
1959  WindowStatePerFunc perfunc; /* per-window-function information */
1960  WindowStatePerAgg peragg; /* per-plain-aggregate information */
1961  ExprState *partEqfunction; /* equality funcs for partition columns */
1962  ExprState *ordEqfunction; /* equality funcs for ordering columns */
1963  Tuplestorestate *buffer; /* stores rows of current partition */
1964  int current_ptr; /* read pointer # for current row */
1965  int framehead_ptr; /* read pointer # for frame head, if used */
1966  int frametail_ptr; /* read pointer # for frame tail, if used */
1967  int grouptail_ptr; /* read pointer # for group tail, if used */
1968  int64 spooled_rows; /* total # of rows in buffer */
1969  int64 currentpos; /* position of current row in partition */
1970  int64 frameheadpos; /* current frame head position */
1971  int64 frametailpos; /* current frame tail position (frame end+1) */
1972  /* use struct pointer to avoid including windowapi.h here */
1973  struct WindowObjectData *agg_winobj; /* winobj for aggregate fetches */
1974  int64 aggregatedbase; /* start row for current aggregates */
1975  int64 aggregatedupto; /* rows before this one are aggregated */
1976 
1977  int frameOptions; /* frame_clause options, see WindowDef */
1978  ExprState *startOffset; /* expression for starting bound offset */
1979  ExprState *endOffset; /* expression for ending bound offset */
1980  Datum startOffsetValue; /* result of startOffset evaluation */
1981  Datum endOffsetValue; /* result of endOffset evaluation */
1982 
1983  /* these fields are used with RANGE offset PRECEDING/FOLLOWING: */
1984  FmgrInfo startInRangeFunc; /* in_range function for startOffset */
1985  FmgrInfo endInRangeFunc; /* in_range function for endOffset */
1986  Oid inRangeColl; /* collation for in_range tests */
1987  bool inRangeAsc; /* use ASC sort order for in_range tests? */
1988  bool inRangeNullsFirst; /* nulls sort first for in_range tests? */
1989 
1990  /* these fields are used in GROUPS mode: */
1991  int64 currentgroup; /* peer group # of current row in partition */
1992  int64 frameheadgroup; /* peer group # of frame head row */
1993  int64 frametailgroup; /* peer group # of frame tail row */
1994  int64 groupheadpos; /* current row's peer group head position */
1995  int64 grouptailpos; /* " " " " tail position (group end+1) */
1996 
1997  MemoryContext partcontext; /* context for partition-lifespan data */
1998  MemoryContext aggcontext; /* shared context for aggregate working data */
1999  MemoryContext curaggcontext; /* current aggregate's working data */
2000  ExprContext *tmpcontext; /* short-term evaluation context */
2001 
2002  bool all_first; /* true if the scan is starting */
2003  bool all_done; /* true if the scan is finished */
2004  bool partition_spooled; /* true if all tuples in current partition
2005  * have been spooled into tuplestore */
2006  bool more_partitions; /* true if there's more partitions after
2007  * this one */
2008  bool framehead_valid; /* true if frameheadpos is known up to
2009  * date for current row */
2010  bool frametail_valid; /* true if frametailpos is known up to
2011  * date for current row */
2012  bool grouptail_valid; /* true if grouptailpos is known up to
2013  * date for current row */
2014 
2015  TupleTableSlot *first_part_slot; /* first tuple of current or next
2016  * partition */
2017  TupleTableSlot *framehead_slot; /* first tuple of current frame */
2018  TupleTableSlot *frametail_slot; /* first tuple after current frame */
2019 
2020  /* temporary slots for tuples fetched back from tuplestore */
2024 } WindowAggState;
2025 
2026 /* ----------------
2027  * UniqueState information
2028  *
2029  * Unique nodes are used "on top of" sort nodes to discard
2030  * duplicate tuples returned from the sort phase. Basically
2031  * all it does is compare the current tuple from the subplan
2032  * with the previously fetched tuple (stored in its result slot).
2033  * If the two are identical in all interesting fields, then
2034  * we just fetch another tuple from the sort and try again.
2035  * ----------------
2036  */
2037 typedef struct UniqueState
2038 {
2039  PlanState ps; /* its first field is NodeTag */
2040  ExprState *eqfunction; /* tuple equality qual */
2041 } UniqueState;
2042 
2043 /* ----------------
2044  * GatherState information
2045  *
2046  * Gather nodes launch 1 or more parallel workers, run a subplan
2047  * in those workers, and collect the results.
2048  * ----------------
2049  */
2050 typedef struct GatherState
2051 {
2052  PlanState ps; /* its first field is NodeTag */
2053  bool initialized; /* workers launched? */
2054  bool need_to_scan_locally; /* need to read from local plan? */
2055  int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */
2056  /* these fields are set up once: */
2059  /* all remaining fields are reinitialized during a rescan: */
2060  int nworkers_launched; /* original number of workers */
2061  int nreaders; /* number of still-active workers */
2062  int nextreader; /* next one to try to read from */
2063  struct TupleQueueReader **reader; /* array with nreaders active entries */
2064 } GatherState;
2065 
2066 /* ----------------
2067  * GatherMergeState information
2068  *
2069  * Gather merge nodes launch 1 or more parallel workers, run a
2070  * subplan which produces sorted output in each worker, and then
2071  * merge the results into a single sorted stream.
2072  * ----------------
2073  */
2074 struct GMReaderTupleBuffer; /* private in nodeGatherMerge.c */
2075 
2076 typedef struct GatherMergeState
2077 {
2078  PlanState ps; /* its first field is NodeTag */
2079  bool initialized; /* workers launched? */
2080  bool gm_initialized; /* gather_merge_init() done? */
2081  bool need_to_scan_locally; /* need to read from local plan? */
2082  int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */
2083  /* these fields are set up once: */
2084  TupleDesc tupDesc; /* descriptor for subplan result tuples */
2085  int gm_nkeys; /* number of sort columns */
2086  SortSupport gm_sortkeys; /* array of length gm_nkeys */
2088  /* all remaining fields are reinitialized during a rescan */
2089  /* (but the arrays are not reallocated, just cleared) */
2090  int nworkers_launched; /* original number of workers */
2091  int nreaders; /* number of active workers */
2092  TupleTableSlot **gm_slots; /* array with nreaders+1 entries */
2093  struct TupleQueueReader **reader; /* array with nreaders active entries */
2094  struct GMReaderTupleBuffer *gm_tuple_buffers; /* nreaders tuple buffers */
2095  struct binaryheap *gm_heap; /* binary heap of slot indices */
2097 
2098 /* ----------------
2099  * Values displayed by EXPLAIN ANALYZE
2100  * ----------------
2101  */
2102 typedef struct HashInstrumentation
2103 {
2104  int nbuckets; /* number of buckets at end of execution */
2105  int nbuckets_original; /* planned number of buckets */
2106  int nbatch; /* number of batches at end of execution */
2107  int nbatch_original; /* planned number of batches */
2108  size_t space_peak; /* speak memory usage in bytes */
2110 
2111 /* ----------------
2112  * Shared memory container for per-worker hash information
2113  * ----------------
2114  */
2115 typedef struct SharedHashInfo
2116 {
2118  HashInstrumentation hinstrument[FLEXIBLE_ARRAY_MEMBER];
2119 } SharedHashInfo;
2120 
2121 /* ----------------
2122  * HashState information
2123  * ----------------
2124  */
2125 typedef struct HashState
2126 {
2127  PlanState ps; /* its first field is NodeTag */
2128  HashJoinTable hashtable; /* hash table for the hashjoin */
2129  List *hashkeys; /* list of ExprState nodes */
2130  /* hashkeys is same as parent's hj_InnerHashKeys */
2131 
2132  SharedHashInfo *shared_info; /* one entry per worker */
2133  HashInstrumentation *hinstrument; /* this worker's entry */
2134 
2135  /* Parallel hash state. */
2137 } HashState;
2138 
2139 /* ----------------
2140  * SetOpState information
2141  *
2142  * Even in "sorted" mode, SetOp nodes are more complex than a simple
2143  * Unique, since we have to count how many duplicates to return. But
2144  * we also support hashing, so this is really more like a cut-down
2145  * form of Agg.
2146  * ----------------
2147  */
2148 /* this struct is private in nodeSetOp.c: */
2150 
2151 typedef struct SetOpState
2152 {
2153  PlanState ps; /* its first field is NodeTag */
2154  ExprState *eqfunction; /* equality comparator */
2155  Oid *eqfuncoids; /* per-grouping-field equality fns */
2156  FmgrInfo *hashfunctions; /* per-grouping-field hash fns */
2157  bool setop_done; /* indicates completion of output scan */
2158  long numOutput; /* number of dups left to output */
2159  /* these fields are used in SETOP_SORTED mode: */
2160  SetOpStatePerGroup pergroup; /* per-group working state */
2161  HeapTuple grp_firstTuple; /* copy of first tuple of current group */
2162  /* these fields are used in SETOP_HASHED mode: */
2163  TupleHashTable hashtable; /* hash table with one entry per group */
2164  MemoryContext tableContext; /* memory context containing hash table */
2165  bool table_filled; /* hash table filled yet? */
2166  TupleHashIterator hashiter; /* for iterating through hash table */
2167 } SetOpState;
2168 
2169 /* ----------------
2170  * LockRowsState information
2171  *
2172  * LockRows nodes are used to enforce FOR [KEY] UPDATE/SHARE locking.
2173  * ----------------
2174  */
2175 typedef struct LockRowsState
2176 {
2177  PlanState ps; /* its first field is NodeTag */
2178  List *lr_arowMarks; /* List of ExecAuxRowMarks */
2179  EPQState lr_epqstate; /* for evaluating EvalPlanQual rechecks */
2180  HeapTuple *lr_curtuples; /* locked tuples (one entry per RT entry) */
2181  int lr_ntables; /* length of lr_curtuples[] array */
2182 } LockRowsState;
2183 
2184 /* ----------------
2185  * LimitState information
2186  *
2187  * Limit nodes are used to enforce LIMIT/OFFSET clauses.
2188  * They just select the desired subrange of their subplan's output.
2189  *
2190  * offset is the number of initial tuples to skip (0 does nothing).
2191  * count is the number of tuples to return after skipping the offset tuples.
2192  * If no limit count was specified, count is undefined and noCount is true.
2193  * When lstate == LIMIT_INITIAL, offset/count/noCount haven't been set yet.
2194  * ----------------
2195  */
2196 typedef enum
2197 {
2198  LIMIT_INITIAL, /* initial state for LIMIT node */
2199  LIMIT_RESCAN, /* rescan after recomputing parameters */
2200  LIMIT_EMPTY, /* there are no returnable rows */
2201  LIMIT_INWINDOW, /* have returned a row in the window */
2202  LIMIT_SUBPLANEOF, /* at EOF of subplan (within window) */
2203  LIMIT_WINDOWEND, /* stepped off end of window */
2204  LIMIT_WINDOWSTART /* stepped off beginning of window */
2205 } LimitStateCond;
2206 
2207 typedef struct LimitState
2208 {
2209  PlanState ps; /* its first field is NodeTag */
2210  ExprState *limitOffset; /* OFFSET parameter, or NULL if none */
2211  ExprState *limitCount; /* COUNT parameter, or NULL if none */
2212  int64 offset; /* current OFFSET value */
2213  int64 count; /* current COUNT, if any */
2214  bool noCount; /* if true, ignore count */
2215  LimitStateCond lstate; /* state machine status, as above */
2216  int64 position; /* 1-based index of last tuple returned */
2217  TupleTableSlot *subSlot; /* tuple last obtained from subplan */
2218 } LimitState;
2219 
2220 #endif /* EXECNODES_H */
bool ioss_RuntimeKeysReady
Definition: execnodes.h:1328
Datum * elem_values
Definition: execnodes.h:1243
JoinType jointype
Definition: execnodes.h:1687
ExprContext * exprcontext
Definition: execnodes.h:681
signed short int16
Definition: c.h:312
struct AggStatePerTransData * AggStatePerTrans
Definition: execnodes.h:1885
FmgrInfo func
Definition: execnodes.h:765
AttrNumber jf_junkAttNo
Definition: execnodes.h:365
int ri_NumIndices
Definition: execnodes.h:400
int slock_t
Definition: s_lock.h:912
struct ParallelHashJoinState * parallel_state
Definition: execnodes.h:2136
AggStatePerGroup * hash_pergroup
Definition: execnodes.h:1932
Size pstate_len
Definition: execnodes.h:1093
struct GroupState GroupState
uint32 CommandId
Definition: c.h:488
HeapTuple * lr_curtuples
Definition: execnodes.h:2180
Node tag
Definition: execnodes.h:59
ScanState ss
Definition: execnodes.h:1640
IndexRuntimeKeyInfo * biss_RuntimeKeys
Definition: execnodes.h:1358
struct TupleHashTableData TupleHashTableData
struct AggStatePerGroupData * AggStatePerGroup
Definition: execnodes.h:1886
JunkFilter * ri_junkFilter
Definition: execnodes.h:439
MemoryContext ii_Context
Definition: execnodes.h:171
Definition: fmgr.h:56
AttrNumber * jf_cleanMap
Definition: execnodes.h:363
MemoryContext curaggcontext
Definition: execnodes.h:1999
HeapTuple * es_epqTuple
Definition: execnodes.h:558
struct TransitionCaptureState * mt_oc_transition_capture
Definition: execnodes.h:1059
JunkFilter * es_junkFilter
Definition: execnodes.h:484
struct dsa_area * es_query_dsa
Definition: execnodes.h:565
uint16 * ii_UniqueStrats
Definition: execnodes.h:163
NodeTag type
Definition: execnodes.h:909
bool rs_done
Definition: execnodes.h:1008
Relation ri_RelationDesc
Definition: execnodes.h:397
ExprState * endOffset
Definition: execnodes.h:1979
AggStatePerPhase phases
Definition: execnodes.h:1920
struct WindowFuncExprState WindowFuncExprState
struct GMReaderTupleBuffer * gm_tuple_buffers
Definition: execnodes.h:2094
ProjectionInfo * projLeft
Definition: execnodes.h:829
int nworkers_launched
Definition: execnodes.h:2060
HeapTuple curTuple
Definition: execnodes.h:825
bool nl_MatchedOuter
Definition: execnodes.h:1705
Datum * ecxt_aggvalues
Definition: execnodes.h:237
WorkerInstrumentation * worker_instrument
Definition: execnodes.h:922
struct WindowStatePerAggData * WindowStatePerAgg
Definition: execnodes.h:1948
TupleHashTable hashtable
Definition: execnodes.h:831
struct PlanState * parent
Definition: execnodes.h:103
ExprState * bitmapqualorig
Definition: execnodes.h:1440
MemoryContext tableContext
Definition: execnodes.h:2164
MemoryContext argcontext
Definition: execnodes.h:1026
NodeTag type
Definition: execnodes.h:323
TupleTableSlot * hj_NullInnerTupleSlot
Definition: execnodes.h:1802
Datum startOffsetValue
Definition: execnodes.h:1980
TupleTableSlot ** ms_slots
Definition: execnodes.h:1117
ExprState * aggfilter
Definition: execnodes.h:733
ExprContext * innerecontext
Definition: execnodes.h:837
ExprState * joinqual
Definition: execnodes.h:1690
List * ii_Predicate
Definition: execnodes.h:156
struct ScanState ScanState
CommandId es_output_cid
Definition: execnodes.h:487
PlanState ps
Definition: execnodes.h:1021
Tuplestorestate * tuplestorestate
Definition: execnodes.h:1829
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:947
SortSupport ms_sortkeys
Definition: execnodes.h:1116
Instrumentation * instrument
Definition: execnodes.h:921
struct SetOpStatePerGroupData * SetOpStatePerGroup
Definition: execnodes.h:2149
PlanState ps
Definition: execnodes.h:1165
NodeTag type
Definition: execnodes.h:214
ExprContext * mj_InnerEContext
Definition: execnodes.h:1753
bool bounded_Done
Definition: execnodes.h:1853
ExprState * eqfunction
Definition: execnodes.h:2154
Tuplestorestate * intermediate_table
Definition: execnodes.h:1139
struct JitContext * es_jit
Definition: execnodes.h:573
EPQState lr_epqstate
Definition: execnodes.h:2179
bool mj_ConstFalseJoin
Definition: execnodes.h:1742
struct PartitionPruneState * as_prune_state
Definition: execnodes.h:1094
struct PartitionTupleRouting * mt_partition_tuple_routing
Definition: execnodes.h:1053
int numaggs
Definition: execnodes.h:1894
TupleTableSlot * es_trig_newtup_slot
Definition: execnodes.h:514
Oid es_lastoid
Definition: execnodes.h:530
bool noCount
Definition: execnodes.h:2214
DomainConstraintType constrainttype
Definition: execnodes.h:875
Oid * eqfuncoids
Definition: execnodes.h:2155
bool agg_done
Definition: execnodes.h:1912
PlanState ps
Definition: execnodes.h:1686
struct WindowAggState WindowAggState
ScanState ss
Definition: execnodes.h:1952
bool nl_NeedNewOuter
Definition: execnodes.h:1704
struct SetExprState SetExprState
TupleTableSlot * inputslot
Definition: execnodes.h:677
Relation relation
Definition: execnodes.h:596
IndexRuntimeKeyInfo * iss_RuntimeKeys
Definition: execnodes.h:1282
int64 groupheadpos
Definition: execnodes.h:1994
bool bounded
Definition: execnodes.h:1850
NodeTag type
Definition: execnodes.h:293
TupleTableSlot * sort_slot
Definition: execnodes.h:1923
List * initPlan
Definition: execnodes.h:933
List * all_grouped_cols
Definition: execnodes.h:1917
ResultRelInfo * resultRelInfo
Definition: execnodes.h:1042
Tuplesortstate * sort_out
Definition: execnodes.h:1922
struct ExprEvalStep * steps
Definition: execnodes.h:81
bool shutdown_reg
Definition: execnodes.h:803
ScanState ss
Definition: execnodes.h:1892
int16 * iss_OrderByTypLens
Definition: execnodes.h:1296
bool * innermost_casenull
Definition: execnodes.h:107
FmgrInfo * hashfunctions
Definition: execnodes.h:1142
ExprState * ii_PredicateState
Definition: execnodes.h:157
Relation ri_PartitionRoot
Definition: execnodes.h:460
ExprContext * ps_ExprContext
Definition: execnodes.h:946
MinimalTuple firstTuple
Definition: execnodes.h:651
SortSupport iss_SortSupport
Definition: execnodes.h:1294
MemoryContext ecxt_per_tuple_memory
Definition: execnodes.h:226
LimitStateCond
Definition: execnodes.h:2196
ExprState * ri_PartitionCheckExpr
Definition: execnodes.h:457
struct BitmapHeapScanState BitmapHeapScanState
tuplehash_iterator TupleHashIterator
Definition: execnodes.h:684
bool single_match
Definition: execnodes.h:1688
HashJoinTable hashtable
Definition: execnodes.h:2128
TIDBitmap * tbm
Definition: execnodes.h:1441
int64 bound
Definition: execnodes.h:1851
bool pending_srf_tuples
Definition: execnodes.h:1025
struct TableFuncScanState TableFuncScanState
TupleTableSlot * mt_conflproj
Definition: execnodes.h:1050
struct HashInstrumentation HashInstrumentation
Relation biss_RelationDesc
Definition: execnodes.h:1364
List * subPlan
Definition: execnodes.h:935
Definition: jit.h:27
ParamListInfo ext_params
Definition: execnodes.h:104
void * tsm_state
Definition: execnodes.h:1218
TupleTableSlot * mj_MarkedTupleSlot
Definition: execnodes.h:1749
bool ri_PartitionReadyForRouting
Definition: execnodes.h:463
AttrNumber * keyColIdx
Definition: execnodes.h:669
unsigned char uint8
Definition: c.h:323
bool need_to_scan_locally
Definition: execnodes.h:2081
ExprState * tab_eq_func
Definition: execnodes.h:671
Instrumentation * ri_TrigInstrument
Definition: execnodes.h:418
PlannedStmt * es_plannedstmt
Definition: execnodes.h:481
PlanState ps
Definition: execnodes.h:2153
NodeTag type
Definition: execnodes.h:719
int64 currentgroup
Definition: execnodes.h:1991
SharedSortInfo * shared_info
Definition: execnodes.h:1857
int current_phase
Definition: execnodes.h:1900
ScanState ss
Definition: execnodes.h:1826
bool need_to_scan_locally
Definition: execnodes.h:2054
Definition: nodes.h:517
AggSplit aggsplit
Definition: execnodes.h:1897
Snapshot es_crosscheck_snapshot
Definition: execnodes.h:479
Oid * ii_ExclusionProcs
Definition: execnodes.h:159
struct CteScanState * leader
Definition: execnodes.h:1594
ScanState ss
Definition: execnodes.h:1589
int64 aggregatedupto
Definition: execnodes.h:1975
ExprState * cur_eq_func
Definition: execnodes.h:679
List * jf_targetList
Definition: execnodes.h:361
struct ExprState ExprState
TupleTableSlot * mj_NullInnerTupleSlot
Definition: execnodes.h:1751
bool ermActive
Definition: execnodes.h:604
TupleTableSlot * jf_resultSlot
Definition: execnodes.h:364
IndexRuntimeKeyInfo * ioss_RuntimeKeys
Definition: execnodes.h:1326
LockWaitPolicy waitPolicy
Definition: execnodes.h:603
bool hj_MatchedOuter
Definition: execnodes.h:1805
ExprContext * es_per_tuple_exprcontext
Definition: execnodes.h:547
struct NamedTuplestoreScanState NamedTuplestoreScanState
struct SubqueryScanState SubqueryScanState
struct TupleQueueReader ** reader
Definition: execnodes.h:2063
Oid * tab_eq_funcoids
Definition: execnodes.h:839
CmdType operation
Definition: execnodes.h:1036
ScanState ss
Definition: execnodes.h:1203
Snapshot es_snapshot
Definition: execnodes.h:478
ResultRelInfo * rootResultRelInfo
Definition: execnodes.h:1043
bool frametail_valid
Definition: execnodes.h:2010
TupleTableSlot ** gm_slots
Definition: execnodes.h:2092
HeapTuple grp_firstTuple
Definition: execnodes.h:2161
List * args
Definition: execnodes.h:751
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1194
bool am_worker
Definition: execnodes.h:1856
FunctionCallInfoData fcinfo_data
Definition: execnodes.h:810
struct AggStatePerPhaseData * AggStatePerPhase
Definition: execnodes.h:1887
struct WindowStatePerFuncData * WindowStatePerFunc
Definition: execnodes.h:1947
ExprState * testexpr
Definition: execnodes.h:823
int64 frametailgroup
Definition: execnodes.h:1993
MemoryContext argcontext
Definition: execnodes.h:1523
PlanState ** bitmapplans
Definition: execnodes.h:1155
Datum * innermost_domainval
Definition: execnodes.h:109
int64 grouptailpos
Definition: execnodes.h:1995
LockClauseStrength strength
Definition: execnodes.h:602
DomainConstraintType
Definition: execnodes.h:866
Relation ss_currentRelation
Definition: execnodes.h:1192
AggStatePerTrans pertrans
Definition: execnodes.h:1902
EState * state
Definition: execnodes.h:913
TupleTableSlot * hj_OuterTupleSlot
Definition: execnodes.h:1799
int projected_set
Definition: execnodes.h:1913
List * custom_ps
Definition: execnodes.h:1668
struct OnConflictSetState OnConflictSetState
LimitStateCond lstate
Definition: execnodes.h:2215
TupleTableSlot * resultslot
Definition: execnodes.h:76
List * es_range_table
Definition: execnodes.h:480
ExprState * fdw_recheck_quals
Definition: execnodes.h:1641
struct PlanState * righttree
Definition: execnodes.h:931
unsigned int Oid
Definition: postgres_ext.h:31
Datum domainValue_datum
Definition: execnodes.h:249
NodeTag
Definition: nodes.h:26
List * hj_OuterHashKeys
Definition: execnodes.h:1791
struct ExecRowMark ExecRowMark
HeapTuple grp_firstTuple
Definition: execnodes.h:1927
ExprState * limitCount
Definition: execnodes.h:2211
TupleTableSlot * temp_slot_1
Definition: execnodes.h:2022
int current_set
Definition: execnodes.h:1915
WindowStatePerFunc perfunc
Definition: execnodes.h:1959
TupleTableSlot * hj_FirstOuterTupleSlot
Definition: execnodes.h:1803
Oid * ii_UniqueOps
Definition: execnodes.h:161
Datum(* ExprStateEvalFunc)(struct ExprState *expression, struct ExprContext *econtext, bool *isNull)
Definition: execnodes.h:49
bool grp_done
Definition: execnodes.h:1868
ExprState * indexqualorig
Definition: execnodes.h:1276
int64 position
Definition: execnodes.h:2216
SharedBitmapState
Definition: execnodes.h:1381
int numtrans
Definition: execnodes.h:1895
ScanKey iss_ScanKeys
Definition: execnodes.h:1278
Size pscan_len
Definition: execnodes.h:1204
TupleTableSlot *(* ExecProcNodeMtd)(struct PlanState *pstate)
Definition: execnodes.h:898
struct ModifyTableState ModifyTableState
PlanState * planstate
Definition: execnodes.h:992
ScanDirection es_direction
Definition: execnodes.h:477
List * indexorderbyorig
Definition: execnodes.h:1277
bool * innermost_domainnull
Definition: execnodes.h:110
PlanState ps
Definition: execnodes.h:2078
uint64 dsa_pointer
Definition: dsa.h:62
Index ri_RangeTableIndex
Definition: execnodes.h:394
ExprContext * tmpcontext
Definition: execnodes.h:1905
int64 count
Definition: execnodes.h:2213
char bool
Definition: c.h:275
PlanState ps
Definition: execnodes.h:1086
JoinType
Definition: nodes.h:681
struct PlanState * lefttree
Definition: execnodes.h:930
HeapTupleData tss_htup
Definition: execnodes.h:1480
struct HashJoinState HashJoinState
TupleTableSlot * first_part_slot
Definition: execnodes.h:2015
TupleTableSlot * mt_existing
Definition: execnodes.h:1048
FmgrInfo * tab_hash_funcs
Definition: execnodes.h:670
ScanState ss
Definition: execnodes.h:1545
ExecRowMark * rowmark
Definition: execnodes.h:623
ItemPointerData curCtid
Definition: execnodes.h:605
bool es_use_parallel_mode
Definition: execnodes.h:562
SharedHashInfo * shared_info
Definition: execnodes.h:2132
const struct CustomExecMethods * methods
Definition: execnodes.h:1670
struct SharedSortInfo SharedSortInfo
List * ri_WithCheckOptionExprs
Definition: execnodes.h:433
FmgrInfo * tab_hash_funcs
Definition: execnodes.h:840
bool * iss_OrderByNulls
Definition: execnodes.h:1293
ScanState ss
Definition: execnodes.h:1866
MemoryContext perValueCxt
Definition: execnodes.h:1573
ExprContext * tmpcontext
Definition: execnodes.h:2000
PlanState ps
Definition: execnodes.h:1191
ScanKey ioss_ScanKeys
Definition: execnodes.h:1322
struct WindowObjectData * agg_winobj
Definition: execnodes.h:1973
bool inRangeNullsFirst
Definition: execnodes.h:1988
void * tuplesortstate
Definition: execnodes.h:1855
int64 frameheadpos
Definition: execnodes.h:1970
int maxsets
Definition: execnodes.h:1919
uint32 hj_CurHashValue
Definition: execnodes.h:1795
Tuplestorestate * funcResultStore
Definition: execnodes.h:772
const char * es_sourceText
Definition: execnodes.h:482
TupleDesc expectedDesc
Definition: execnodes.h:296
int hj_CurSkewBucketNo
Definition: execnodes.h:1797
List * ii_ExpressionsState
Definition: execnodes.h:155
struct ProjectSetState ProjectSetState
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:945
ParamExecData * es_param_exec_vals
Definition: execnodes.h:518
unsigned short uint16
Definition: c.h:324
MemoryContext es_query_cxt
Definition: execnodes.h:523
ExprState * cur_eq_comp
Definition: execnodes.h:844
ExprState * eqfunction
Definition: execnodes.h:2040
struct ParallelExecutorInfo * pei
Definition: execnodes.h:2087
struct FunctionScanState FunctionScanState
bool mj_MatchedOuter
Definition: execnodes.h:1745
PlanState ps
Definition: execnodes.h:1154
bool table_filled
Definition: execnodes.h:1929
AggStrategy aggstrategy
Definition: execnodes.h:1896
ExprState * partEqfunction
Definition: execnodes.h:1961
FmgrInfo * in_hash_funcs
Definition: execnodes.h:678
NodeTag type
Definition: execnodes.h:391
PlanState ps
Definition: execnodes.h:1035
int ii_NumIndexKeyAttrs
Definition: execnodes.h:152
int64 offset
Definition: execnodes.h:2212
bool initialized
Definition: execnodes.h:2053
Bitmapset * notnulls
Definition: execnodes.h:1567
struct PlanState * planstate
Definition: execnodes.h:821
TupleTableSlot * hj_NullOuterTupleSlot
Definition: execnodes.h:1801
bool resnull
Definition: execnodes.h:68
ProjectionInfo * oc_ProjInfo
Definition: execnodes.h:377
ScanState ss
Definition: execnodes.h:1474
ParallelBitmapHeapState * pstate
Definition: execnodes.h:1458
struct CustomScanState CustomScanState
struct ResultRelInfo ResultRelInfo
Expr * expr
Definition: execnodes.h:90
FmgrInfo endInRangeFunc
Definition: execnodes.h:1985
List * args
Definition: execnodes.h:824
SubPlan * subplan
Definition: execnodes.h:820
ExprState * eqfunction
Definition: execnodes.h:1867
ParallelAppendState * as_pstate
Definition: execnodes.h:1092
struct ParallelExecutorInfo * pei
Definition: execnodes.h:2058
Datum caseValue_datum
Definition: execnodes.h:243
PlanState ** bitmapplans
Definition: execnodes.h:1166
ExprContext_CB * ecxt_callbacks
Definition: execnodes.h:257
List * tss_tidexprs
Definition: execnodes.h:1475
NodeTag type
Definition: execnodes.h:360
AlternativeSubPlan * subplan
Definition: execnodes.h:854
struct SeqScanState SeqScanState
bool iss_ReachedEnd
Definition: execnodes.h:1291
struct TupleHashEntryData TupleHashEntryData
List * arowMarks
Definition: execnodes.h:995
struct HashJoinTupleData * HashJoinTuple
Definition: execnodes.h:1784
ExprState * resconstantqual
Definition: execnodes.h:1007
bool mj_MatchedInner
Definition: execnodes.h:1746
bool ri_usesFdwDirectModify
Definition: execnodes.h:427
ScanState ss
Definition: execnodes.h:1665
Tuplesortstate * sort_in
Definition: execnodes.h:1921
AttrNumber * keyColIdx
Definition: execnodes.h:838
MemoryContext tempContext
Definition: execnodes.h:1143
ItemPointerData * tss_TidList
Definition: execnodes.h:1479
NodeTag type
Definition: execnodes.h:749
ExprState ** ri_TrigWhenExprs
Definition: execnodes.h:415
TupleTableSlot * temp_slot_2
Definition: execnodes.h:2023
PlanState ps
Definition: execnodes.h:2177
ExprState * key_expr
Definition: execnodes.h:1233
bool funcReturnsSet
Definition: execnodes.h:786
Aggref * aggref
Definition: execnodes.h:720
struct BitmapAndState BitmapAndState
Datum endOffsetValue
Definition: execnodes.h:1981
Index rti
Definition: execnodes.h:598
WindowStatePerAgg peragg
Definition: execnodes.h:1960
struct TransitionCaptureState * mt_transition_capture
Definition: execnodes.h:1056
ExprContext * ioss_RuntimeContext
Definition: execnodes.h:1329
ExprStateEvalFunc evalfunc
Definition: execnodes.h:87
struct MergeJoinClauseData * MergeJoinClause
Definition: execnodes.h:1732
ExprState * ordEqfunction
Definition: execnodes.h:1962
struct EPQState EPQState
void * ermExtra
Definition: execnodes.h:606
const struct TableFuncRoutine * routine
Definition: execnodes.h:1569
int iss_NumRuntimeKeys
Definition: execnodes.h:1283
struct MergeJoinState MergeJoinState
ExprState * startOffset
Definition: execnodes.h:1978
int64 frameheadgroup
Definition: execnodes.h:1992
MemoryContext tablecxt
Definition: execnodes.h:672
int es_jit_flags
Definition: execnodes.h:572
struct ExecAuxRowMark ExecAuxRowMark
TupleDesc jf_cleanTupType
Definition: execnodes.h:362
AttrNumber wholeAttNo
Definition: execnodes.h:626
HashJoinTuple hj_CurTuple
Definition: execnodes.h:1798
Oid * ii_UniqueProcs
Definition: execnodes.h:162
PlanState ps
Definition: execnodes.h:2039
bool table_filled
Definition: execnodes.h:2165
ResultRelInfo * es_result_relations
Definition: execnodes.h:490
int64 aggregatedbase
Definition: execnodes.h:1974
Index prti
Definition: execnodes.h:599
struct ExprContext ExprContext
IndexScanDesc ioss_ScanDesc
Definition: execnodes.h:1331
ExprState * docexpr
Definition: execnodes.h:1561
ScanDirection
Definition: sdir.h:22
EPQState mt_epqstate
Definition: execnodes.h:1046
bool * iss_OrderByTypByVals
Definition: execnodes.h:1295
struct TupleHashTableData * TupleHashTable
Definition: execnodes.h:647
long numOutput
Definition: execnodes.h:2158
bool tss_isCurrentOf
Definition: execnodes.h:1476
PlanState ** mergeplans
Definition: execnodes.h:1113
struct ValuesScanState ValuesScanState
struct AggStatePerHashData * AggStatePerHash
Definition: execnodes.h:1888
TupleTableSlot * ecxt_innertuple
Definition: execnodes.h:220
TupleTableSlot * es_trig_oldtup_slot
Definition: execnodes.h:513
bool havenullrows
Definition: execnodes.h:834
ParamExecData * ecxt_param_exec_vals
Definition: execnodes.h:229
ExprState * limitOffset
Definition: execnodes.h:2210
ExprState * check_exprstate
Definition: execnodes.h:878
struct MaterialState MaterialState
struct EState * ecxt_estate
Definition: execnodes.h:254
struct ProjectionInfo ProjectionInfo
List * hashkeys
Definition: execnodes.h:2129
struct HashState HashState
ProjectionInfo * ri_projectReturning
Definition: execnodes.h:445
bool eof_underlying
Definition: execnodes.h:1828
struct FdwRoutine * ri_FdwRoutine
Definition: execnodes.h:421
bool ii_BrokenHotChain
Definition: execnodes.h:167
unsigned int uint32
Definition: c.h:325
PlanState ps
Definition: execnodes.h:2127
int64 bound_Done
Definition: execnodes.h:1854
struct FdwRoutine * fdwroutine
Definition: execnodes.h:1644
AggStatePerAgg curperagg
Definition: execnodes.h:1908
struct PlanState * parent
Definition: execnodes.h:822
struct binaryheap * gm_heap
Definition: execnodes.h:2095
int as_first_partial_plan
Definition: execnodes.h:1090
AggStatePerHash perhash
Definition: execnodes.h:1931
ScanState ss
Definition: execnodes.h:1848
PlanState ps
Definition: execnodes.h:2052
MergeJoinClause mj_Clauses
Definition: execnodes.h:1738
dsa_pointer tbmiterator
Definition: execnodes.h:1403
Tuplestorestate * buffer
Definition: execnodes.h:1963
int es_instrument
Definition: execnodes.h:533
ExprState * oc_WhereClause
Definition: execnodes.h:379
struct GatherMergeState GatherMergeState
MemoryContext aggcontext
Definition: execnodes.h:1998
ExprState * repeatable
Definition: execnodes.h:1215
Datum * innermost_caseval
Definition: execnodes.h:106
bool iss_RuntimeKeysReady
Definition: execnodes.h:1284
TupleTableSlot * es_trig_tuple_slot
Definition: execnodes.h:512
TupleHashTable hashtable
Definition: execnodes.h:1144
PlanState * subplan
Definition: execnodes.h:1493
TupleTableSlot * origslot
Definition: execnodes.h:993
struct LockRowsState LockRowsState
struct RecursiveUnionState RecursiveUnionState
bool ii_ReadyForInserts
Definition: execnodes.h:165
HashInstrumentation * hinstrument
Definition: execnodes.h:2133
List * hj_HashOperators
Definition: execnodes.h:1793
Bitmapset * grouped_cols
Definition: execnodes.h:1916
struct HashJoinTableData * HashJoinTable
Definition: execnodes.h:1785
ExprState ** ri_ConstraintExprs
Definition: execnodes.h:436
TBMIterateResult * tbmres
Definition: execnodes.h:1443
TriggerDesc * ri_TrigDesc
Definition: execnodes.h:409
struct AggState AggState
ScanKey ioss_OrderByKeys
Definition: execnodes.h:1324
Index rowmarkId
Definition: execnodes.h:600
TupleHashIterator hashiter
Definition: execnodes.h:2166
void * evalfunc_private
Definition: execnodes.h:93
Bitmapset * chgParam
Definition: execnodes.h:940
struct AggrefExprState AggrefExprState
struct ExprContext_CB * next
Definition: execnodes.h:184
Tuplestorestate * working_table
Definition: execnodes.h:1138
bool rs_checkqual
Definition: execnodes.h:1009
void * ii_AmCache
Definition: execnodes.h:170
struct AlternativeSubPlanState AlternativeSubPlanState
QueryEnvironment * es_queryEnv
Definition: execnodes.h:520
int es_num_root_result_relations
Definition: execnodes.h:502
int hj_CurBucketNo
Definition: execnodes.h:1796
RecursiveUnionState * rustate
Definition: execnodes.h:1629
PlanState ** mt_plans
Definition: execnodes.h:1039
struct FunctionScanPerFuncState * funcstates
Definition: execnodes.h:1522
int num_hashes
Definition: execnodes.h:1930
SetFunctionReturnMode
Definition: execnodes.h:277
int64 spooled_rows
Definition: execnodes.h:1968
OnConflictSetState * ri_onConflict
Definition: execnodes.h:451
bool domainValue_isNull
Definition: execnodes.h:251
bool input_done
Definition: execnodes.h:1911
ExprDoneCond
Definition: execnodes.h:264
ProjectionInfo * combinedproj
Definition: execnodes.h:1939
ExprContext * curaggcontext
Definition: execnodes.h:1907
ExprContext * hashcontext
Definition: execnodes.h:1903
bool * ecxt_aggnulls
Definition: execnodes.h:239
bool mj_SkipMarkRestore
Definition: execnodes.h:1740
TupleConversionMap ** mt_per_subplan_tupconv_maps
Definition: execnodes.h:1062
struct NestLoopState NestLoopState
List * es_trig_target_relations
Definition: execnodes.h:511
Plan * plan
Definition: execnodes.h:994
List * es_tupleTable
Definition: execnodes.h:525
LockClauseStrength
Definition: lockoptions.h:21
AggStatePerPhase phase
Definition: execnodes.h:1898
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:917
List * es_auxmodifytables
Definition: execnodes.h:540
Datum curArray
Definition: execnodes.h:826
Bitmapset * as_valid_subplans
Definition: execnodes.h:1095
uintptr_t Datum
Definition: postgres.h:365
TupleDesc tupDesc
Definition: execnodes.h:2084
IndexScanDesc biss_ScanDesc
Definition: execnodes.h:1365
ExecProcNodeMtd ExecProcNodeReal
Definition: execnodes.h:918
ExprContext * rowcontext
Definition: execnodes.h:1546
int ii_NumIndexAttrs
Definition: execnodes.h:151
TupleTableSlot * funnel_slot
Definition: execnodes.h:2057
TupleDesc scandesc
Definition: execnodes.h:954
List * ri_WithCheckOptions
Definition: execnodes.h:430
TupleDesc funcResultDesc
Definition: execnodes.h:779
Expr * expr
Definition: execnodes.h:750
struct TupleHashEntryData * TupleHashEntry
Definition: execnodes.h:646
TupleTableSlot * agg_row_slot
Definition: execnodes.h:2021
int es_num_result_relations
Definition: execnodes.h:491
TIDBitmap * biss_result
Definition: execnodes.h:1355
List * ri_PartitionCheck
Definition: execnodes.h:454
unsigned int Index
Definition: c.h:442
struct TupleQueueReader ** reader
Definition: execnodes.h:2093
FmgrInfo * hashfunctions
Definition: execnodes.h:2156
TupleTableSlot * nl_NullInnerTupleSlot
Definition: execnodes.h:1706
Plan * plan
Definition: execnodes.h:911
TupleTableSlot * frametail_slot
Definition: execnodes.h:2018
MemoryContext hashtempcxt
Definition: execnodes.h:836
bool more_partitions
Definition: execnodes.h:2006
struct SampleScanState SampleScanState
List * es_tuple_routing_result_relations
Definition: execnodes.h:508
Relation ioss_RelationDesc
Definition: execnodes.h:1330
bool es_finished
Definition: execnodes.h:534
PlanState ps
Definition: execnodes.h:1112
void * ri_FdwState
Definition: execnodes.h:424
ExprState * array_expr
Definition: execnodes.h:1240
int allowedModes
Definition: execnodes.h:297
struct EState EState
JoinState js
Definition: execnodes.h:1736
MemoryContext hashtablecxt
Definition: execnodes.h:835
dsa_pointer prefetch_iterator
Definition: execnodes.h:1404
struct binaryheap * ms_heap
Definition: execnodes.h:1118
tuplehash_hash * hashtab
Definition: execnodes.h:667
ScanState ss
Definition: execnodes.h:1275
bool ii_Unique
Definition: execnodes.h:164
struct PlanState PlanState
SetFunctionReturnMode returnMode
Definition: execnodes.h:299
ExprContext ** aggcontexts
Definition: execnodes.h:1904
MemoryContext tableContext
Definition: execnodes.h:1145
TupleTableSlot * ecxt_outertuple
Definition: execnodes.h:222
bool hj_OuterNotEmpty
Definition: execnodes.h:1806
int64 frametailpos
Definition: execnodes.h:1971
List * ii_Expressions
Definition: execnodes.h:154
NodeTag type
Definition: execnodes.h:150
FmgrInfo * tab_eq_funcs
Definition: execnodes.h:841
TupleTableSlot * tableslot
Definition: execnodes.h:675
TupleTableSlot * mj_InnerTupleSlot
Definition: execnodes.h:1748
struct AggStatePerAggData * AggStatePerAgg
Definition: execnodes.h:1884
FmgrInfo startInRangeFunc
Definition: execnodes.h:1984
bool grouptail_valid
Definition: execnodes.h:2012
TupleTableSlot * framehead_slot
Definition: execnodes.h:2017
bool setop_done
Definition: execnodes.h:2157
struct UniqueState UniqueState
FmgrInfo * in_functions
Definition: execnodes.h:1570
TupleTableSlot * subSlot
Definition: execnodes.h:2217
RowMarkType markType
Definition: execnodes.h:601
uint64 es_processed
Definition: execnodes.h:529
void(* ExprContextCallbackFunction)(Datum arg)
Definition: execnodes.h:180
int as_whichplan
Definition: execnodes.h:1089
#define INDEX_MAX_KEYS
AggStatePerGroup * pergroups
Definition: execnodes.h:1925
int ii_ParallelWorkers
Definition: execnodes.h:168
size_t Size
Definition: c.h:433
AggSplit
Definition: nodes.h:765
bool funcReturnsTuple
Definition: execnodes.h:780
ExprContext * mj_OuterEContext
Definition: execnodes.h:1752
struct ParallelBitmapHeapState ParallelBitmapHeapState
bool randomAccess
Definition: execnodes.h:1849
RowMarkType
Definition: plannodes.h:984
struct SetOpState SetOpState
SharedBitmapState state
Definition: execnodes.h:1408
bool sort_Done
Definition: execnodes.h:1852
Tuplestorestate * relation
Definition: execnodes.h:1615
ExprState * indexqual
Definition: execnodes.h:1321
TupleTableSlot * ecxt_scantuple
Definition: execnodes.h:218
SetOpStatePerGroup pergroup
Definition: execnodes.h:2160
bool * es_epqTupleSet
Definition: execnodes.h:559
List * es_subplanstates
Definition: execnodes.h:538
struct TsmRoutine * tsmroutine
Definition: execnodes.h:1217
TBMSharedIterator * shared_tbmiterator
Definition: execnodes.h:1456
AttrNumber toidAttNo
Definition: execnodes.h:625
List * es_rowMarks
Definition: execnodes.h:527
ExprContext * iss_RuntimeContext
Definition: execnodes.h:1285
TBMIterator * tbmiterator
Definition: execnodes.h:1442
MemoryContext ecxt_per_query_memory
Definition: execnodes.h:225
TupleTableSlot * mj_NullOuterTupleSlot
Definition: execnodes.h:1750
int numphases
Definition: execnodes.h:1899
struct IndexInfo IndexInfo
bool ii_Concurrent
Definition: execnodes.h:166
FmgrInfo * lhs_hash_funcs
Definition: execnodes.h:842
int64 currentpos
Definition: execnodes.h:1969
ExprState * qual
Definition: execnodes.h:929
Tuplestorestate * setResult
Definition: execnodes.h:302
FmgrInfo * cur_eq_funcs
Definition: execnodes.h:843
bool setArgsValid
Definition: execnodes.h:795
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1193
PlanState * cteplanstate
Definition: execnodes.h:1592
ExprContext * econtext
Definition: execnodes.h:295
struct MergeAppendState MergeAppendState
JoinState js
Definition: execnodes.h:1703
IndexArrayKeyInfo * biss_ArrayKeys
Definition: execnodes.h:1360
List * mt_excludedtlist
Definition: execnodes.h:1049
int nextreader
Definition: execnodes.h:2062
TupleTableSlot * funcResultSlot
Definition: execnodes.h:773
TupleTableSlot * hj_HashTupleSlot
Definition: execnodes.h:1800
List * hj_InnerHashKeys
Definition: execnodes.h:1792
Definition: dsa.c:354
bool caseValue_isNull
Definition: execnodes.h:245
bool partition_spooled
Definition: execnodes.h:2004
Oid * ii_ExclusionOps
Definition: execnodes.h:158
AggStrategy
Definition: nodes.h:743
struct TidScanState TidScanState
TupleDesc setDesc
Definition: execnodes.h:303
ConditionVariable cv
Definition: execnodes.h:1409
ExprState * elidedFuncState
Definition: execnodes.h:758
struct ReturnSetInfo ReturnSetInfo
int steps_alloc
Definition: execnodes.h:101
struct GatherState GatherState
HashJoinTable hj_HashTable
Definition: execnodes.h:1794
int es_top_eflags
Definition: execnodes.h:532
AggStatePerAgg peragg
Definition: execnodes.h:1901
bool framehead_valid
Definition: execnodes.h:2008
int steps_len
Definition: execnodes.h:100
PlanState ** appendplans
Definition: execnodes.h:1087
TBMIterator * prefetch_iterator
Definition: execnodes.h:1450
ResultRelInfo * es_root_result_relations
Definition: execnodes.h:501
TupleDesc descRight
Definition: execnodes.h:828
struct DomainConstraintState DomainConstraintState
IndexInfo ** ri_IndexRelationInfo
Definition: execnodes.h:406
List * lr_arowMarks
Definition: execnodes.h:2178
struct ExprContext_CB ExprContext_CB
NodeTag type
Definition: execnodes.h:819
bool * es_epqScanDone
Definition: execnodes.h:560
struct JunkFilter JunkFilter
ExprDoneCond * elemdone
Definition: execnodes.h:1023
uint8 flags
Definition: execnodes.h:61
NodeTag type
Definition: execnodes.h:474
ExprState pi_state
Definition: execnodes.h:325
void * arg
AggStatePerTrans curpertrans
Definition: execnodes.h:1910
int epqParam
Definition: execnodes.h:996
ParamListInfo es_param_list_info
Definition: execnodes.h:517
List * es_exprcontexts
Definition: execnodes.h:536
MemoryContext tempcxt
Definition: execnodes.h:673
ProjectionInfo * projRight
Definition: execnodes.h:830
MemoryContext partcontext
Definition: execnodes.h:1997
struct CteScanState CteScanState
ExprDoneCond isDone
Definition: execnodes.h:300
struct ResultState ResultState
WindowFunc * wfunc
Definition: execnodes.h:731
List * aggs
Definition: execnodes.h:1893
ExprContext * biss_RuntimeContext
Definition: execnodes.h:1363
bool mj_ExtraMarks
Definition: execnodes.h:1741
EState * estate
Definition: execnodes.h:991
Datum * iss_OrderByValues
Definition: execnodes.h:1292
uint16 * ii_ExclusionStrats
Definition: execnodes.h:160
struct BitmapIndexScanState BitmapIndexScanState
ParamListInfo ecxt_param_list_info
Definition: execnodes.h:230
int iss_NumOrderByKeys
Definition: execnodes.h:1281
Tuplestorestate * cte_table
Definition: execnodes.h:1596
List ** exprlists
Definition: execnodes.h:1547
ExprContext * pi_exprContext
Definition: execnodes.h:327
IndexScanDesc iss_ScanDesc
Definition: execnodes.h:1287
struct SortState SortState
Definition: pg_list.h:45
Tuplestorestate * tupstore
Definition: execnodes.h:1574
int Buffer
Definition: buf.h:23
bool havehashrows
Definition: execnodes.h:833
Datum resvalue
Definition: execnodes.h:70
int16 AttrNumber
Definition: attnum.h:21
ExprState * rowexpr
Definition: execnodes.h:1562
JoinState js
Definition: execnodes.h:1789
struct IndexOnlyScanState IndexOnlyScanState
LockWaitPolicy
Definition: lockoptions.h:36
TupleDesc oc_ProjTupdesc
Definition: execnodes.h:378
List * ri_onConflictArbiterIndexes
Definition: execnodes.h:448
CmdType
Definition: nodes.h:657
TupleHashTable hashnulls
Definition: execnodes.h:832
AttrNumber ctidAttNo
Definition: execnodes.h:624
RelationPtr ri_IndexRelationDescs
Definition: execnodes.h:403
PlanState ps
Definition: execnodes.h:2209
struct SubPlanState SubPlanState
TBMSharedIterator * shared_prefetch_iterator
Definition: execnodes.h:1457
struct IndexScanState IndexScanState
TupleHashTable hashtable
Definition: execnodes.h:2163
ExprState * hashclauses
Definition: execnodes.h:1790
List * ri_returningList
Definition: execnodes.h:442
FmgrInfo * ri_TrigFunctions
Definition: execnodes.h:412
struct ForeignScanState ForeignScanState
struct BitmapOrState BitmapOrState
Relation iss_RelationDesc
Definition: execnodes.h:1286
List ** mt_arowmarks
Definition: execnodes.h:1045
TupleTableSlot * mj_OuterTupleSlot
Definition: execnodes.h:1747
SortSupport gm_sortkeys
Definition: execnodes.h:2086
pairingheap * iss_ReorderQueue
Definition: execnodes.h:1290
struct SharedHashInfo SharedHashInfo
struct LimitState LimitState
int64 tuples_needed
Definition: execnodes.h:2055
AggStatePerGroup * all_pergroups
Definition: execnodes.h:1937
struct WorkTableScanState WorkTableScanState
struct JoinState JoinState
Oid ii_Am
Definition: execnodes.h:169
PlanState ps
Definition: execnodes.h:1006
ScanState ss
Definition: execnodes.h:1213
ScanKey iss_OrderByKeys
Definition: execnodes.h:1280
ResultRelInfo * es_result_relation_info
Definition: execnodes.h:492