PostgreSQL Source Code git master
Loading...
Searching...
No Matches
execnodes.h File Reference
#include "access/htup.h"
#include "executor/instrument_node.h"
#include "fmgr.h"
#include "lib/ilist.h"
#include "nodes/miscnodes.h"
#include "nodes/params.h"
#include "nodes/plannodes.h"
#include "partitioning/partdefs.h"
#include "storage/buf.h"
#include "utils/reltrigger.h"
#include "utils/typcache.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  OnConflictActionState
 
struct  MergeActionState
 
struct  ForPortionOfState
 
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  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 BufferUsage BufferUsage
 
typedef struct ExecRowMark ExecRowMark
 
typedef struct ExprState ExprState
 
typedef struct ExprContext ExprContext
 
typedef struct HTAB HTAB
 
typedef struct Instrumentation Instrumentation
 
typedef struct pairingheap pairingheap
 
typedef struct PlanState PlanState
 
typedef struct QueryEnvironment QueryEnvironment
 
typedef struct RelationDataRelation
 
typedef RelationRelationPtr
 
typedef struct ScanKeyData ScanKeyData
 
typedef struct SnapshotDataSnapshot
 
typedef struct SortSupportDataSortSupport
 
typedef struct TIDBitmap TIDBitmap
 
typedef struct NodeInstrumentation NodeInstrumentation
 
typedef struct TriggerInstrumentation TriggerInstrumentation
 
typedef struct TupleConversionMap TupleConversionMap
 
typedef struct TupleDescDataTupleDesc
 
typedef struct Tuplesortstate Tuplesortstate
 
typedef struct Tuplestorestate Tuplestorestate
 
typedef struct TupleTableSlot TupleTableSlot
 
typedef struct TupleTableSlotOps TupleTableSlotOps
 
typedef struct WalUsage WalUsage
 
typedef struct WorkerNodeInstrumentation WorkerNodeInstrumentation
 
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 OnConflictActionState OnConflictActionState
 
typedef struct MergeActionState MergeActionState
 
typedef struct ForPortionOfState ForPortionOfState
 
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  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 92 of file execnodes.h.

◆ EEO_FLAG_HAS_OLD

#define EEO_FLAG_HAS_OLD   (1 << 1)

Definition at line 90 of file execnodes.h.

◆ EEO_FLAG_IS_QUAL

#define EEO_FLAG_IS_QUAL   (1 << 0)

Definition at line 88 of file execnodes.h.

◆ EEO_FLAG_NEW_IS_NULL

#define EEO_FLAG_NEW_IS_NULL   (1 << 4)

Definition at line 96 of file execnodes.h.

◆ EEO_FLAG_OLD_IS_NULL

#define EEO_FLAG_OLD_IS_NULL   (1 << 3)

Definition at line 94 of file execnodes.h.

◆ FIELDNO_AGGSTATE_ALL_PERGROUPS

#define FIELDNO_AGGSTATE_ALL_PERGROUPS   54

Definition at line 2502 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURAGGCONTEXT

#define FIELDNO_AGGSTATE_CURAGGCONTEXT   14

Definition at line 2447 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURPERTRANS

#define FIELDNO_AGGSTATE_CURPERTRANS   16

Definition at line 2450 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURRENT_SET

#define FIELDNO_AGGSTATE_CURRENT_SET   20

Definition at line 2455 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_AGGNULLS

#define FIELDNO_EXPRCONTEXT_AGGNULLS   9

Definition at line 307 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_AGGVALUES

#define FIELDNO_EXPRCONTEXT_AGGVALUES   8

Definition at line 305 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_CASEDATUM

#define FIELDNO_EXPRCONTEXT_CASEDATUM   10

Definition at line 311 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_CASENULL

#define FIELDNO_EXPRCONTEXT_CASENULL   11

Definition at line 313 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_DOMAINDATUM

#define FIELDNO_EXPRCONTEXT_DOMAINDATUM   12

Definition at line 317 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_DOMAINNULL

#define FIELDNO_EXPRCONTEXT_DOMAINNULL   13

Definition at line 319 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_INNERTUPLE

#define FIELDNO_EXPRCONTEXT_INNERTUPLE   2

Definition at line 288 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_NEWTUPLE

#define FIELDNO_EXPRCONTEXT_NEWTUPLE   15

Definition at line 325 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_OLDTUPLE

#define FIELDNO_EXPRCONTEXT_OLDTUPLE   14

Definition at line 323 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_OUTERTUPLE

#define FIELDNO_EXPRCONTEXT_OUTERTUPLE   3

Definition at line 290 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_SCANTUPLE

#define FIELDNO_EXPRCONTEXT_SCANTUPLE   1

Definition at line 286 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_FLAGS

#define FIELDNO_EXPRSTATE_FLAGS   1

Definition at line 102 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_PARENT

#define FIELDNO_EXPRSTATE_PARENT   11

Definition at line 145 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESNULL

#define FIELDNO_EXPRSTATE_RESNULL   2

Definition at line 109 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESULTSLOT

#define FIELDNO_EXPRSTATE_RESULTSLOT   4

Definition at line 117 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESVALUE

#define FIELDNO_EXPRSTATE_RESVALUE   3

Definition at line 111 of file execnodes.h.

◆ InitTupleHashIterator

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

Definition at line 931 of file execnodes.h.

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

◆ innerPlanState

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

Definition at line 1299 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 1308 of file execnodes.h.

1309 { \
1310 if (((PlanState *)(node))->instrument) \
1311 ((PlanState *)(node))->instrument->nfiltered1 += (delta); \
1312 } while(0)

◆ InstrCountFiltered2

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

Definition at line 1313 of file execnodes.h.

1314 { \
1315 if (((PlanState *)(node))->instrument) \
1316 ((PlanState *)(node))->instrument->nfiltered2 += (delta); \
1317 } while(0)

◆ InstrCountTuples2

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

Definition at line 1303 of file execnodes.h.

1304 { \
1305 if (((PlanState *)(node))->instrument) \
1306 ((PlanState *)(node))->instrument->ntuples2 += (delta); \
1307 } while (0)

◆ MERGE_DELETE

#define MERGE_DELETE   0x04

Definition at line 1434 of file execnodes.h.

◆ MERGE_INSERT

#define MERGE_INSERT   0x01

Definition at line 1432 of file execnodes.h.

◆ MERGE_UPDATE

#define MERGE_UPDATE   0x02

Definition at line 1433 of file execnodes.h.

◆ outerPlanState

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

Definition at line 1300 of file execnodes.h.

◆ ResetTupleHashIterator

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

Definition at line 935 of file execnodes.h.

◆ ScanTupleHashTable

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

Definition at line 937 of file execnodes.h.

◆ SH_DECLARE

#define SH_DECLARE

Definition at line 902 of file execnodes.h.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   TupleHashEntryData

Definition at line 899 of file execnodes.h.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   MinimalTuple

Definition at line 900 of file execnodes.h.

◆ SH_PREFIX

#define SH_PREFIX   tuplehash

Definition at line 898 of file execnodes.h.

◆ SH_SCOPE

#define SH_SCOPE   extern

Definition at line 901 of file execnodes.h.

◆ TermTupleHashIterator

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

Definition at line 933 of file execnodes.h.

Typedef Documentation

◆ AggState

◆ AggStatePerAgg

Definition at line 2425 of file execnodes.h.

◆ AggStatePerGroup

Definition at line 2427 of file execnodes.h.

◆ AggStatePerHash

Definition at line 2429 of file execnodes.h.

◆ AggStatePerPhase

Definition at line 2428 of file execnodes.h.

◆ AggStatePerTrans

Definition at line 2426 of file execnodes.h.

◆ AppendState

Definition at line 1528 of file execnodes.h.

◆ AsyncRequest

◆ BitmapAndState

◆ BitmapHeapScanState

◆ BitmapIndexScanState

◆ BitmapOrState

◆ BufferUsage

Definition at line 48 of file execnodes.h.

◆ CteScanState

◆ CustomScanState

◆ DomainConstraintState

◆ DomainConstraintType

◆ EPQState

◆ EState

◆ ExecAuxRowMark

◆ ExecProcNodeMtd

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

Definition at line 1187 of file execnodes.h.

◆ ExecRowMark

Definition at line 49 of file execnodes.h.

◆ ExprContext

Definition at line 51 of file execnodes.h.

◆ ExprContext_CB

◆ ExprContextCallbackFunction

typedef void(* ExprContextCallbackFunction) (Datum arg)

Definition at line 249 of file execnodes.h.

◆ ExprState

Definition at line 50 of file execnodes.h.

◆ ExprStateEvalFunc

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

Definition at line 82 of file execnodes.h.

◆ ForeignScanState

◆ ForPortionOfState

◆ FunctionScanState

◆ GatherMergeState

◆ GatherState

◆ GroupState

◆ HashJoinState

◆ HashJoinTable

Definition at line 2245 of file execnodes.h.

◆ HashJoinTuple

Definition at line 2244 of file execnodes.h.

◆ HashState

◆ HTAB

typedef struct HTAB HTAB

Definition at line 52 of file execnodes.h.

◆ IncrementalSortState

◆ IndexInfo

◆ IndexOnlyScanState

◆ IndexScanState

◆ Instrumentation

Definition at line 53 of file execnodes.h.

◆ JoinState

◆ JsonExprState

◆ JunkFilter

◆ LimitState

◆ LockRowsState

◆ MaterialState

◆ MemoizeState

◆ MergeActionState

◆ MergeAppendState

◆ MergeJoinClause

Definition at line 2190 of file execnodes.h.

◆ MergeJoinState

◆ ModifyTableState

◆ NamedTuplestoreScanState

◆ NestLoopState

◆ NodeInstrumentation

Definition at line 63 of file execnodes.h.

◆ OnConflictActionState

◆ pairingheap

Definition at line 54 of file execnodes.h.

◆ ParallelAppendState

Definition at line 1530 of file execnodes.h.

◆ ParallelBitmapHeapState

◆ PlanState

Definition at line 55 of file execnodes.h.

◆ PresortedKeyData

◆ ProjectionInfo

◆ ProjectSetState

◆ QueryEnvironment

Definition at line 56 of file execnodes.h.

◆ RecursiveUnionState

◆ Relation

Definition at line 57 of file execnodes.h.

◆ RelationPtr

Definition at line 58 of file execnodes.h.

◆ ResultRelInfo

◆ ResultState

◆ ReturnSetInfo

◆ SampleScanState

◆ ScanKeyData

Definition at line 59 of file execnodes.h.

◆ ScanState

◆ SeqScanState

◆ SetExprState

◆ SetOpState

◆ SetOpStatePerInput

◆ Snapshot

Definition at line 60 of file execnodes.h.

◆ SortState

◆ SortSupport

Definition at line 61 of file execnodes.h.

◆ SubPlanState

◆ SubqueryScanState

◆ TableFuncScanState

◆ TIDBitmap

Definition at line 62 of file execnodes.h.

◆ TidRangeScanState

◆ TidScanState

◆ TriggerInstrumentation

◆ TupleConversionMap

Definition at line 65 of file execnodes.h.

◆ TupleDesc

Definition at line 66 of file execnodes.h.

◆ TupleHashEntry

Definition at line 881 of file execnodes.h.

◆ TupleHashEntryData

◆ TupleHashIterator

◆ TupleHashTable

Definition at line 882 of file execnodes.h.

◆ TupleHashTableData

◆ Tuplesortstate

Definition at line 67 of file execnodes.h.

◆ Tuplestorestate

Definition at line 68 of file execnodes.h.

◆ TupleTableSlot

Definition at line 69 of file execnodes.h.

◆ TupleTableSlotOps

Definition at line 70 of file execnodes.h.

◆ UniqueState

◆ ValuesScanState

◆ WalUsage

Definition at line 71 of file execnodes.h.

◆ WindowAggState

◆ WindowAggStatus

◆ WindowFuncExprState

◆ WindowStatePerAgg

Definition at line 2514 of file execnodes.h.

◆ WindowStatePerFunc

Definition at line 2513 of file execnodes.h.

◆ WorkerNodeInstrumentation

◆ WorkTableScanState

Enumeration Type Documentation

◆ DomainConstraintType

Enumerator
DOM_CONSTRAINT_NOTNULL 
DOM_CONSTRAINT_CHECK 

Definition at line 1084 of file execnodes.h.

◆ ExprDoneCond

Enumerator
ExprSingleResult 
ExprMultipleResult 
ExprEndResult 

Definition at line 339 of file execnodes.h.

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

◆ IncrementalSortExecutionStatus

Enumerator
INCSORT_LOADFULLSORT 
INCSORT_LOADPREFIXSORT 
INCSORT_READFULLSORT 
INCSORT_READPREFIXSORT 

Definition at line 2370 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 2785 of file execnodes.h.

2786{
2787 LIMIT_INITIAL, /* initial state for LIMIT node */
2788 LIMIT_RESCAN, /* rescan after recomputing parameters */
2789 LIMIT_EMPTY, /* there are no returnable rows */
2790 LIMIT_INWINDOW, /* have returned a row in the window */
2791 LIMIT_WINDOWEND_TIES, /* have returned a tied row */
2792 LIMIT_SUBPLANEOF, /* at EOF of subplan (within window) */
2793 LIMIT_WINDOWEND, /* stepped off end of window */
2794 LIMIT_WINDOWSTART, /* stepped off beginning of window */

◆ SetFunctionReturnMode

Enumerator
SFRM_ValuePerCall 
SFRM_Materialize 
SFRM_Materialize_Random 
SFRM_Materialize_Preferred 

Definition at line 352 of file execnodes.h.

353{
354 SFRM_ValuePerCall = 0x01, /* one value returned per call */
355 SFRM_Materialize = 0x02, /* result set instantiated in Tuplestore */
356 SFRM_Materialize_Random = 0x04, /* Tuplestore needs randomAccess */
357 SFRM_Materialize_Preferred = 0x08, /* caller prefers Tuplestore */
SetFunctionReturnMode
Definition execnodes.h:353
@ SFRM_Materialize_Preferred
Definition execnodes.h:357
@ SFRM_ValuePerCall
Definition execnodes.h:354
@ SFRM_Materialize_Random
Definition execnodes.h:356
@ SFRM_Materialize
Definition execnodes.h:355

◆ WindowAggStatus

Enumerator
WINDOWAGG_DONE 
WINDOWAGG_RUN 
WINDOWAGG_PASSTHROUGH 
WINDOWAGG_PASSTHROUGH_STRICT 

Definition at line 2519 of file execnodes.h.

2520{
2521 WINDOWAGG_DONE, /* No more processing to do */
2522 WINDOWAGG_RUN, /* Normal processing of window funcs */
2523 WINDOWAGG_PASSTHROUGH, /* Don't eval window funcs */
2524 WINDOWAGG_PASSTHROUGH_STRICT, /* Pass-through plus don't store new
2525 * tuples during spool */