PostgreSQL Source Code git master
Loading...
Searching...
No Matches
execnodes.h File Reference
#include "access/skey.h"
#include "access/tupconvert.h"
#include "executor/instrument.h"
#include "executor/instrument_node.h"
#include "fmgr.h"
#include "lib/ilist.h"
#include "lib/pairingheap.h"
#include "nodes/miscnodes.h"
#include "nodes/params.h"
#include "nodes/plannodes.h"
#include "nodes/tidbitmap.h"
#include "partitioning/partdefs.h"
#include "storage/condition_variable.h"
#include "utils/hsearch.h"
#include "utils/queryenvironment.h"
#include "utils/reltrigger.h"
#include "utils/sharedtuplestore.h"
#include "utils/snapshot.h"
#include "utils/sortsupport.h"
#include "utils/tuplesort.h"
#include "utils/tuplestore.h"
#include "lib/simplehash.h"
Include dependency graph for execnodes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ExprState
 
struct  IndexInfo
 
struct  ExprContext_CB
 
struct  ExprContext
 
struct  ReturnSetInfo
 
struct  ProjectionInfo
 
struct  JunkFilter
 
struct  OnConflictSetState
 
struct  MergeActionState
 
struct  ResultRelInfo
 
struct  AsyncRequest
 
struct  EState
 
struct  ExecRowMark
 
struct  ExecAuxRowMark
 
struct  TupleHashEntryData
 
struct  TupleHashTableData
 
struct  WindowFuncExprState
 
struct  SetExprState
 
struct  SubPlanState
 
struct  DomainConstraintState
 
struct  JsonExprState
 
struct  PlanState
 
struct  EPQState
 
struct  ResultState
 
struct  ProjectSetState
 
struct  ModifyTableState
 
struct  AppendState
 
struct  MergeAppendState
 
struct  RecursiveUnionState
 
struct  BitmapAndState
 
struct  BitmapOrState
 
struct  ScanState
 
struct  SeqScanState
 
struct  SampleScanState
 
struct  IndexRuntimeKeyInfo
 
struct  IndexArrayKeyInfo
 
struct  IndexScanState
 
struct  IndexOnlyScanState
 
struct  BitmapIndexScanState
 
struct  ParallelBitmapHeapState
 
struct  BitmapHeapScanState
 
struct  TidScanState
 
struct  TidRangeScanState
 
struct  SubqueryScanState
 
struct  FunctionScanState
 
struct  ValuesScanState
 
struct  TableFuncScanState
 
struct  CteScanState
 
struct  NamedTuplestoreScanState
 
struct  WorkTableScanState
 
struct  ForeignScanState
 
struct  CustomScanState
 
struct  JoinState
 
struct  NestLoopState
 
struct  MergeJoinState
 
struct  HashJoinState
 
struct  MaterialState
 
struct  MemoizeState
 
struct  PresortedKeyData
 
struct  SortState
 
struct  IncrementalSortState
 
struct  GroupState
 
struct  AggState
 
struct  WindowAggState
 
struct  UniqueState
 
struct  GatherState
 
struct  GatherMergeState
 
struct  HashState
 
struct  SetOpStatePerInput
 
struct  SetOpState
 
struct  LockRowsState
 
struct  LimitState
 

Macros

#define EEO_FLAG_IS_QUAL   (1 << 0)
 
#define EEO_FLAG_HAS_OLD   (1 << 1)
 
#define EEO_FLAG_HAS_NEW   (1 << 2)
 
#define EEO_FLAG_OLD_IS_NULL   (1 << 3)
 
#define EEO_FLAG_NEW_IS_NULL   (1 << 4)
 
#define FIELDNO_EXPRSTATE_FLAGS   1
 
#define FIELDNO_EXPRSTATE_RESNULL   2
 
#define FIELDNO_EXPRSTATE_RESVALUE   3
 
#define FIELDNO_EXPRSTATE_RESULTSLOT   4
 
#define FIELDNO_EXPRSTATE_PARENT   11
 
#define FIELDNO_EXPRCONTEXT_SCANTUPLE   1
 
#define FIELDNO_EXPRCONTEXT_INNERTUPLE   2
 
#define FIELDNO_EXPRCONTEXT_OUTERTUPLE   3
 
#define FIELDNO_EXPRCONTEXT_AGGVALUES   8
 
#define FIELDNO_EXPRCONTEXT_AGGNULLS   9
 
#define FIELDNO_EXPRCONTEXT_CASEDATUM   10
 
#define FIELDNO_EXPRCONTEXT_CASENULL   11
 
#define FIELDNO_EXPRCONTEXT_DOMAINDATUM   12
 
#define FIELDNO_EXPRCONTEXT_DOMAINNULL   13
 
#define FIELDNO_EXPRCONTEXT_OLDTUPLE   14
 
#define FIELDNO_EXPRCONTEXT_NEWTUPLE   15
 
#define SH_PREFIX   tuplehash
 
#define SH_ELEMENT_TYPE   TupleHashEntryData
 
#define SH_KEY_TYPE   MinimalTuple
 
#define SH_SCOPE   extern
 
#define SH_DECLARE
 
#define InitTupleHashIterator(htable, iter)    tuplehash_start_iterate(htable->hashtab, iter)
 
#define TermTupleHashIterator(iter)    ((void) 0)
 
#define ResetTupleHashIterator(htable, iter)    InitTupleHashIterator(htable, iter)
 
#define ScanTupleHashTable(htable, iter)    tuplehash_iterate(htable->hashtab, iter)
 
#define innerPlanState(node)   (((PlanState *)(node))->righttree)
 
#define outerPlanState(node)   (((PlanState *)(node))->lefttree)
 
#define InstrCountTuples2(node, delta)
 
#define InstrCountFiltered1(node, delta)
 
#define InstrCountFiltered2(node, delta)
 
#define MERGE_INSERT   0x01
 
#define MERGE_UPDATE   0x02
 
#define MERGE_DELETE   0x04
 
#define FIELDNO_AGGSTATE_CURAGGCONTEXT   14
 
#define FIELDNO_AGGSTATE_CURPERTRANS   16
 
#define FIELDNO_AGGSTATE_CURRENT_SET   20
 
#define FIELDNO_AGGSTATE_ALL_PERGROUPS   54
 

Typedefs

typedef struct PlanState PlanState
 
typedef struct ExecRowMark ExecRowMark
 
typedef struct ExprState ExprState
 
typedef struct ExprContext ExprContext
 
typedef Datum(* ExprStateEvalFunc) (ExprState *expression, ExprContext *econtext, bool *isNull)
 
typedef struct IndexInfo IndexInfo
 
typedef void(* ExprContextCallbackFunction) (Datum arg)
 
typedef struct ExprContext_CB ExprContext_CB
 
typedef struct ReturnSetInfo ReturnSetInfo
 
typedef struct ProjectionInfo ProjectionInfo
 
typedef struct JunkFilter JunkFilter
 
typedef struct OnConflictSetState OnConflictSetState
 
typedef struct MergeActionState MergeActionState
 
typedef struct ResultRelInfo ResultRelInfo
 
typedef struct AsyncRequest AsyncRequest
 
typedef struct EState EState
 
typedef struct ExecAuxRowMark ExecAuxRowMark
 
typedef struct TupleHashEntryDataTupleHashEntry
 
typedef struct TupleHashTableDataTupleHashTable
 
typedef struct TupleHashEntryData TupleHashEntryData
 
typedef struct TupleHashTableData TupleHashTableData
 
typedef tuplehash_iterator TupleHashIterator
 
typedef struct WindowFuncExprState WindowFuncExprState
 
typedef struct SetExprState SetExprState
 
typedef struct SubPlanState SubPlanState
 
typedef enum DomainConstraintType DomainConstraintType
 
typedef struct DomainConstraintState DomainConstraintState
 
typedef struct JsonExprState JsonExprState
 
typedef TupleTableSlot *(* ExecProcNodeMtd) (PlanState *pstate)
 
typedef struct EPQState EPQState
 
typedef struct ResultState ResultState
 
typedef struct ProjectSetState ProjectSetState
 
typedef struct ModifyTableState ModifyTableState
 
typedef struct AppendState AppendState
 
typedef struct ParallelAppendState ParallelAppendState
 
typedef struct MergeAppendState MergeAppendState
 
typedef struct RecursiveUnionState RecursiveUnionState
 
typedef struct BitmapAndState BitmapAndState
 
typedef struct BitmapOrState BitmapOrState
 
typedef struct ScanState ScanState
 
typedef struct SeqScanState SeqScanState
 
typedef struct SampleScanState SampleScanState
 
typedef struct IndexScanState IndexScanState
 
typedef struct IndexOnlyScanState IndexOnlyScanState
 
typedef struct BitmapIndexScanState BitmapIndexScanState
 
typedef struct ParallelBitmapHeapState ParallelBitmapHeapState
 
typedef struct BitmapHeapScanState BitmapHeapScanState
 
typedef struct TidScanState TidScanState
 
typedef struct TidRangeScanState TidRangeScanState
 
typedef struct SubqueryScanState SubqueryScanState
 
typedef struct FunctionScanState FunctionScanState
 
typedef struct ValuesScanState ValuesScanState
 
typedef struct TableFuncScanState TableFuncScanState
 
typedef struct CteScanState CteScanState
 
typedef struct NamedTuplestoreScanState NamedTuplestoreScanState
 
typedef struct WorkTableScanState WorkTableScanState
 
typedef struct ForeignScanState ForeignScanState
 
typedef struct CustomScanState CustomScanState
 
typedef struct JoinState JoinState
 
typedef struct NestLoopState NestLoopState
 
typedef struct MergeJoinClauseDataMergeJoinClause
 
typedef struct MergeJoinState MergeJoinState
 
typedef struct HashJoinTupleDataHashJoinTuple
 
typedef struct HashJoinTableDataHashJoinTable
 
typedef struct HashJoinState HashJoinState
 
typedef struct MaterialState MaterialState
 
typedef struct MemoizeState MemoizeState
 
typedef struct PresortedKeyData PresortedKeyData
 
typedef struct SortState SortState
 
typedef struct IncrementalSortState IncrementalSortState
 
typedef struct GroupState GroupState
 
typedef struct AggStatePerAggDataAggStatePerAgg
 
typedef struct AggStatePerTransDataAggStatePerTrans
 
typedef struct AggStatePerGroupDataAggStatePerGroup
 
typedef struct AggStatePerPhaseDataAggStatePerPhase
 
typedef struct AggStatePerHashDataAggStatePerHash
 
typedef struct AggState AggState
 
typedef struct WindowStatePerFuncDataWindowStatePerFunc
 
typedef struct WindowStatePerAggDataWindowStatePerAgg
 
typedef enum WindowAggStatus WindowAggStatus
 
typedef struct WindowAggState WindowAggState
 
typedef struct UniqueState UniqueState
 
typedef struct GatherState GatherState
 
typedef struct GatherMergeState GatherMergeState
 
typedef struct HashState HashState
 
typedef struct SetOpStatePerInput SetOpStatePerInput
 
typedef struct SetOpState SetOpState
 
typedef struct LockRowsState LockRowsState
 
typedef struct LimitState LimitState
 

Enumerations

enum  ExprDoneCond { ExprSingleResult , ExprMultipleResult , ExprEndResult }
 
enum  SetFunctionReturnMode { SFRM_ValuePerCall = 0x01 , SFRM_Materialize = 0x02 , SFRM_Materialize_Random = 0x04 , SFRM_Materialize_Preferred = 0x08 }
 
enum  DomainConstraintType { DOM_CONSTRAINT_NOTNULL , DOM_CONSTRAINT_CHECK }
 
enum  SharedBitmapState { BM_INITIAL , BM_INPROGRESS , BM_FINISHED }
 
enum  IncrementalSortExecutionStatus { INCSORT_LOADFULLSORT , INCSORT_LOADPREFIXSORT , INCSORT_READFULLSORT , INCSORT_READPREFIXSORT }
 
enum  WindowAggStatus { WINDOWAGG_DONE , WINDOWAGG_RUN , WINDOWAGG_PASSTHROUGH , WINDOWAGG_PASSTHROUGH_STRICT }
 
enum  LimitStateCond {
  LIMIT_INITIAL , LIMIT_RESCAN , LIMIT_EMPTY , LIMIT_INWINDOW ,
  LIMIT_WINDOWEND_TIES , LIMIT_SUBPLANEOF , LIMIT_WINDOWEND , LIMIT_WINDOWSTART
}
 

Macro Definition Documentation

◆ EEO_FLAG_HAS_NEW

#define EEO_FLAG_HAS_NEW   (1 << 2)

Definition at line 80 of file execnodes.h.

◆ EEO_FLAG_HAS_OLD

#define EEO_FLAG_HAS_OLD   (1 << 1)

Definition at line 78 of file execnodes.h.

◆ EEO_FLAG_IS_QUAL

#define EEO_FLAG_IS_QUAL   (1 << 0)

Definition at line 76 of file execnodes.h.

◆ EEO_FLAG_NEW_IS_NULL

#define EEO_FLAG_NEW_IS_NULL   (1 << 4)

Definition at line 84 of file execnodes.h.

◆ EEO_FLAG_OLD_IS_NULL

#define EEO_FLAG_OLD_IS_NULL   (1 << 3)

Definition at line 82 of file execnodes.h.

◆ FIELDNO_AGGSTATE_ALL_PERGROUPS

#define FIELDNO_AGGSTATE_ALL_PERGROUPS   54

Definition at line 2489 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURAGGCONTEXT

#define FIELDNO_AGGSTATE_CURAGGCONTEXT   14

Definition at line 2434 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURPERTRANS

#define FIELDNO_AGGSTATE_CURPERTRANS   16

Definition at line 2437 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURRENT_SET

#define FIELDNO_AGGSTATE_CURRENT_SET   20

Definition at line 2442 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_AGGNULLS

#define FIELDNO_EXPRCONTEXT_AGGNULLS   9

Definition at line 295 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_AGGVALUES

#define FIELDNO_EXPRCONTEXT_AGGVALUES   8

Definition at line 293 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_CASEDATUM

#define FIELDNO_EXPRCONTEXT_CASEDATUM   10

Definition at line 299 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_CASENULL

#define FIELDNO_EXPRCONTEXT_CASENULL   11

Definition at line 301 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_DOMAINDATUM

#define FIELDNO_EXPRCONTEXT_DOMAINDATUM   12

Definition at line 305 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_DOMAINNULL

#define FIELDNO_EXPRCONTEXT_DOMAINNULL   13

Definition at line 307 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_INNERTUPLE

#define FIELDNO_EXPRCONTEXT_INNERTUPLE   2

Definition at line 276 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_NEWTUPLE

#define FIELDNO_EXPRCONTEXT_NEWTUPLE   15

Definition at line 313 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_OLDTUPLE

#define FIELDNO_EXPRCONTEXT_OLDTUPLE   14

Definition at line 311 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_OUTERTUPLE

#define FIELDNO_EXPRCONTEXT_OUTERTUPLE   3

Definition at line 278 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_SCANTUPLE

#define FIELDNO_EXPRCONTEXT_SCANTUPLE   1

Definition at line 274 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_FLAGS

#define FIELDNO_EXPRSTATE_FLAGS   1

Definition at line 90 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_PARENT

#define FIELDNO_EXPRSTATE_PARENT   11

Definition at line 133 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESNULL

#define FIELDNO_EXPRSTATE_RESNULL   2

Definition at line 97 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESULTSLOT

#define FIELDNO_EXPRSTATE_RESULTSLOT   4

Definition at line 105 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESVALUE

#define FIELDNO_EXPRSTATE_RESVALUE   3

Definition at line 99 of file execnodes.h.

◆ InitTupleHashIterator

#define InitTupleHashIterator (   htable,
  iter 
)     tuplehash_start_iterate(htable->hashtab, iter)

Definition at line 896 of file execnodes.h.

923{
925 WindowFunc *wfunc; /* expression plan node */
926 List *args; /* ExprStates for argument expressions */
927 ExprState *aggfilter; /* FILTER expression */
928 int wfuncno; /* ID number for wfunc within its plan node */
930
931
932/* ----------------
933 * SetExprState node
934 *
935 * State for evaluating a potentially set-returning expression (like FuncExpr
936 * or OpExpr). In some cases, like some of the expressions in ROWS FROM(...)
937 * the expression might not be a SRF, but nonetheless it uses the same
938 * machinery as SRFs; it will be treated as a SRF returning a single row.
939 * ----------------
940 */
941typedef struct SetExprState
942{
944 Expr *expr; /* expression plan node */
945 List *args; /* ExprStates for argument expressions */
946
947 /*
948 * In ROWS FROM, functions can be inlined, removing the FuncExpr normally
949 * inside. In such a case this is the compiled expression (which cannot
950 * return a set), which'll be evaluated using regular ExecEvalExpr().
951 */
953
954 /*
955 * Function manager's lookup info for the target function. If func.fn_oid
956 * is InvalidOid, we haven't initialized it yet (nor any of the following
957 * fields, except funcReturnsSet).
958 */
960
961 /*
962 * For a set-returning function (SRF) that returns a tuplestore, we keep
963 * the tuplestore here and dole out the result rows one at a time. The
964 * slot holds the row currently being returned.
965 */
968
969 /*
970 * In some cases we need to compute a tuple descriptor for the function's
971 * output. If so, it's stored here.
972 */
974 bool funcReturnsTuple; /* valid when funcResultDesc isn't NULL */
975
976 /*
977 * Remember whether the function is declared to return a set. This is set
978 * by ExecInitExpr, and is valid even before the FmgrInfo is set up.
979 */
980 bool funcReturnsSet;
981
982 /*
983 * setArgsValid is true when we are evaluating a set-returning function
984 * that uses value-per-call mode and we are in the middle of a call
985 * series; we want to pass the same argument values to the function again
986 * (and again, until it returns ExprEndResult). This indicates that
987 * fcinfo_data already contains valid argument data.
988 */
989 bool setArgsValid;
990
991 /*
992 * Flag to remember whether we have registered a shutdown callback for
993 * this SetExprState. We do so only if funcResultStore or setArgsValid
994 * has been set at least once (since all the callback is for is to release
995 * the tuplestore or clear setArgsValid).
996 */
997 bool shutdown_reg; /* a shutdown callback is registered */
998
999 /*
1000 * Call parameter structure for the function. This has been initialized
1001 * (by InitFunctionCallInfoData) if func.fn_oid is valid. It also saves
1002 * argument values between calls, when setArgsValid is true.
1003 */
1005} SetExprState;
1006
1007/* ----------------
1008 * SubPlanState node
1009 * ----------------
1010 */
1011typedef struct SubPlanState
1012{
1013 NodeTag type;
1014 SubPlan *subplan; /* expression plan node */
1015 PlanState *planstate; /* subselect plan's state tree */
1016 PlanState *parent; /* parent plan node's state tree */
1017 ExprState *testexpr; /* state of combining expression */
1018 HeapTuple curTuple; /* copy of most recent tuple from subplan */
1019 Datum curArray; /* most recent array from ARRAY() subplan */
1020 /* these are used when hashing the subselect's output: */
1021 TupleDesc descRight; /* subselect desc after projection */
1022 ProjectionInfo *projLeft; /* for projecting lefthand exprs */
1023 ProjectionInfo *projRight; /* for projecting subselect output */
1024 TupleHashTable hashtable; /* hash table for no-nulls subselect rows */
1025 TupleHashTable hashnulls; /* hash table for rows with null(s) */
1026 bool havehashrows; /* true if hashtable is not empty */
1027 bool havenullrows; /* true if hashnulls is not empty */
1028 MemoryContext tuplesContext; /* context containing hash tables' tuples */
1029 ExprContext *innerecontext; /* econtext for computing inner tuples */
1030 int numCols; /* number of columns being hashed */
1031 /* each of the remaining fields is an array of length numCols: */
1032 AttrNumber *keyColIdx; /* control data for hash tables */
1033 Oid *tab_eq_funcoids; /* equality func oids for table
1034 * datatype(s) */
1035 Oid *tab_collations; /* collations for hash and comparison */
1036 FmgrInfo *tab_hash_funcs; /* hash functions for table datatype(s) */
1037 ExprState *lhs_hash_expr; /* hash expr for lefthand datatype(s) */
1038 FmgrInfo *cur_eq_funcs; /* equality functions for LHS vs. table */
1039 ExprState *cur_eq_comp; /* equality comparator for LHS vs. table */
1040} SubPlanState;
1041
1042/*
1043 * DomainConstraintState - one item to check during CoerceToDomain
1044 *
1045 * Note: we consider this to be part of an ExprState tree, so we give it
1046 * a name following the xxxState convention. But there's no directly
1047 * associated plan-tree node.
1048 */
1049typedef enum DomainConstraintType
1050{
1054
1055typedef struct DomainConstraintState
1056{
1057 NodeTag type;
1058 DomainConstraintType constrainttype; /* constraint type */
1059 char *name; /* name of constraint (for error msgs) */
1060 Expr *check_expr; /* for CHECK, a boolean expression */
1061 ExprState *check_exprstate; /* check_expr's eval state, or NULL */
1063
1064/*
1065 * State for JsonExpr evaluation, too big to inline.
1066 *
1067 * This contains the information going into and coming out of the
1068 * EEOP_JSONEXPR_PATH eval step.
1069 */
1070typedef struct JsonExprState
1071{
1072 /* original expression node */
1074
1075 /* value/isnull for formatted_expr */
1077
1078 /* value/isnull for pathspec */
1080
1081 /* JsonPathVariable entries for passing_values */
1082 List *args;
1083
1084 /*
1085 * Output variables that drive the EEOP_JUMP_IF_NOT_TRUE steps that are
1086 * added for ON ERROR and ON EMPTY expressions, if any.
1087 *
1088 * Reset for each evaluation of EEOP_JSONEXPR_PATH.
1089 */
1090
1091 /* Set to true if jsonpath evaluation cause an error. */
1093
1094 /* Set to true if the jsonpath evaluation returned 0 items. */
1096
1097 /*
1098 * Addresses of steps that implement the non-ERROR variant of ON EMPTY and
1099 * ON ERROR behaviors, respectively.
1100 */
1101 int jump_empty;
1102 int jump_error;
1103
1104 /*
1105 * Address of the step to coerce the result value of jsonpath evaluation
1106 * to the RETURNING type. -1 if no coercion if JsonExpr.use_io_coercion
1107 * is true.
1108 */
1110
1111 /*
1112 * Address to jump to when skipping all the steps after performing
1113 * ExecEvalJsonExprPath() so as to return whatever the JsonPath* function
1114 * returned as is, that is, in the cases where there's no error and no
1115 * coercion is necessary.
1116 */
1117 int jump_end;
1118
1119 /*
1120 * RETURNING type input function invocation info when
1121 * JsonExpr.use_io_coercion is true.
1122 */
1124
1125 /*
1126 * For error-safe evaluation of coercions. When the ON ERROR behavior is
1127 * not ERROR, a pointer to this is passed to ExecInitExprRec() when
1128 * initializing the coercion expressions or to ExecInitJsonCoercion().
1129 *
1130 * Reset for each evaluation of EEOP_JSONEXPR_PATH.
1131 */
1134
1135
1136/* ----------------------------------------------------------------
1137 * Executor State Trees
1138 *
1139 * An executing query has a PlanState tree paralleling the Plan tree
1140 * that describes the plan.
1141 * ----------------------------------------------------------------
1142 */
1143
1144/* ----------------
1145 * ExecProcNodeMtd
1146 *
1147 * This is the method called by ExecProcNode to return the next tuple
1148 * from an executor node. It returns NULL, or an empty TupleTableSlot,
1149 * if no more tuples are available.
1150 * ----------------
1151 */
1152typedef TupleTableSlot *(*ExecProcNodeMtd) (PlanState *pstate);
1153
1154/* ----------------
1155 * PlanState node
1156 *
1157 * We never actually instantiate any PlanState nodes; this is just the common
1158 * abstract superclass for all PlanState-type nodes.
1159 * ----------------
1160 */
1161typedef struct PlanState
1162{
1163 pg_node_attr(abstract)
1164
1165 NodeTag type;
1166
1167 Plan *plan; /* associated Plan node */
1168
1169 EState *state; /* at execution time, states of individual
1170 * nodes point to one EState for the whole
1171 * top-level plan */
1172
1173 ExecProcNodeMtd ExecProcNode; /* function to return next tuple */
1174 ExecProcNodeMtd ExecProcNodeReal; /* actual function, if above is a
1175 * wrapper */
1176
1177 Instrumentation *instrument; /* Optional runtime stats for this node */
1178 WorkerInstrumentation *worker_instrument; /* per-worker instrumentation */
1179
1180 /* Per-worker JIT instrumentation */
1182
1183 /*
1184 * Common structural data for all Plan types. These links to subsidiary
1185 * state trees parallel links in the associated plan tree (except for the
1186 * subPlan list, which does not exist in the plan tree).
1187 */
1188 ExprState *qual; /* boolean qual condition */
1189 PlanState *lefttree; /* input plan tree(s) */
1191
1192 List *initPlan; /* Init SubPlanState nodes (un-correlated expr
1193 * subselects) */
1194 List *subPlan; /* SubPlanState nodes in my expressions */
1195
1196 /*
1197 * State for management of parameter-change-driven rescanning
1198 */
1199 Bitmapset *chgParam; /* set of IDs of changed Params */
1200
1201 /*
1202 * Other run-time state needed by most if not all node types.
1203 */
1204 TupleDesc ps_ResultTupleDesc; /* node's return type */
1205 TupleTableSlot *ps_ResultTupleSlot; /* slot for my result tuples */
1206 ExprContext *ps_ExprContext; /* node's expression-evaluation context */
1207 ProjectionInfo *ps_ProjInfo; /* info for doing tuple projection */
1208
1209 bool async_capable; /* true if node is async-capable */
1210
1211 /*
1212 * Scanslot's descriptor if known. This is a bit of a hack, but otherwise
1213 * it's hard for expression compilation to optimize based on the
1214 * descriptor, without encoding knowledge about all executor nodes.
1215 */
1217
1218 /*
1219 * Define the slot types for inner, outer and scanslots for expression
1220 * contexts with this state as a parent. If *opsset is set, then
1221 * *opsfixed indicates whether *ops is guaranteed to be the type of slot
1222 * used. That means that every slot in the corresponding
1223 * ExprContext.ecxt_*tuple will point to a slot of that type, while
1224 * evaluating the expression. If *opsfixed is false, but *ops is set,
1225 * that indicates the most likely type of slot.
1226 *
1227 * The scan* fields are set by ExecInitScanTupleSlot(). If that's not
1228 * called, nodes can initialize the fields themselves.
1229 *
1230 * If outer/inneropsset is false, the information is inferred on-demand
1231 * using ExecGetResultSlotOps() on ->righttree/lefttree, using the
1232 * corresponding node's resultops* fields.
1233 *
1234 * The result* fields are automatically set when ExecInitResultSlot is
1235 * used (be it directly or when the slot is created by
1236 * ExecAssignScanProjectionInfo() /
1237 * ExecConditionalAssignProjectionInfo()). If no projection is necessary
1238 * ExecConditionalAssignProjectionInfo() defaults those fields to the scan
1239 * operations.
1240 */
1245 bool scanopsfixed;
1246 bool outeropsfixed;
1247 bool inneropsfixed;
1248 bool resultopsfixed;
1249 bool scanopsset;
1250 bool outeropsset;
1251 bool inneropsset;
1252 bool resultopsset;
1253} PlanState;
1254
1255/* ----------------
1256 * these are defined to avoid confusion problems with "left"
1257 * and "right" and "inner" and "outer". The convention is that
1258 * the "left" plan is the "outer" plan and the "right" plan is
1259 * the inner plan, but these make the code more readable.
1260 * ----------------
1261 */
1262#define innerPlanState(node) (((PlanState *)(node))->righttree)
1263#define outerPlanState(node) (((PlanState *)(node))->lefttree)
1264
1265/* Macros for inline access to certain instrumentation counters */
1266#define InstrCountTuples2(node, delta) \
1267 do { \
1268 if (((PlanState *)(node))->instrument) \
1269 ((PlanState *)(node))->instrument->ntuples2 += (delta); \
1270 } while (0)
1271#define InstrCountFiltered1(node, delta) \
1272 do { \
1273 if (((PlanState *)(node))->instrument) \
1274 ((PlanState *)(node))->instrument->nfiltered1 += (delta); \
1275 } while(0)
1276#define InstrCountFiltered2(node, delta) \
1277 do { \
1278 if (((PlanState *)(node))->instrument) \
1279 ((PlanState *)(node))->instrument->nfiltered2 += (delta); \
1280 } while(0)
1281
1282/*
1283 * EPQState is state for executing an EvalPlanQual recheck on a candidate
1284 * tuples e.g. in ModifyTable or LockRows.
1285 *
1286 * To execute EPQ a separate EState is created (stored in ->recheckestate),
1287 * which shares some resources, like the rangetable, with the main query's
1288 * EState (stored in ->parentestate). The (sub-)tree of the plan that needs to
1289 * be rechecked (in ->plan), is separately initialized (into
1290 * ->recheckplanstate), but shares plan nodes with the corresponding nodes in
1291 * the main query. The scan nodes in that separate executor tree are changed
1292 * to return only the current tuple of interest for the respective
1293 * table. Those tuples are either provided by the caller (using
1294 * EvalPlanQualSlot), and/or found using the rowmark mechanism (non-locking
1295 * rowmarks by the EPQ machinery itself, locking ones by the caller).
1296 *
1297 * While the plan to be checked may be changed using EvalPlanQualSetPlan(),
1298 * all such plans need to share the same EState.
1299 */
1300typedef struct EPQState
1301{
1302 /* These are initialized by EvalPlanQualInit() and do not change later: */
1303 EState *parentestate; /* main query's EState */
1304 int epqParam; /* ID of Param to force scan node re-eval */
1305 List *resultRelations; /* integer list of RT indexes, or NIL */
1306
1307 /*
1308 * relsubs_slot[scanrelid - 1] holds the EPQ test tuple to be returned by
1309 * the scan node for the scanrelid'th RT index, in place of performing an
1310 * actual table scan. Callers should use EvalPlanQualSlot() to fetch
1311 * these slots.
1312 */
1313 List *tuple_table; /* tuple table for relsubs_slot */
1314 TupleTableSlot **relsubs_slot;
1315
1316 /*
1317 * Initialized by EvalPlanQualInit(), may be changed later with
1318 * EvalPlanQualSetPlan():
1319 */
1320
1321 Plan *plan; /* plan tree to be executed */
1322 List *arowMarks; /* ExecAuxRowMarks (non-locking only) */
1323
1324
1325 /*
1326 * The original output tuple to be rechecked. Set by
1327 * EvalPlanQualSetSlot(), before EvalPlanQualNext() or EvalPlanQual() may
1328 * be called.
1329 */
1330 TupleTableSlot *origslot;
1331
1332
1333 /* Initialized or reset by EvalPlanQualBegin(): */
1334
1335 EState *recheckestate; /* EState for EPQ execution, see above */
1336
1337 /*
1338 * Rowmarks that can be fetched on-demand using
1339 * EvalPlanQualFetchRowMark(), indexed by scanrelid - 1. Only non-locking
1340 * rowmarks.
1341 */
1342 ExecAuxRowMark **relsubs_rowmark;
1343
1344 /*
1345 * relsubs_done[scanrelid - 1] is true if there is no EPQ tuple for this
1346 * target relation or it has already been fetched in the current scan of
1347 * this target relation within the current EvalPlanQual test.
1348 */
1349 bool *relsubs_done;
1350
1351 /*
1352 * relsubs_blocked[scanrelid - 1] is true if there is no EPQ tuple for
1353 * this target relation during the current EvalPlanQual test. We keep
1354 * these flags set for all relids listed in resultRelations, but
1355 * transiently clear the one for the relation whose tuple is actually
1356 * passed to EvalPlanQual().
1357 */
1358 bool *relsubs_blocked;
1359
1360 PlanState *recheckplanstate; /* EPQ specific exec nodes, for ->plan */
1361} EPQState;
1362
1363
1364/* ----------------
1365 * ResultState information
1366 * ----------------
1367 */
1368typedef struct ResultState
1369{
1370 PlanState ps; /* its first field is NodeTag */
1371 ExprState *resconstantqual;
1372 bool rs_done; /* are we done? */
1373 bool rs_checkqual; /* do we need to check the qual? */
1374} ResultState;
1375
1376/* ----------------
1377 * ProjectSetState information
1378 *
1379 * Note: at least one of the "elems" will be a SetExprState; the rest are
1380 * regular ExprStates.
1381 * ----------------
1382 */
1383typedef struct ProjectSetState
1384{
1385 PlanState ps; /* its first field is NodeTag */
1386 Node **elems; /* array of expression states */
1387 ExprDoneCond *elemdone; /* array of per-SRF is-done states */
1388 int nelems; /* length of elemdone[] array */
1389 bool pending_srf_tuples; /* still evaluating srfs in tlist? */
1390 MemoryContext argcontext; /* context for SRF arguments */
1392
1393
1394/* flags for mt_merge_subcommands */
1395#define MERGE_INSERT 0x01
1396#define MERGE_UPDATE 0x02
1397#define MERGE_DELETE 0x04
1398
1399/* ----------------
1400 * ModifyTableState information
1401 * ----------------
1402 */
1403typedef struct ModifyTableState
1404{
1405 PlanState ps; /* its first field is NodeTag */
1406 CmdType operation; /* INSERT, UPDATE, DELETE, or MERGE */
1407 bool canSetTag; /* do we set the command tag/es_processed? */
1408 bool mt_done; /* are we done? */
1409 int mt_nrels; /* number of entries in resultRelInfo[] */
1410 ResultRelInfo *resultRelInfo; /* info about target relation(s) */
1411
1412 /*
1413 * Target relation mentioned in the original statement, used to fire
1414 * statement-level triggers and as the root for tuple routing. (This
1415 * might point to one of the resultRelInfo[] entries, but it can also be a
1416 * distinct struct.)
1417 */
1418 ResultRelInfo *rootResultRelInfo;
1419
1420 EPQState mt_epqstate; /* for evaluating EvalPlanQual rechecks */
1421 bool fireBSTriggers; /* do we need to fire stmt triggers? */
1422
1423 /*
1424 * These fields are used for inherited UPDATE and DELETE, to track which
1425 * target relation a given tuple is from. If there are a lot of target
1426 * relations, we use a hash table to translate table OIDs to
1427 * resultRelInfo[] indexes; otherwise mt_resultOidHash is NULL.
1428 */
1429 int mt_resultOidAttno; /* resno of "tableoid" junk attr */
1430 Oid mt_lastResultOid; /* last-seen value of tableoid */
1431 int mt_lastResultIndex; /* corresponding index in resultRelInfo[] */
1432 HTAB *mt_resultOidHash; /* optional hash table to speed lookups */
1433
1434 /*
1435 * Slot for storing tuples in the root partitioned table's rowtype during
1436 * an UPDATE of a partitioned table.
1437 */
1438 TupleTableSlot *mt_root_tuple_slot;
1439
1440 /* Tuple-routing support info */
1441 struct PartitionTupleRouting *mt_partition_tuple_routing;
1442
1443 /* controls transition table population for specified operation */
1444 struct TransitionCaptureState *mt_transition_capture;
1445
1446 /* controls transition table population for INSERT...ON CONFLICT UPDATE */
1447 struct TransitionCaptureState *mt_oc_transition_capture;
1448
1449 /* Flags showing which subcommands are present INS/UPD/DEL/DO NOTHING */
1450 int mt_merge_subcommands;
1451
1452 /* For MERGE, the action currently being executed */
1453 MergeActionState *mt_merge_action;
1454
1455 /*
1456 * For MERGE, if there is a pending NOT MATCHED [BY TARGET] action to be
1457 * performed, this will be the last tuple read from the subplan; otherwise
1458 * it will be NULL --- see the comments in ExecMerge().
1459 */
1460 TupleTableSlot *mt_merge_pending_not_matched;
1461
1462 /* tuple counters for MERGE */
1463 double mt_merge_inserted;
1464 double mt_merge_updated;
1465 double mt_merge_deleted;
1466
1467 /*
1468 * Lists of valid updateColnosLists, mergeActionLists, and
1469 * mergeJoinConditions. These contain only entries for unpruned
1470 * relations, filtered from the corresponding lists in ModifyTable.
1471 */
1472 List *mt_updateColnosLists;
1473 List *mt_mergeActionLists;
1474 List *mt_mergeJoinConditions;
1476
1477/* ----------------
1478 * AppendState information
1479 *
1480 * nplans how many plans are in the array
1481 * whichplan which synchronous plan is being executed (0 .. n-1)
1482 * or a special negative value. See nodeAppend.c.
1483 * prune_state details required to allow partitions to be
1484 * eliminated from the scan, or NULL if not possible.
1485 * valid_subplans for runtime pruning, valid synchronous appendplans
1486 * indexes to scan.
1487 * ----------------
1488 */
1489
1490struct AppendState;
1491typedef struct AppendState AppendState;
1492struct ParallelAppendState;
1494struct PartitionPruneState;
1495
1496struct AppendState
1497{
1498 PlanState ps; /* its first field is NodeTag */
1499 PlanState **appendplans; /* array of PlanStates for my inputs */
1500 int as_nplans;
1501 int as_whichplan;
1502 bool as_begun; /* false means need to initialize */
1503 Bitmapset *as_asyncplans; /* asynchronous plans indexes */
1504 int as_nasyncplans; /* # of asynchronous plans */
1505 AsyncRequest **as_asyncrequests; /* array of AsyncRequests */
1506 TupleTableSlot **as_asyncresults; /* unreturned results of async plans */
1507 int as_nasyncresults; /* # of valid entries in as_asyncresults */
1508 bool as_syncdone; /* true if all synchronous plans done in
1509 * asynchronous mode, else false */
1510 int as_nasyncremain; /* # of remaining asynchronous plans */
1511 Bitmapset *as_needrequest; /* asynchronous plans needing a new request */
1512 struct WaitEventSet *as_eventset; /* WaitEventSet used to configure file
1513 * descriptor wait events */
1514 int as_first_partial_plan; /* Index of 'appendplans' containing
1515 * the first partial plan */
1516 ParallelAppendState *as_pstate; /* parallel coordination info */
1517 Size pstate_len; /* size of parallel coordination info */
1518 struct PartitionPruneState *as_prune_state;
1519 bool as_valid_subplans_identified; /* is as_valid_subplans valid? */
1520 Bitmapset *as_valid_subplans;
1521 Bitmapset *as_valid_asyncplans; /* valid asynchronous plans indexes */
1522 bool (*choose_next_subplan) (AppendState *);
1523};
1524
1525/* ----------------
1526 * MergeAppendState information
1527 *
1528 * nplans how many plans are in the array
1529 * nkeys number of sort key columns
1530 * sortkeys sort keys in SortSupport representation
1531 * slots current output tuple of each subplan
1532 * heap heap of active tuples
1533 * initialized true if we have fetched first tuple from each subplan
1534 * prune_state details required to allow partitions to be
1535 * eliminated from the scan, or NULL if not possible.
1536 * valid_subplans for runtime pruning, valid mergeplans indexes to
1537 * scan.
1538 * ----------------
1539 */
1540typedef struct MergeAppendState
1541{
1542 PlanState ps; /* its first field is NodeTag */
1543 PlanState **mergeplans; /* array of PlanStates for my inputs */
1544 int ms_nplans;
1545 int ms_nkeys;
1546 SortSupport ms_sortkeys; /* array of length ms_nkeys */
1547 TupleTableSlot **ms_slots; /* array of length ms_nplans */
1548 struct binaryheap *ms_heap; /* binary heap of slot indices */
1549 bool ms_initialized; /* are subplans started? */
1550 struct PartitionPruneState *ms_prune_state;
1551 Bitmapset *ms_valid_subplans;
1553
1554/* ----------------
1555 * RecursiveUnionState information
1556 *
1557 * RecursiveUnionState is used for performing a recursive union.
1558 *
1559 * recursing T when we're done scanning the non-recursive term
1560 * intermediate_empty T if intermediate_table is currently empty
1561 * working_table working table (to be scanned by recursive term)
1562 * intermediate_table current recursive output (next generation of WT)
1563 * ----------------
1564 */
1565typedef struct RecursiveUnionState
1566{
1567 PlanState ps; /* its first field is NodeTag */
1568 bool recursing;
1569 bool intermediate_empty;
1570 Tuplestorestate *working_table;
1571 Tuplestorestate *intermediate_table;
1572 /* Remaining fields are unused in UNION ALL case */
1573 Oid *eqfuncoids; /* per-grouping-field equality fns */
1574 FmgrInfo *hashfunctions; /* per-grouping-field hash fns */
1575 MemoryContext tempContext; /* short-term context for comparisons */
1576 TupleHashTable hashtable; /* hash table for tuples already seen */
1577 MemoryContext tuplesContext; /* context containing hash table's tuples */
1579
1580/* ----------------
1581 * BitmapAndState information
1582 * ----------------
1583 */
1584typedef struct BitmapAndState
1585{
1586 PlanState ps; /* its first field is NodeTag */
1587 PlanState **bitmapplans; /* array of PlanStates for my inputs */
1588 int nplans; /* number of input plans */
1590
1591/* ----------------
1592 * BitmapOrState information
1593 * ----------------
1594 */
1595typedef struct BitmapOrState
1596{
1597 PlanState ps; /* its first field is NodeTag */
1598 PlanState **bitmapplans; /* array of PlanStates for my inputs */
1599 int nplans; /* number of input plans */
1601
1602/* ----------------------------------------------------------------
1603 * Scan State Information
1604 * ----------------------------------------------------------------
1605 */
1606
1607/* ----------------
1608 * ScanState information
1609 *
1610 * ScanState extends PlanState for node types that represent
1611 * scans of an underlying relation. It can also be used for nodes
1612 * that scan the output of an underlying plan node --- in that case,
1613 * only ScanTupleSlot is actually useful, and it refers to the tuple
1614 * retrieved from the subplan.
1615 *
1616 * currentRelation relation being scanned (NULL if none)
1617 * currentScanDesc current scan descriptor for scan (NULL if none)
1618 * ScanTupleSlot pointer to slot in tuple table holding scan tuple
1619 * ----------------
1620 */
1621typedef struct ScanState
1622{
1623 PlanState ps; /* its first field is NodeTag */
1624 Relation ss_currentRelation;
1625 struct TableScanDescData *ss_currentScanDesc;
1626 TupleTableSlot *ss_ScanTupleSlot;
1627} ScanState;
1628
1629/* ----------------
1630 * SeqScanState information
1631 * ----------------
1632 */
1633typedef struct SeqScanState
1634{
1635 ScanState ss; /* its first field is NodeTag */
1636 Size pscan_len; /* size of parallel heap scan descriptor */
1637} SeqScanState;
1638
1639/* ----------------
1640 * SampleScanState information
1641 * ----------------
1642 */
1643typedef struct SampleScanState
1644{
1645 ScanState ss;
1646 List *args; /* expr states for TABLESAMPLE params */
1647 ExprState *repeatable; /* expr state for REPEATABLE expr */
1648 /* use struct pointer to avoid including tsmapi.h here */
1649 struct TsmRoutine *tsmroutine; /* descriptor for tablesample method */
1650 void *tsm_state; /* tablesample method can keep state here */
1651 bool use_bulkread; /* use bulkread buffer access strategy? */
1652 bool use_pagemode; /* use page-at-a-time visibility checking? */
1653 bool begun; /* false means need to call BeginSampleScan */
1654 uint32 seed; /* random seed */
1655 int64 donetuples; /* number of tuples already returned */
1656 bool haveblock; /* has a block for sampling been determined */
1657 bool done; /* exhausted all tuples? */
1659
1660/*
1661 * These structs store information about index quals that don't have simple
1662 * constant right-hand sides. See comments for ExecIndexBuildScanKeys()
1663 * for discussion.
1664 */
1665typedef struct
1666{
1667 ScanKeyData *scan_key; /* scankey to put value into */
1668 ExprState *key_expr; /* expr to evaluate to get value */
1669 bool key_toastable; /* is expr's result a toastable datatype? */
1671
1672typedef struct
1673{
1674 ScanKeyData *scan_key; /* scankey to put value into */
1675 ExprState *array_expr; /* expr to evaluate to get array value */
1676 int next_elem; /* next array element to use */
1677 int num_elems; /* number of elems in current array value */
1678 Datum *elem_values; /* array of num_elems Datums */
1679 bool *elem_nulls; /* array of num_elems is-null flags */
1681
1682/* ----------------
1683 * IndexScanState information
1684 *
1685 * indexqualorig execution state for indexqualorig expressions
1686 * indexorderbyorig execution state for indexorderbyorig expressions
1687 * ScanKeys Skey structures for index quals
1688 * NumScanKeys number of ScanKeys
1689 * OrderByKeys Skey structures for index ordering operators
1690 * NumOrderByKeys number of OrderByKeys
1691 * RuntimeKeys info about Skeys that must be evaluated at runtime
1692 * NumRuntimeKeys number of RuntimeKeys
1693 * RuntimeKeysReady true if runtime Skeys have been computed
1694 * RuntimeContext expr context for evaling runtime Skeys
1695 * RelationDesc index relation descriptor
1696 * ScanDesc index scan descriptor
1697 * Instrument local index scan instrumentation
1698 * SharedInfo parallel worker instrumentation (no leader entry)
1699 *
1700 * ReorderQueue tuples that need reordering due to re-check
1701 * ReachedEnd have we fetched all tuples from index already?
1702 * OrderByValues values of ORDER BY exprs of last fetched tuple
1703 * OrderByNulls null flags for OrderByValues
1704 * SortSupport for reordering ORDER BY exprs
1705 * OrderByTypByVals is the datatype of order by expression pass-by-value?
1706 * OrderByTypLens typlens of the datatypes of order by expressions
1707 * PscanLen size of parallel index scan descriptor
1708 * ----------------
1709 */
1710typedef struct IndexScanState
1711{
1712 ScanState ss; /* its first field is NodeTag */
1713 ExprState *indexqualorig;
1714 List *indexorderbyorig;
1715 ScanKeyData *iss_ScanKeys;
1716 int iss_NumScanKeys;
1717 ScanKeyData *iss_OrderByKeys;
1718 int iss_NumOrderByKeys;
1719 IndexRuntimeKeyInfo *iss_RuntimeKeys;
1720 int iss_NumRuntimeKeys;
1721 bool iss_RuntimeKeysReady;
1722 ExprContext *iss_RuntimeContext;
1723 Relation iss_RelationDesc;
1724 struct IndexScanDescData *iss_ScanDesc;
1725 IndexScanInstrumentation iss_Instrument;
1726 SharedIndexScanInstrumentation *iss_SharedInfo;
1727
1728 /* These are needed for re-checking ORDER BY expr ordering */
1729 pairingheap *iss_ReorderQueue;
1730 bool iss_ReachedEnd;
1731 Datum *iss_OrderByValues;
1732 bool *iss_OrderByNulls;
1733 SortSupport iss_SortSupport;
1734 bool *iss_OrderByTypByVals;
1735 int16 *iss_OrderByTypLens;
1736 Size iss_PscanLen;
1738
1739/* ----------------
1740 * IndexOnlyScanState information
1741 *
1742 * recheckqual execution state for recheckqual expressions
1743 * ScanKeys Skey structures for index quals
1744 * NumScanKeys number of ScanKeys
1745 * OrderByKeys Skey structures for index ordering operators
1746 * NumOrderByKeys number of OrderByKeys
1747 * RuntimeKeys info about Skeys that must be evaluated at runtime
1748 * NumRuntimeKeys number of RuntimeKeys
1749 * RuntimeKeysReady true if runtime Skeys have been computed
1750 * RuntimeContext expr context for evaling runtime Skeys
1751 * RelationDesc index relation descriptor
1752 * ScanDesc index scan descriptor
1753 * Instrument local index scan instrumentation
1754 * SharedInfo parallel worker instrumentation (no leader entry)
1755 * TableSlot slot for holding tuples fetched from the table
1756 * VMBuffer buffer in use for visibility map testing, if any
1757 * PscanLen size of parallel index-only scan descriptor
1758 * NameCStringAttNums attnums of name typed columns to pad to NAMEDATALEN
1759 * NameCStringCount number of elements in the NameCStringAttNums array
1760 * ----------------
1761 */
1762typedef struct IndexOnlyScanState
1763{
1764 ScanState ss; /* its first field is NodeTag */
1765 ExprState *recheckqual;
1766 ScanKeyData *ioss_ScanKeys;
1767 int ioss_NumScanKeys;
1768 ScanKeyData *ioss_OrderByKeys;
1769 int ioss_NumOrderByKeys;
1770 IndexRuntimeKeyInfo *ioss_RuntimeKeys;
1771 int ioss_NumRuntimeKeys;
1772 bool ioss_RuntimeKeysReady;
1773 ExprContext *ioss_RuntimeContext;
1774 Relation ioss_RelationDesc;
1775 struct IndexScanDescData *ioss_ScanDesc;
1776 IndexScanInstrumentation ioss_Instrument;
1777 SharedIndexScanInstrumentation *ioss_SharedInfo;
1778 TupleTableSlot *ioss_TableSlot;
1779 Buffer ioss_VMBuffer;
1780 Size ioss_PscanLen;
1781 AttrNumber *ioss_NameCStringAttNums;
1782 int ioss_NameCStringCount;
1784
1785/* ----------------
1786 * BitmapIndexScanState information
1787 *
1788 * result bitmap to return output into, or NULL
1789 * ScanKeys Skey structures for index quals
1790 * NumScanKeys number of ScanKeys
1791 * RuntimeKeys info about Skeys that must be evaluated at runtime
1792 * NumRuntimeKeys number of RuntimeKeys
1793 * ArrayKeys info about Skeys that come from ScalarArrayOpExprs
1794 * NumArrayKeys number of ArrayKeys
1795 * RuntimeKeysReady true if runtime Skeys have been computed
1796 * RuntimeContext expr context for evaling runtime Skeys
1797 * RelationDesc index relation descriptor
1798 * ScanDesc index scan descriptor
1799 * Instrument local index scan instrumentation
1800 * SharedInfo parallel worker instrumentation (no leader entry)
1801 * ----------------
1802 */
1803typedef struct BitmapIndexScanState
1804{
1805 ScanState ss; /* its first field is NodeTag */
1806 TIDBitmap *biss_result;
1807 ScanKeyData *biss_ScanKeys;
1808 int biss_NumScanKeys;
1809 IndexRuntimeKeyInfo *biss_RuntimeKeys;
1810 int biss_NumRuntimeKeys;
1811 IndexArrayKeyInfo *biss_ArrayKeys;
1812 int biss_NumArrayKeys;
1813 bool biss_RuntimeKeysReady;
1814 ExprContext *biss_RuntimeContext;
1815 Relation biss_RelationDesc;
1816 struct IndexScanDescData *biss_ScanDesc;
1817 IndexScanInstrumentation biss_Instrument;
1818 SharedIndexScanInstrumentation *biss_SharedInfo;
1820
1821/* ----------------
1822 * SharedBitmapState information
1823 *
1824 * BM_INITIAL TIDBitmap creation is not yet started, so first worker
1825 * to see this state will set the state to BM_INPROGRESS
1826 * and that process will be responsible for creating
1827 * TIDBitmap.
1828 * BM_INPROGRESS TIDBitmap creation is in progress; workers need to
1829 * sleep until it's finished.
1830 * BM_FINISHED TIDBitmap creation is done, so now all workers can
1831 * proceed to iterate over TIDBitmap.
1832 * ----------------
1833 */
1834typedef enum
1835{
1836 BM_INITIAL,
1840
1841/* ----------------
1842 * ParallelBitmapHeapState information
1843 * tbmiterator iterator for scanning current pages
1844 * mutex mutual exclusion for state
1845 * state current state of the TIDBitmap
1846 * cv conditional wait variable
1847 * ----------------
1848 */
1849typedef struct ParallelBitmapHeapState
1850{
1851 dsa_pointer tbmiterator;
1852 slock_t mutex;
1856
1857/* ----------------
1858 * BitmapHeapScanState information
1859 *
1860 * bitmapqualorig execution state for bitmapqualorig expressions
1861 * tbm bitmap obtained from child index scan(s)
1862 * stats execution statistics
1863 * initialized is node is ready to iterate
1864 * pstate shared state for parallel bitmap scan
1865 * sinstrument statistics for parallel workers
1866 * recheck do current page's tuples need recheck
1867 * ----------------
1868 */
1869typedef struct BitmapHeapScanState
1870{
1871 ScanState ss; /* its first field is NodeTag */
1872 ExprState *bitmapqualorig;
1873 TIDBitmap *tbm;
1875 bool initialized;
1878 bool recheck;
1880
1881/* ----------------
1882 * TidScanState information
1883 *
1884 * tidexprs list of TidExpr structs (see nodeTidscan.c)
1885 * isCurrentOf scan has a CurrentOfExpr qual
1886 * NumTids number of tids in this scan
1887 * TidPtr index of currently fetched tid
1888 * TidList evaluated item pointers (array of size NumTids)
1889 * ----------------
1890 */
1891typedef struct TidScanState
1892{
1893 ScanState ss; /* its first field is NodeTag */
1894 List *tss_tidexprs;
1895 bool tss_isCurrentOf;
1896 int tss_NumTids;
1897 int tss_TidPtr;
1898 ItemPointerData *tss_TidList;
1899} TidScanState;
1900
1901/* ----------------
1902 * TidRangeScanState information
1903 *
1904 * trss_tidexprs list of TidOpExpr structs (see nodeTidrangescan.c)
1905 * trss_mintid the lowest TID in the scan range
1906 * trss_maxtid the highest TID in the scan range
1907 * trss_inScan is a scan currently in progress?
1908 * trss_pscanlen size of parallel heap scan descriptor
1909 * ----------------
1910 */
1911typedef struct TidRangeScanState
1912{
1913 ScanState ss; /* its first field is NodeTag */
1914 List *trss_tidexprs;
1915 ItemPointerData trss_mintid;
1916 ItemPointerData trss_maxtid;
1917 bool trss_inScan;
1918 Size trss_pscanlen;
1920
1921/* ----------------
1922 * SubqueryScanState information
1923 *
1924 * SubqueryScanState is used for scanning a sub-query in the range table.
1925 * ScanTupleSlot references the current output tuple of the sub-query.
1926 * ----------------
1927 */
1928typedef struct SubqueryScanState
1929{
1930 ScanState ss; /* its first field is NodeTag */
1931 PlanState *subplan;
1933
1934/* ----------------
1935 * FunctionScanState information
1936 *
1937 * Function nodes are used to scan the results of a
1938 * function appearing in FROM (typically a function returning set).
1939 *
1940 * eflags node's capability flags
1941 * ordinality is this scan WITH ORDINALITY?
1942 * simple true if we have 1 function and no ordinality
1943 * ordinal current ordinal column value
1944 * nfuncs number of functions being executed
1945 * funcstates per-function execution states (private in
1946 * nodeFunctionscan.c)
1947 * argcontext memory context to evaluate function arguments in
1948 * ----------------
1949 */
1951
1952typedef struct FunctionScanState
1953{
1954 ScanState ss; /* its first field is NodeTag */
1955 int eflags;
1956 bool ordinality;
1957 bool simple;
1958 int64 ordinal;
1959 int nfuncs;
1960 struct FunctionScanPerFuncState *funcstates; /* array of length nfuncs */
1961 MemoryContext argcontext;
1963
1964/* ----------------
1965 * ValuesScanState information
1966 *
1967 * ValuesScan nodes are used to scan the results of a VALUES list
1968 *
1969 * rowcontext per-expression-list context
1970 * exprlists array of expression lists being evaluated
1971 * exprstatelists array of expression state lists, for SubPlans only
1972 * array_len size of above arrays
1973 * curr_idx current array index (0-based)
1974 *
1975 * Note: ss.ps.ps_ExprContext is used to evaluate any qual or projection
1976 * expressions attached to the node. We create a second ExprContext,
1977 * rowcontext, in which to build the executor expression state for each
1978 * Values sublist. Resetting this context lets us get rid of expression
1979 * state for each row, avoiding major memory leakage over a long values list.
1980 * However, that doesn't work for sublists containing SubPlans, because a
1981 * SubPlan has to be connected up to the outer plan tree to work properly.
1982 * Therefore, for only those sublists containing SubPlans, we do expression
1983 * state construction at executor start, and store those pointers in
1984 * exprstatelists[]. NULL entries in that array correspond to simple
1985 * subexpressions that are handled as described above.
1986 * ----------------
1987 */
1988typedef struct ValuesScanState
1989{
1990 ScanState ss; /* its first field is NodeTag */
1991 ExprContext *rowcontext;
1992 List **exprlists;
1993 List **exprstatelists;
1994 int array_len;
1995 int curr_idx;
1997
1998/* ----------------
1999 * TableFuncScanState node
2000 *
2001 * Used in table-expression functions like XMLTABLE.
2002 * ----------------
2003 */
2004typedef struct TableFuncScanState
2005{
2006 ScanState ss; /* its first field is NodeTag */
2007 ExprState *docexpr; /* state for document expression */
2008 ExprState *rowexpr; /* state for row-generating expression */
2009 List *colexprs; /* state for column-generating expression */
2010 List *coldefexprs; /* state for column default expressions */
2011 List *colvalexprs; /* state for column value expressions */
2012 List *passingvalexprs; /* state for PASSING argument expressions */
2013 List *ns_names; /* same as TableFunc.ns_names */
2014 List *ns_uris; /* list of states of namespace URI exprs */
2015 Bitmapset *notnulls; /* nullability flag for each output column */
2016 void *opaque; /* table builder private space */
2017 const struct TableFuncRoutine *routine; /* table builder methods */
2018 FmgrInfo *in_functions; /* input function for each column */
2019 Oid *typioparams; /* typioparam for each column */
2020 int64 ordinal; /* row number to be output next */
2021 MemoryContext perTableCxt; /* per-table context */
2022 Tuplestorestate *tupstore; /* output tuple store */
2024
2025/* ----------------
2026 * CteScanState information
2027 *
2028 * CteScan nodes are used to scan a CommonTableExpr query.
2029 *
2030 * Multiple CteScan nodes can read out from the same CTE query. We use
2031 * a tuplestore to hold rows that have been read from the CTE query but
2032 * not yet consumed by all readers.
2033 * ----------------
2034 */
2035typedef struct CteScanState
2036{
2037 ScanState ss; /* its first field is NodeTag */
2038 int eflags; /* capability flags to pass to tuplestore */
2039 int readptr; /* index of my tuplestore read pointer */
2040 PlanState *cteplanstate; /* PlanState for the CTE query itself */
2041 /* Link to the "leader" CteScanState (possibly this same node) */
2042 struct CteScanState *leader;
2043 /* The remaining fields are only valid in the "leader" CteScanState */
2044 Tuplestorestate *cte_table; /* rows already read from the CTE query */
2045 bool eof_cte; /* reached end of CTE query? */
2046} CteScanState;
2047
2048/* ----------------
2049 * NamedTuplestoreScanState information
2050 *
2051 * NamedTuplestoreScan nodes are used to scan a Tuplestore created and
2052 * named prior to execution of the query. An example is a transition
2053 * table for an AFTER trigger.
2054 *
2055 * Multiple NamedTuplestoreScan nodes can read out from the same Tuplestore.
2056 * ----------------
2057 */
2058typedef struct NamedTuplestoreScanState
2059{
2060 ScanState ss; /* its first field is NodeTag */
2061 int readptr; /* index of my tuplestore read pointer */
2062 TupleDesc tupdesc; /* format of the tuples in the tuplestore */
2063 Tuplestorestate *relation; /* the rows */
2065
2066/* ----------------
2067 * WorkTableScanState information
2068 *
2069 * WorkTableScan nodes are used to scan the work table created by
2070 * a RecursiveUnion node. We locate the RecursiveUnion node
2071 * during executor startup.
2072 * ----------------
2073 */
2074typedef struct WorkTableScanState
2075{
2076 ScanState ss; /* its first field is NodeTag */
2077 RecursiveUnionState *rustate;
2079
2080/* ----------------
2081 * ForeignScanState information
2082 *
2083 * ForeignScan nodes are used to scan foreign-data tables.
2084 * ----------------
2085 */
2086typedef struct ForeignScanState
2087{
2088 ScanState ss; /* its first field is NodeTag */
2089 ExprState *fdw_recheck_quals; /* original quals not in ss.ps.qual */
2090 Size pscan_len; /* size of parallel coordination information */
2091 ResultRelInfo *resultRelInfo; /* result rel info, if UPDATE or DELETE */
2092 /* use struct pointer to avoid including fdwapi.h here */
2093 struct FdwRoutine *fdwroutine;
2094 void *fdw_state; /* foreign-data wrapper can keep state here */
2096
2097/* ----------------
2098 * CustomScanState information
2099 *
2100 * CustomScan nodes are used to execute custom code within executor.
2101 *
2102 * Core code must avoid assuming that the CustomScanState is only as large as
2103 * the structure declared here; providers are allowed to make it the first
2104 * element in a larger structure, and typically would need to do so. The
2105 * struct is actually allocated by the CreateCustomScanState method associated
2106 * with the plan node. Any additional fields can be initialized there, or in
2107 * the BeginCustomScan method.
2108 * ----------------
2109 */
2110struct CustomExecMethods;
2111
2112typedef struct CustomScanState
2113{
2114 ScanState ss;
2115 uint32 flags; /* mask of CUSTOMPATH_* flags, see
2116 * nodes/extensible.h */
2117 List *custom_ps; /* list of child PlanState nodes, if any */
2118 Size pscan_len; /* size of parallel coordination information */
2119 const struct CustomExecMethods *methods;
2120 const struct TupleTableSlotOps *slotOps;
2122
2123/* ----------------------------------------------------------------
2124 * Join State Information
2125 * ----------------------------------------------------------------
2126 */
2127
2128/* ----------------
2129 * JoinState information
2130 *
2131 * Superclass for state nodes of join plans.
2132 * ----------------
2133 */
2134typedef struct JoinState
2135{
2136 PlanState ps;
2137 JoinType jointype;
2138 bool single_match; /* True if we should skip to next outer tuple
2139 * after finding one inner match */
2140 ExprState *joinqual; /* JOIN quals (in addition to ps.qual) */
2141} JoinState;
2142
2143/* ----------------
2144 * NestLoopState information
2145 *
2146 * NeedNewOuter true if need new outer tuple on next call
2147 * MatchedOuter true if found a join match for current outer tuple
2148 * NullInnerTupleSlot prepared null tuple for left outer joins
2149 * ----------------
2150 */
2151typedef struct NestLoopState
2152{
2153 JoinState js; /* its first field is NodeTag */
2154 bool nl_NeedNewOuter;
2155 bool nl_MatchedOuter;
2156 TupleTableSlot *nl_NullInnerTupleSlot;
2158
2159/* ----------------
2160 * MergeJoinState information
2161 *
2162 * NumClauses number of mergejoinable join clauses
2163 * Clauses info for each mergejoinable clause
2164 * JoinState current state of ExecMergeJoin state machine
2165 * SkipMarkRestore true if we may skip Mark and Restore operations
2166 * ExtraMarks true to issue extra Mark operations on inner scan
2167 * ConstFalseJoin true if we have a constant-false joinqual
2168 * FillOuter true if should emit unjoined outer tuples anyway
2169 * FillInner true if should emit unjoined inner tuples anyway
2170 * MatchedOuter true if found a join match for current outer tuple
2171 * MatchedInner true if found a join match for current inner tuple
2172 * OuterTupleSlot slot in tuple table for cur outer tuple
2173 * InnerTupleSlot slot in tuple table for cur inner tuple
2174 * MarkedTupleSlot slot in tuple table for marked tuple
2175 * NullOuterTupleSlot prepared null tuple for right outer joins
2176 * NullInnerTupleSlot prepared null tuple for left outer joins
2177 * OuterEContext workspace for computing outer tuple's join values
2178 * InnerEContext workspace for computing inner tuple's join values
2179 * ----------------
2180 */
2181/* private in nodeMergejoin.c: */
2182typedef struct MergeJoinClauseData *MergeJoinClause;
2183
2184typedef struct MergeJoinState
2185{
2186 JoinState js; /* its first field is NodeTag */
2187 int mj_NumClauses;
2188 MergeJoinClause mj_Clauses; /* array of length mj_NumClauses */
2189 int mj_JoinState;
2190 bool mj_SkipMarkRestore;
2191 bool mj_ExtraMarks;
2192 bool mj_ConstFalseJoin;
2193 bool mj_FillOuter;
2194 bool mj_FillInner;
2195 bool mj_MatchedOuter;
2196 bool mj_MatchedInner;
2197 TupleTableSlot *mj_OuterTupleSlot;
2198 TupleTableSlot *mj_InnerTupleSlot;
2199 TupleTableSlot *mj_MarkedTupleSlot;
2200 TupleTableSlot *mj_NullOuterTupleSlot;
2201 TupleTableSlot *mj_NullInnerTupleSlot;
2202 ExprContext *mj_OuterEContext;
2203 ExprContext *mj_InnerEContext;
2205
2206/* ----------------
2207 * HashJoinState information
2208 *
2209 * hashclauses original form of the hashjoin condition
2210 * hj_OuterHash ExprState for hashing outer keys
2211 * hj_HashTable hash table for the hashjoin
2212 * (NULL if table not built yet)
2213 * hj_CurHashValue hash value for current outer tuple
2214 * hj_CurBucketNo regular bucket# for current outer tuple
2215 * hj_CurSkewBucketNo skew bucket# for current outer tuple
2216 * hj_CurTuple last inner tuple matched to current outer
2217 * tuple, or NULL if starting search
2218 * (hj_CurXXX variables are undefined if
2219 * OuterTupleSlot is empty!)
2220 * hj_OuterTupleSlot tuple slot for outer tuples
2221 * hj_HashTupleSlot tuple slot for inner (hashed) tuples
2222 * hj_NullOuterTupleSlot prepared null tuple for right/right-anti/full
2223 * outer joins
2224 * hj_NullInnerTupleSlot prepared null tuple for left/full outer joins
2225 * hj_FirstOuterTupleSlot first tuple retrieved from outer plan
2226 * hj_JoinState current state of ExecHashJoin state machine
2227 * hj_MatchedOuter true if found a join match for current outer
2228 * hj_OuterNotEmpty true if outer relation known not empty
2229 * ----------------
2230 */
2231
2232/* these structs are defined in executor/hashjoin.h: */
2233typedef struct HashJoinTupleData *HashJoinTuple;
2234typedef struct HashJoinTableData *HashJoinTable;
2235
2236typedef struct HashJoinState
2237{
2238 JoinState js; /* its first field is NodeTag */
2239 ExprState *hashclauses;
2240 ExprState *hj_OuterHash;
2241 HashJoinTable hj_HashTable;
2242 uint32 hj_CurHashValue;
2243 int hj_CurBucketNo;
2244 int hj_CurSkewBucketNo;
2245 HashJoinTuple hj_CurTuple;
2246 TupleTableSlot *hj_OuterTupleSlot;
2247 TupleTableSlot *hj_HashTupleSlot;
2248 TupleTableSlot *hj_NullOuterTupleSlot;
2249 TupleTableSlot *hj_NullInnerTupleSlot;
2250 TupleTableSlot *hj_FirstOuterTupleSlot;
2251 int hj_JoinState;
2252 bool hj_MatchedOuter;
2253 bool hj_OuterNotEmpty;
2255
2256
2257/* ----------------------------------------------------------------
2258 * Materialization State Information
2259 * ----------------------------------------------------------------
2260 */
2261
2262/* ----------------
2263 * MaterialState information
2264 *
2265 * materialize nodes are used to materialize the results
2266 * of a subplan into a temporary file.
2267 *
2268 * ss.ss_ScanTupleSlot refers to output of underlying plan.
2269 * ----------------
2270 */
2271typedef struct MaterialState
2272{
2273 ScanState ss; /* its first field is NodeTag */
2274 int eflags; /* capability flags to pass to tuplestore */
2275 bool eof_underlying; /* reached end of underlying plan? */
2276 Tuplestorestate *tuplestorestate;
2278
2279struct MemoizeEntry;
2280struct MemoizeTuple;
2281struct MemoizeKey;
2282
2283/* ----------------
2284 * MemoizeState information
2285 *
2286 * memoize nodes are used to cache recent and commonly seen results from
2287 * a parameterized scan.
2288 * ----------------
2289 */
2290typedef struct MemoizeState
2291{
2292 ScanState ss; /* its first field is NodeTag */
2293 int mstatus; /* value of ExecMemoize state machine */
2294 int nkeys; /* number of cache keys */
2295 struct memoize_hash *hashtable; /* hash table for cache entries */
2296 TupleDesc hashkeydesc; /* tuple descriptor for cache keys */
2297 TupleTableSlot *tableslot; /* min tuple slot for existing cache entries */
2298 TupleTableSlot *probeslot; /* virtual slot used for hash lookups */
2299 ExprState *cache_eq_expr; /* Compare exec params to hash key */
2300 ExprState **param_exprs; /* exprs containing the parameters to this
2301 * node */
2302 FmgrInfo *hashfunctions; /* lookup data for hash funcs nkeys in size */
2303 Oid *collations; /* collation for comparisons nkeys in size */
2304 uint64 mem_used; /* bytes of memory used by cache */
2305 uint64 mem_limit; /* memory limit in bytes for the cache */
2306 MemoryContext tableContext; /* memory context to store cache data */
2307 dlist_head lru_list; /* least recently used entry list */
2308 struct MemoizeTuple *last_tuple; /* Used to point to the last tuple
2309 * returned during a cache hit and the
2310 * tuple we last stored when
2311 * populating the cache. */
2312 struct MemoizeEntry *entry; /* the entry that 'last_tuple' belongs to or
2313 * NULL if 'last_tuple' is NULL. */
2314 bool singlerow; /* true if the cache entry is to be marked as
2315 * complete after caching the first tuple. */
2316 bool binary_mode; /* true when cache key should be compared bit
2317 * by bit, false when using hash equality ops */
2318 MemoizeInstrumentation stats; /* execution statistics */
2319 SharedMemoizeInfo *shared_info; /* statistics for parallel workers */
2320 Bitmapset *keyparamids; /* Param->paramids of expressions belonging to
2321 * param_exprs */
2322} MemoizeState;
2323
2324/* ----------------
2325 * When performing sorting by multiple keys, it's possible that the input
2326 * dataset is already sorted on a prefix of those keys. We call these
2327 * "presorted keys".
2328 * PresortedKeyData represents information about one such key.
2329 * ----------------
2330 */
2331typedef struct PresortedKeyData
2332{
2333 FmgrInfo flinfo; /* comparison function info */
2334 FunctionCallInfo fcinfo; /* comparison function call info */
2335 OffsetNumber attno; /* attribute number in tuple */
2337
2338/* ----------------
2339 * SortState information
2340 * ----------------
2341 */
2342typedef struct SortState
2343{
2344 ScanState ss; /* its first field is NodeTag */
2345 bool randomAccess; /* need random access to sort output? */
2346 bool bounded; /* is the result set bounded? */
2347 int64 bound; /* if bounded, how many tuples are needed */
2348 bool sort_Done; /* sort completed yet? */
2349 bool bounded_Done; /* value of bounded we did the sort with */
2350 int64 bound_Done; /* value of bound we did the sort with */
2351 void *tuplesortstate; /* private state of tuplesort.c */
2352 bool am_worker; /* are we a worker? */
2353 bool datumSort; /* Datum sort instead of tuple sort? */
2354 SharedSortInfo *shared_info; /* one entry per worker */
2355} SortState;
2356
2357typedef enum
2358{
2364
2365typedef struct IncrementalSortState
2366{
2367 ScanState ss; /* its first field is NodeTag */
2368 bool bounded; /* is the result set bounded? */
2369 int64 bound; /* if bounded, how many tuples are needed */
2370 bool outerNodeDone; /* finished fetching tuples from outer node */
2371 int64 bound_Done; /* value of bound we did the sort with */
2372 IncrementalSortExecutionStatus execution_status;
2373 int64 n_fullsort_remaining;
2374 Tuplesortstate *fullsort_state; /* private state of tuplesort.c */
2375 Tuplesortstate *prefixsort_state; /* private state of tuplesort.c */
2376 /* the keys by which the input path is already sorted */
2377 PresortedKeyData *presorted_keys;
2378
2379 IncrementalSortInfo incsort_info;
2380
2381 /* slot for pivot tuple defining values of presorted keys within group */
2382 TupleTableSlot *group_pivot;
2383 TupleTableSlot *transfer_tuple;
2384 bool am_worker; /* are we a worker? */
2385 SharedIncrementalSortInfo *shared_info; /* one entry per worker */
2387
2388/* ---------------------
2389 * GroupState information
2390 * ---------------------
2391 */
2392typedef struct GroupState
2393{
2394 ScanState ss; /* its first field is NodeTag */
2395 ExprState *eqfunction; /* equality function */
2396 bool grp_done; /* indicates completion of Group scan */
2397} GroupState;
2398
2399/* ---------------------
2400 * AggState information
2401 *
2402 * ss.ss_ScanTupleSlot refers to output of underlying plan.
2403 *
2404 * Note: ss.ps.ps_ExprContext contains ecxt_aggvalues and
2405 * ecxt_aggnulls arrays, which hold the computed agg values for the current
2406 * input group during evaluation of an Agg node's output tuple(s). We
2407 * create a second ExprContext, tmpcontext, in which to evaluate input
2408 * expressions and run the aggregate transition functions.
2409 * ---------------------
2410 */
2411/* these structs are private in nodeAgg.c: */
2412typedef struct AggStatePerAggData *AggStatePerAgg;
2416typedef struct AggStatePerHashData *AggStatePerHash;
2417
2418typedef struct AggState
2419{
2420 ScanState ss; /* its first field is NodeTag */
2421 List *aggs; /* all Aggref nodes in targetlist & quals */
2422 int numaggs; /* length of list (could be zero!) */
2423 int numtrans; /* number of pertrans items */
2424 AggStrategy aggstrategy; /* strategy mode */
2425 AggSplit aggsplit; /* agg-splitting mode, see nodes.h */
2426 AggStatePerPhase phase; /* pointer to current phase data */
2427 int numphases; /* number of phases (including phase 0) */
2428 int current_phase; /* current phase number */
2429 AggStatePerAgg peragg; /* per-Aggref information */
2430 AggStatePerTrans pertrans; /* per-Trans state information */
2431 ExprContext *hashcontext; /* econtexts for long-lived data (hashtable) */
2432 ExprContext **aggcontexts; /* econtexts for long-lived data (per GS) */
2433 ExprContext *tmpcontext; /* econtext for input expressions */
2434#define FIELDNO_AGGSTATE_CURAGGCONTEXT 14
2435 ExprContext *curaggcontext; /* currently active aggcontext */
2436 AggStatePerAgg curperagg; /* currently active aggregate, if any */
2437#define FIELDNO_AGGSTATE_CURPERTRANS 16
2438 AggStatePerTrans curpertrans; /* currently active trans state, if any */
2439 bool input_done; /* indicates end of input */
2440 bool agg_done; /* indicates completion of Agg scan */
2441 int projected_set; /* The last projected grouping set */
2442#define FIELDNO_AGGSTATE_CURRENT_SET 20
2443 int current_set; /* The current grouping set being evaluated */
2444 Bitmapset *grouped_cols; /* grouped cols in current projection */
2445 List *all_grouped_cols; /* list of all grouped cols in DESC order */
2446 Bitmapset *colnos_needed; /* all columns needed from the outer plan */
2447 int max_colno_needed; /* highest colno needed from outer plan */
2448 bool all_cols_needed; /* are all cols from outer plan needed? */
2449 /* These fields are for grouping set phase data */
2450 int maxsets; /* The max number of sets in any phase */
2451 AggStatePerPhase phases; /* array of all phases */
2452 Tuplesortstate *sort_in; /* sorted input to phases > 1 */
2453 Tuplesortstate *sort_out; /* input is copied here for next phase */
2454 TupleTableSlot *sort_slot; /* slot for sort results */
2455 /* these fields are used in AGG_PLAIN and AGG_SORTED modes: */
2456 AggStatePerGroup *pergroups; /* grouping set indexed array of per-group
2457 * pointers */
2458 HeapTuple grp_firstTuple; /* copy of first tuple of current group */
2459 /* these fields are used in AGG_HASHED and AGG_MIXED modes: */
2460 bool table_filled; /* hash table filled yet? */
2461 int num_hashes;
2462 MemoryContext hash_metacxt; /* memory for hash table bucket array */
2463 MemoryContext hash_tuplescxt; /* memory for hash table tuples */
2464 struct LogicalTapeSet *hash_tapeset; /* tape set for hash spill tapes */
2465 struct HashAggSpill *hash_spills; /* HashAggSpill for each grouping set,
2466 * exists only during first pass */
2467 TupleTableSlot *hash_spill_rslot; /* for reading spill files */
2468 TupleTableSlot *hash_spill_wslot; /* for writing spill files */
2469 List *hash_batches; /* hash batches remaining to be processed */
2470 bool hash_ever_spilled; /* ever spilled during this execution? */
2471 bool hash_spill_mode; /* we hit a limit during the current batch
2472 * and we must not create new groups */
2473 Size hash_mem_limit; /* limit before spilling hash table */
2474 uint64 hash_ngroups_limit; /* limit before spilling hash table */
2475 int hash_planned_partitions; /* number of partitions planned
2476 * for first pass */
2477 double hashentrysize; /* estimate revised during execution */
2478 Size hash_mem_peak; /* peak hash table memory usage */
2479 uint64 hash_ngroups_current; /* number of groups currently in
2480 * memory in all hash tables */
2481 uint64 hash_disk_used; /* kB of disk space used */
2482 int hash_batches_used; /* batches used during entire execution */
2483
2484 AggStatePerHash perhash; /* array of per-hashtable data */
2485 AggStatePerGroup *hash_pergroup; /* grouping set indexed array of
2486 * per-group pointers */
2487
2488 /* support for evaluation of agg input expressions: */
2489#define FIELDNO_AGGSTATE_ALL_PERGROUPS 54
2490 AggStatePerGroup *all_pergroups; /* array of first ->pergroups, than
2491 * ->hash_pergroup */
2492 SharedAggInfo *shared_info; /* one entry per worker */
2493} AggState;
2494
2495/* ----------------
2496 * WindowAggState information
2497 * ----------------
2498 */
2499/* these structs are private in nodeWindowAgg.c: */
2502
2503/*
2504 * WindowAggStatus -- Used to track the status of WindowAggState
2505 */
2506typedef enum WindowAggStatus
2507{
2508 WINDOWAGG_DONE, /* No more processing to do */
2509 WINDOWAGG_RUN, /* Normal processing of window funcs */
2510 WINDOWAGG_PASSTHROUGH, /* Don't eval window funcs */
2511 WINDOWAGG_PASSTHROUGH_STRICT, /* Pass-through plus don't store new
2512 * tuples during spool */
2514
2515typedef struct WindowAggState
2516{
2517 ScanState ss; /* its first field is NodeTag */
2518
2519 /* these fields are filled in by ExecInitExpr: */
2520 List *funcs; /* all WindowFunc nodes in targetlist */
2521 int numfuncs; /* total number of window functions */
2522 int numaggs; /* number that are plain aggregates */
2523
2524 WindowStatePerFunc perfunc; /* per-window-function information */
2525 WindowStatePerAgg peragg; /* per-plain-aggregate information */
2526 ExprState *partEqfunction; /* equality funcs for partition columns */
2527 ExprState *ordEqfunction; /* equality funcs for ordering columns */
2528 Tuplestorestate *buffer; /* stores rows of current partition */
2529 int current_ptr; /* read pointer # for current row */
2530 int framehead_ptr; /* read pointer # for frame head, if used */
2531 int frametail_ptr; /* read pointer # for frame tail, if used */
2532 int grouptail_ptr; /* read pointer # for group tail, if used */
2533 int64 spooled_rows; /* total # of rows in buffer */
2534 int64 currentpos; /* position of current row in partition */
2535 int64 frameheadpos; /* current frame head position */
2536 int64 frametailpos; /* current frame tail position (frame end+1) */
2537 /* use struct pointer to avoid including windowapi.h here */
2538 struct WindowObjectData *agg_winobj; /* winobj for aggregate fetches */
2539 int64 aggregatedbase; /* start row for current aggregates */
2540 int64 aggregatedupto; /* rows before this one are aggregated */
2541 WindowAggStatus status; /* run status of WindowAggState */
2542
2543 int frameOptions; /* frame_clause options, see WindowDef */
2544 ExprState *startOffset; /* expression for starting bound offset */
2545 ExprState *endOffset; /* expression for ending bound offset */
2546 Datum startOffsetValue; /* result of startOffset evaluation */
2547 Datum endOffsetValue; /* result of endOffset evaluation */
2548
2549 /* these fields are used with RANGE offset PRECEDING/FOLLOWING: */
2550 FmgrInfo startInRangeFunc; /* in_range function for startOffset */
2551 FmgrInfo endInRangeFunc; /* in_range function for endOffset */
2552 Oid inRangeColl; /* collation for in_range tests */
2553 bool inRangeAsc; /* use ASC sort order for in_range tests? */
2554 bool inRangeNullsFirst; /* nulls sort first for in_range tests? */
2555
2556 /* fields relating to runconditions */
2557 bool use_pass_through; /* When false, stop execution when
2558 * runcondition is no longer true. Else
2559 * just stop evaluating window funcs. */
2560 bool top_window; /* true if this is the top-most WindowAgg or
2561 * the only WindowAgg in this query level */
2562 ExprState *runcondition; /* Condition which must remain true otherwise
2563 * execution of the WindowAgg will finish or
2564 * go into pass-through mode. NULL when there
2565 * is no such condition. */
2566
2567 /* these fields are used in GROUPS mode: */
2568 int64 currentgroup; /* peer group # of current row in partition */
2569 int64 frameheadgroup; /* peer group # of frame head row */
2570 int64 frametailgroup; /* peer group # of frame tail row */
2571 int64 groupheadpos; /* current row's peer group head position */
2572 int64 grouptailpos; /* " " " " tail position (group end+1) */
2573
2574 MemoryContext partcontext; /* context for partition-lifespan data */
2575 MemoryContext aggcontext; /* shared context for aggregate working data */
2576 MemoryContext curaggcontext; /* current aggregate's working data */
2577 ExprContext *tmpcontext; /* short-term evaluation context */
2578
2579 bool all_first; /* true if the scan is starting */
2580 bool partition_spooled; /* true if all tuples in current partition
2581 * have been spooled into tuplestore */
2582 bool next_partition; /* true if begin_partition needs to be called */
2583 bool more_partitions; /* true if there's more partitions after
2584 * this one */
2585 bool framehead_valid; /* true if frameheadpos is known up to
2586 * date for current row */
2587 bool frametail_valid; /* true if frametailpos is known up to
2588 * date for current row */
2589 bool grouptail_valid; /* true if grouptailpos is known up to
2590 * date for current row */
2591
2592 TupleTableSlot *first_part_slot; /* first tuple of current or next
2593 * partition */
2594 TupleTableSlot *framehead_slot; /* first tuple of current frame */
2595 TupleTableSlot *frametail_slot; /* first tuple after current frame */
2596
2597 /* temporary slots for tuples fetched back from tuplestore */
2598 TupleTableSlot *agg_row_slot;
2599 TupleTableSlot *temp_slot_1;
2600 TupleTableSlot *temp_slot_2;
2602
2603/* ----------------
2604 * UniqueState information
2605 *
2606 * Unique nodes are used "on top of" sort nodes to discard
2607 * duplicate tuples returned from the sort phase. Basically
2608 * all it does is compare the current tuple from the subplan
2609 * with the previously fetched tuple (stored in its result slot).
2610 * If the two are identical in all interesting fields, then
2611 * we just fetch another tuple from the sort and try again.
2612 * ----------------
2613 */
2614typedef struct UniqueState
2615{
2616 PlanState ps; /* its first field is NodeTag */
2617 ExprState *eqfunction; /* tuple equality qual */
2618} UniqueState;
2619
2620/* ----------------
2621 * GatherState information
2622 *
2623 * Gather nodes launch 1 or more parallel workers, run a subplan
2624 * in those workers, and collect the results.
2625 * ----------------
2626 */
2627typedef struct GatherState
2628{
2629 PlanState ps; /* its first field is NodeTag */
2630 bool initialized; /* workers launched? */
2631 bool need_to_scan_locally; /* need to read from local plan? */
2632 int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */
2633 /* these fields are set up once: */
2634 TupleTableSlot *funnel_slot;
2635 struct ParallelExecutorInfo *pei;
2636 /* all remaining fields are reinitialized during a rescan: */
2637 int nworkers_launched; /* original number of workers */
2638 int nreaders; /* number of still-active workers */
2639 int nextreader; /* next one to try to read from */
2640 struct TupleQueueReader **reader; /* array with nreaders active entries */
2641} GatherState;
2642
2643/* ----------------
2644 * GatherMergeState information
2645 *
2646 * Gather merge nodes launch 1 or more parallel workers, run a
2647 * subplan which produces sorted output in each worker, and then
2648 * merge the results into a single sorted stream.
2649 * ----------------
2650 */
2651struct GMReaderTupleBuffer; /* private in nodeGatherMerge.c */
2652
2653typedef struct GatherMergeState
2654{
2655 PlanState ps; /* its first field is NodeTag */
2656 bool initialized; /* workers launched? */
2657 bool gm_initialized; /* gather_merge_init() done? */
2658 bool need_to_scan_locally; /* need to read from local plan? */
2659 int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */
2660 /* these fields are set up once: */
2661 TupleDesc tupDesc; /* descriptor for subplan result tuples */
2662 int gm_nkeys; /* number of sort columns */
2663 SortSupport gm_sortkeys; /* array of length gm_nkeys */
2664 struct ParallelExecutorInfo *pei;
2665 /* all remaining fields are reinitialized during a rescan */
2666 /* (but the arrays are not reallocated, just cleared) */
2667 int nworkers_launched; /* original number of workers */
2668 int nreaders; /* number of active workers */
2669 TupleTableSlot **gm_slots; /* array with nreaders+1 entries */
2670 struct TupleQueueReader **reader; /* array with nreaders active entries */
2671 struct GMReaderTupleBuffer *gm_tuple_buffers; /* nreaders tuple buffers */
2672 struct binaryheap *gm_heap; /* binary heap of slot indices */
2674
2675/* ----------------
2676 * HashState information
2677 * ----------------
2678 */
2679typedef struct HashState
2680{
2681 PlanState ps; /* its first field is NodeTag */
2682 HashJoinTable hashtable; /* hash table for the hashjoin */
2683 ExprState *hash_expr; /* ExprState to get hash value */
2684
2685 FmgrInfo *skew_hashfunction; /* lookup data for skew hash function */
2686 Oid skew_collation; /* collation to call skew_hashfunction with */
2687
2688 /*
2689 * In a parallelized hash join, the leader retains a pointer to the
2690 * shared-memory stats area in its shared_info field, and then copies the
2691 * shared-memory info back to local storage before DSM shutdown. The
2692 * shared_info field remains NULL in workers, or in non-parallel joins.
2693 */
2694 SharedHashInfo *shared_info;
2695
2696 /*
2697 * If we are collecting hash stats, this points to an initially-zeroed
2698 * collection area, which could be either local storage or in shared
2699 * memory; either way it's for just one process.
2700 */
2701 HashInstrumentation *hinstrument;
2702
2703 /* Parallel hash state. */
2704 struct ParallelHashJoinState *parallel_state;
2705} HashState;
2706
2707/* ----------------
2708 * SetOpState information
2709 *
2710 * SetOp nodes support either sorted or hashed de-duplication.
2711 * The sorted mode is a bit like MergeJoin, the hashed mode like Agg.
2712 * ----------------
2713 */
2714typedef struct SetOpStatePerInput
2715{
2716 TupleTableSlot *firstTupleSlot; /* first tuple of current group */
2717 int64 numTuples; /* number of tuples in current group */
2718 TupleTableSlot *nextTupleSlot; /* next input tuple, if already read */
2719 bool needGroup; /* do we need to load a new group? */
2721
2722typedef struct SetOpState
2723{
2724 PlanState ps; /* its first field is NodeTag */
2725 bool setop_done; /* indicates completion of output scan */
2726 int64 numOutput; /* number of dups left to output */
2727 int numCols; /* number of grouping columns */
2728
2729 /* these fields are used in SETOP_SORTED mode: */
2730 SortSupport sortKeys; /* per-grouping-field sort data */
2731 SetOpStatePerInput leftInput; /* current outer-relation input state */
2732 SetOpStatePerInput rightInput; /* current inner-relation input state */
2733 bool need_init; /* have we read the first tuples yet? */
2734
2735 /* these fields are used in SETOP_HASHED mode: */
2736 Oid *eqfuncoids; /* per-grouping-field equality fns */
2737 FmgrInfo *hashfunctions; /* per-grouping-field hash fns */
2738 TupleHashTable hashtable; /* hash table with one entry per group */
2739 MemoryContext tuplesContext; /* context containing hash table's tuples */
2740 bool table_filled; /* hash table filled yet? */
2741 TupleHashIterator hashiter; /* for iterating through hash table */
2742} SetOpState;
2743
2744/* ----------------
2745 * LockRowsState information
2746 *
2747 * LockRows nodes are used to enforce FOR [KEY] UPDATE/SHARE locking.
2748 * ----------------
2749 */
2750typedef struct LockRowsState
2751{
2752 PlanState ps; /* its first field is NodeTag */
2753 List *lr_arowMarks; /* List of ExecAuxRowMarks */
2754 EPQState lr_epqstate; /* for evaluating EvalPlanQual rechecks */
2756
2757/* ----------------
2758 * LimitState information
2759 *
2760 * Limit nodes are used to enforce LIMIT/OFFSET clauses.
2761 * They just select the desired subrange of their subplan's output.
2762 *
2763 * offset is the number of initial tuples to skip (0 does nothing).
2764 * count is the number of tuples to return after skipping the offset tuples.
2765 * If no limit count was specified, count is undefined and noCount is true.
2766 * When lstate == LIMIT_INITIAL, offset/count/noCount haven't been set yet.
2767 * ----------------
2768 */
2769typedef enum
2770{
2771 LIMIT_INITIAL, /* initial state for LIMIT node */
2772 LIMIT_RESCAN, /* rescan after recomputing parameters */
2773 LIMIT_EMPTY, /* there are no returnable rows */
2774 LIMIT_INWINDOW, /* have returned a row in the window */
2775 LIMIT_WINDOWEND_TIES, /* have returned a tied row */
2776 LIMIT_SUBPLANEOF, /* at EOF of subplan (within window) */
2777 LIMIT_WINDOWEND, /* stepped off end of window */
2778 LIMIT_WINDOWSTART, /* stepped off beginning of window */
2780
2781typedef struct LimitState
2782{
2783 PlanState ps; /* its first field is NodeTag */
2784 ExprState *limitOffset; /* OFFSET parameter, or NULL if none */
2785 ExprState *limitCount; /* COUNT parameter, or NULL if none */
2786 LimitOption limitOption; /* limit specification type */
2787 int64 offset; /* current OFFSET value */
2788 int64 count; /* current COUNT, if any */
2789 bool noCount; /* if true, ignore count */
2790 LimitStateCond lstate; /* state machine status, as above */
2791 int64 position; /* 1-based index of last tuple returned */
2792 TupleTableSlot *subSlot; /* tuple last obtained from subplan */
2793 ExprState *eqfunction; /* tuple equality qual in case of WITH TIES
2794 * option */
2795 TupleTableSlot *last_slot; /* slot for evaluation of ties */
2796} LimitState;
2797
2798#endif /* EXECNODES_H */
int16 AttrNumber
Definition attnum.h:21
int Buffer
Definition buf.h:23
int64_t int64
Definition c.h:543
int16_t int16
Definition c.h:541
uint64_t uint64
Definition c.h:547
uint32_t uint32
Definition c.h:546
size_t Size
Definition c.h:619
uint64 dsa_pointer
Definition dsa.h:62
struct WindowStatePerAggData * WindowStatePerAgg
Definition execnodes.h:2501
IncrementalSortExecutionStatus
Definition execnodes.h:2358
@ INCSORT_READFULLSORT
Definition execnodes.h:2361
@ INCSORT_LOADPREFIXSORT
Definition execnodes.h:2360
@ INCSORT_READPREFIXSORT
Definition execnodes.h:2362
@ INCSORT_LOADFULLSORT
Definition execnodes.h:2359
WindowAggStatus
Definition execnodes.h:2507
@ WINDOWAGG_PASSTHROUGH
Definition execnodes.h:2510
@ WINDOWAGG_RUN
Definition execnodes.h:2509
@ WINDOWAGG_DONE
Definition execnodes.h:2508
@ WINDOWAGG_PASSTHROUGH_STRICT
Definition execnodes.h:2511
struct HashJoinTableData * HashJoinTable
Definition execnodes.h:2234
struct HashJoinTupleData * HashJoinTuple
Definition execnodes.h:2233
SharedBitmapState
Definition execnodes.h:1835
@ BM_INITIAL
Definition execnodes.h:1836
@ BM_FINISHED
Definition execnodes.h:1838
@ BM_INPROGRESS
Definition execnodes.h:1837
struct WindowStatePerFuncData * WindowStatePerFunc
Definition execnodes.h:2500
struct AggStatePerHashData * AggStatePerHash
Definition execnodes.h:2416
LimitStateCond
Definition execnodes.h:2770
@ LIMIT_WINDOWEND_TIES
Definition execnodes.h:2775
@ LIMIT_WINDOWEND
Definition execnodes.h:2777
@ LIMIT_INWINDOW
Definition execnodes.h:2774
@ LIMIT_SUBPLANEOF
Definition execnodes.h:2776
@ LIMIT_WINDOWSTART
Definition execnodes.h:2778
@ LIMIT_EMPTY
Definition execnodes.h:2773
@ LIMIT_INITIAL
Definition execnodes.h:2771
@ LIMIT_RESCAN
Definition execnodes.h:2772
struct MergeJoinClauseData * MergeJoinClause
Definition execnodes.h:2182
ExprDoneCond
Definition execnodes.h:328
struct AggStatePerGroupData * AggStatePerGroup
Definition execnodes.h:2414
struct AggStatePerPhaseData * AggStatePerPhase
Definition execnodes.h:2415
struct AggStatePerTransData * AggStatePerTrans
Definition execnodes.h:2413
DomainConstraintType
Definition execnodes.h:1050
@ DOM_CONSTRAINT_CHECK
Definition execnodes.h:1052
@ DOM_CONSTRAINT_NOTNULL
Definition execnodes.h:1051
tuplehash_iterator TupleHashIterator
Definition execnodes.h:889
struct AggStatePerAggData * AggStatePerAgg
Definition execnodes.h:2412
TupleTableSlot *(* ExecProcNodeMtd)(PlanState *pstate)
Definition execnodes.h:1152
struct parser_state ps
static void fireBSTriggers(ModifyTableState *node)
#define pg_node_attr(...)
Definition nodes.h:126
CmdType
Definition nodes.h:273
AggStrategy
Definition nodes.h:363
NodeTag
Definition nodes.h:27
AggSplit
Definition nodes.h:385
LimitOption
Definition nodes.h:440
JoinType
Definition nodes.h:298
uint16 OffsetNumber
Definition off.h:24
#define plan(x)
Definition pg_regress.c:161
uint64_t Datum
Definition postgres.h:70
unsigned int Oid
static int fb(int x)
DomainConstraintType constrainttype
Definition execnodes.h:1058
ExprState * check_exprstate
Definition execnodes.h:1061
int jump_eval_coercion
Definition execnodes.h:1109
NullableDatum empty
Definition execnodes.h:1095
FunctionCallInfo input_fcinfo
Definition execnodes.h:1123
JsonExpr * jsexpr
Definition execnodes.h:1073
NullableDatum error
Definition execnodes.h:1092
NullableDatum pathspec
Definition execnodes.h:1079
ErrorSaveContext escontext
Definition execnodes.h:1132
NullableDatum formatted_expr
Definition execnodes.h:1076
Definition pg_list.h:54
Definition nodes.h:135
bool inneropsset
Definition execnodes.h:1251
const TupleTableSlotOps * resultops
Definition execnodes.h:1244
bool outeropsset
Definition execnodes.h:1250
struct SharedJitInstrumentation * worker_jit_instrument
Definition execnodes.h:1181
Instrumentation * instrument
Definition execnodes.h:1177
ExecProcNodeMtd ExecProcNodeReal
Definition execnodes.h:1174
const TupleTableSlotOps * outerops
Definition execnodes.h:1242
const TupleTableSlotOps * innerops
Definition execnodes.h:1243
bool resultopsset
Definition execnodes.h:1252
ExprState * qual
Definition execnodes.h:1188
const TupleTableSlotOps * scanops
Definition execnodes.h:1241
Plan * plan
Definition execnodes.h:1167
PlanState * righttree
Definition execnodes.h:1190
bool outeropsfixed
Definition execnodes.h:1246
List * subPlan
Definition execnodes.h:1194
TupleDesc ps_ResultTupleDesc
Definition execnodes.h:1204
WorkerInstrumentation * worker_instrument
Definition execnodes.h:1178
List * initPlan
Definition execnodes.h:1192
Bitmapset * chgParam
Definition execnodes.h:1199
bool scanopsset
Definition execnodes.h:1249
PlanState * lefttree
Definition execnodes.h:1189
ExprContext * ps_ExprContext
Definition execnodes.h:1206
TupleTableSlot * ps_ResultTupleSlot
Definition execnodes.h:1205
TupleDesc scandesc
Definition execnodes.h:1216
ProjectionInfo * ps_ProjInfo
Definition execnodes.h:1207
bool scanopsfixed
Definition execnodes.h:1245
bool async_capable
Definition execnodes.h:1209
bool resultopsfixed
Definition execnodes.h:1248
bool inneropsfixed
Definition execnodes.h:1247
ExecProcNodeMtd ExecProcNode
Definition execnodes.h:1173
Expr * expr
Definition execnodes.h:944
FunctionCallInfo fcinfo
Definition execnodes.h:1004
TupleTableSlot * funcResultSlot
Definition execnodes.h:967
Tuplestorestate * funcResultStore
Definition execnodes.h:966
bool funcReturnsSet
Definition execnodes.h:980
bool shutdown_reg
Definition execnodes.h:997
bool funcReturnsTuple
Definition execnodes.h:974
ExprState * elidedFuncState
Definition execnodes.h:952
TupleDesc funcResultDesc
Definition execnodes.h:973
FmgrInfo func
Definition execnodes.h:959
List * args
Definition execnodes.h:945
NodeTag type
Definition execnodes.h:943
bool setArgsValid
Definition execnodes.h:989
TupleHashTable hashtable
Definition execnodes.h:1024
ExprState * lhs_hash_expr
Definition execnodes.h:1037
PlanState * parent
Definition execnodes.h:1016
ExprState * cur_eq_comp
Definition execnodes.h:1039
Oid * tab_eq_funcoids
Definition execnodes.h:1033
NodeTag type
Definition execnodes.h:1013
ExprContext * innerecontext
Definition execnodes.h:1029
FmgrInfo * tab_hash_funcs
Definition execnodes.h:1036
FmgrInfo * cur_eq_funcs
Definition execnodes.h:1038
PlanState * planstate
Definition execnodes.h:1015
HeapTuple curTuple
Definition execnodes.h:1018
AttrNumber * keyColIdx
Definition execnodes.h:1032
TupleDesc descRight
Definition execnodes.h:1021
SubPlan * subplan
Definition execnodes.h:1014
ProjectionInfo * projLeft
Definition execnodes.h:1022
ProjectionInfo * projRight
Definition execnodes.h:1023
bool havenullrows
Definition execnodes.h:1027
ExprState * testexpr
Definition execnodes.h:1017
MemoryContext tuplesContext
Definition execnodes.h:1028
Oid * tab_collations
Definition execnodes.h:1035
TupleHashTable hashnulls
Definition execnodes.h:1025
bool havehashrows
Definition execnodes.h:1026
const char * type
static bool initialized
Definition win32ntdll.c:36

◆ innerPlanState

#define innerPlanState (   node)    (((PlanState *)(node))->righttree)

Definition at line 1262 of file execnodes.h.

◆ InstrCountFiltered1

#define InstrCountFiltered1 (   node,
  delta 
)
Value:
do { \
if (((PlanState *)(node))->instrument) \
((PlanState *)(node))->instrument->nfiltered1 += (delta); \
} while(0)

Definition at line 1271 of file execnodes.h.

1272 { \
1273 if (((PlanState *)(node))->instrument) \
1274 ((PlanState *)(node))->instrument->nfiltered1 += (delta); \
1275 } while(0)

◆ InstrCountFiltered2

#define InstrCountFiltered2 (   node,
  delta 
)
Value:
do { \
if (((PlanState *)(node))->instrument) \
((PlanState *)(node))->instrument->nfiltered2 += (delta); \
} while(0)

Definition at line 1276 of file execnodes.h.

1277 { \
1278 if (((PlanState *)(node))->instrument) \
1279 ((PlanState *)(node))->instrument->nfiltered2 += (delta); \
1280 } while(0)

◆ InstrCountTuples2

#define InstrCountTuples2 (   node,
  delta 
)
Value:
do { \
if (((PlanState *)(node))->instrument) \
((PlanState *)(node))->instrument->ntuples2 += (delta); \
} while (0)

Definition at line 1266 of file execnodes.h.

1267 { \
1268 if (((PlanState *)(node))->instrument) \
1269 ((PlanState *)(node))->instrument->ntuples2 += (delta); \
1270 } while (0)

◆ MERGE_DELETE

#define MERGE_DELETE   0x04

Definition at line 1397 of file execnodes.h.

◆ MERGE_INSERT

#define MERGE_INSERT   0x01

Definition at line 1395 of file execnodes.h.

◆ MERGE_UPDATE

#define MERGE_UPDATE   0x02

Definition at line 1396 of file execnodes.h.

◆ outerPlanState

#define outerPlanState (   node)    (((PlanState *)(node))->lefttree)

Definition at line 1263 of file execnodes.h.

◆ ResetTupleHashIterator

#define ResetTupleHashIterator (   htable,
  iter 
)     InitTupleHashIterator(htable, iter)

Definition at line 900 of file execnodes.h.

◆ ScanTupleHashTable

#define ScanTupleHashTable (   htable,
  iter 
)     tuplehash_iterate(htable->hashtab, iter)

Definition at line 902 of file execnodes.h.

◆ SH_DECLARE

#define SH_DECLARE

Definition at line 867 of file execnodes.h.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   TupleHashEntryData

Definition at line 864 of file execnodes.h.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   MinimalTuple

Definition at line 865 of file execnodes.h.

◆ SH_PREFIX

#define SH_PREFIX   tuplehash

Definition at line 863 of file execnodes.h.

◆ SH_SCOPE

#define SH_SCOPE   extern

Definition at line 866 of file execnodes.h.

◆ TermTupleHashIterator

#define TermTupleHashIterator (   iter)     ((void) 0)

Definition at line 898 of file execnodes.h.

Typedef Documentation

◆ AggState

◆ AggStatePerAgg

◆ AggStatePerGroup

◆ AggStatePerHash

◆ AggStatePerPhase

◆ AggStatePerTrans

◆ AppendState

Definition at line 1491 of file execnodes.h.

◆ AsyncRequest

◆ BitmapAndState

◆ BitmapHeapScanState

◆ BitmapIndexScanState

◆ BitmapOrState

◆ CteScanState

◆ CustomScanState

◆ DomainConstraintState

◆ DomainConstraintType

◆ EPQState

◆ EState

◆ ExecAuxRowMark

◆ ExecProcNodeMtd

typedef TupleTableSlot *(* ExecProcNodeMtd) (PlanState *pstate)

Definition at line 1152 of file execnodes.h.

◆ ExecRowMark

Definition at line 58 of file execnodes.h.

◆ ExprContext

Definition at line 60 of file execnodes.h.

◆ ExprContext_CB

◆ ExprContextCallbackFunction

typedef void(* ExprContextCallbackFunction) (Datum arg)

Definition at line 237 of file execnodes.h.

◆ ExprState

Definition at line 59 of file execnodes.h.

◆ ExprStateEvalFunc

typedef Datum(* ExprStateEvalFunc) (ExprState *expression, ExprContext *econtext, bool *isNull)

Definition at line 70 of file execnodes.h.

◆ ForeignScanState

◆ FunctionScanState

◆ GatherMergeState

◆ GatherState

◆ GroupState

◆ HashJoinState

◆ HashJoinTable

◆ HashJoinTuple

◆ HashState

◆ IncrementalSortState

◆ IndexInfo

◆ IndexOnlyScanState

◆ IndexScanState

◆ JoinState

◆ JsonExprState

◆ JunkFilter

◆ LimitState

◆ LockRowsState

◆ MaterialState

◆ MemoizeState

◆ MergeActionState

◆ MergeAppendState

◆ MergeJoinClause

◆ MergeJoinState

◆ ModifyTableState

◆ NamedTuplestoreScanState

◆ NestLoopState

◆ OnConflictSetState

◆ ParallelAppendState

◆ ParallelBitmapHeapState

◆ PlanState

Definition at line 57 of file execnodes.h.

◆ PresortedKeyData

◆ ProjectionInfo

◆ ProjectSetState

◆ RecursiveUnionState

◆ ResultRelInfo

◆ ResultState

◆ ReturnSetInfo

◆ SampleScanState

◆ ScanState

◆ SeqScanState

◆ SetExprState

◆ SetOpState

◆ SetOpStatePerInput

◆ SortState

◆ SubPlanState

◆ SubqueryScanState

◆ TableFuncScanState

◆ TidRangeScanState

◆ TidScanState

◆ TupleHashEntry

◆ TupleHashEntryData

◆ TupleHashIterator

◆ TupleHashTable

◆ TupleHashTableData

◆ UniqueState

◆ ValuesScanState

◆ WindowAggState

◆ WindowAggStatus

◆ WindowFuncExprState

◆ WindowStatePerAgg

◆ WindowStatePerFunc

◆ WorkTableScanState

Enumeration Type Documentation

◆ DomainConstraintType

Enumerator
DOM_CONSTRAINT_NOTNULL 
DOM_CONSTRAINT_CHECK 

Definition at line 1049 of file execnodes.h.

◆ ExprDoneCond

Enumerator
ExprSingleResult 
ExprMultipleResult 
ExprEndResult 

Definition at line 327 of file execnodes.h.

328{
329 ExprSingleResult, /* expression does not return a set */
330 ExprMultipleResult, /* this result is an element of a set */
331 ExprEndResult, /* there are no more elements in the set */
@ ExprSingleResult
Definition execnodes.h:329
@ ExprMultipleResult
Definition execnodes.h:330
@ ExprEndResult
Definition execnodes.h:331

◆ IncrementalSortExecutionStatus

Enumerator
INCSORT_LOADFULLSORT 
INCSORT_LOADPREFIXSORT 
INCSORT_READFULLSORT 
INCSORT_READPREFIXSORT 

Definition at line 2357 of file execnodes.h.

◆ LimitStateCond

Enumerator
LIMIT_INITIAL 
LIMIT_RESCAN 
LIMIT_EMPTY 
LIMIT_INWINDOW 
LIMIT_WINDOWEND_TIES 
LIMIT_SUBPLANEOF 
LIMIT_WINDOWEND 
LIMIT_WINDOWSTART 

Definition at line 2769 of file execnodes.h.

2770{
2771 LIMIT_INITIAL, /* initial state for LIMIT node */
2772 LIMIT_RESCAN, /* rescan after recomputing parameters */
2773 LIMIT_EMPTY, /* there are no returnable rows */
2774 LIMIT_INWINDOW, /* have returned a row in the window */
2775 LIMIT_WINDOWEND_TIES, /* have returned a tied row */
2776 LIMIT_SUBPLANEOF, /* at EOF of subplan (within window) */
2777 LIMIT_WINDOWEND, /* stepped off end of window */
2778 LIMIT_WINDOWSTART, /* stepped off beginning of window */

◆ SetFunctionReturnMode

Enumerator
SFRM_ValuePerCall 
SFRM_Materialize 
SFRM_Materialize_Random 
SFRM_Materialize_Preferred 

Definition at line 340 of file execnodes.h.

341{
342 SFRM_ValuePerCall = 0x01, /* one value returned per call */
343 SFRM_Materialize = 0x02, /* result set instantiated in Tuplestore */
344 SFRM_Materialize_Random = 0x04, /* Tuplestore needs randomAccess */
345 SFRM_Materialize_Preferred = 0x08, /* caller prefers Tuplestore */
SetFunctionReturnMode
Definition execnodes.h:341
@ SFRM_Materialize_Preferred
Definition execnodes.h:345
@ SFRM_ValuePerCall
Definition execnodes.h:342
@ SFRM_Materialize_Random
Definition execnodes.h:344
@ SFRM_Materialize
Definition execnodes.h:343

◆ SharedBitmapState

Enumerator
BM_INITIAL 
BM_INPROGRESS 
BM_FINISHED 

Definition at line 1834 of file execnodes.h.

1835{
1836 BM_INITIAL,

◆ WindowAggStatus

Enumerator
WINDOWAGG_DONE 
WINDOWAGG_RUN 
WINDOWAGG_PASSTHROUGH 
WINDOWAGG_PASSTHROUGH_STRICT 

Definition at line 2506 of file execnodes.h.

2507{
2508 WINDOWAGG_DONE, /* No more processing to do */
2509 WINDOWAGG_RUN, /* Normal processing of window funcs */
2510 WINDOWAGG_PASSTHROUGH, /* Don't eval window funcs */
2511 WINDOWAGG_PASSTHROUGH_STRICT, /* Pass-through plus don't store new
2512 * tuples during spool */