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 "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  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 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 WorkerInstrumentation WorkerInstrumentation
 
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 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 89 of file execnodes.h.

◆ EEO_FLAG_HAS_OLD

#define EEO_FLAG_HAS_OLD   (1 << 1)

Definition at line 87 of file execnodes.h.

◆ EEO_FLAG_IS_QUAL

#define EEO_FLAG_IS_QUAL   (1 << 0)

Definition at line 85 of file execnodes.h.

◆ EEO_FLAG_NEW_IS_NULL

#define EEO_FLAG_NEW_IS_NULL   (1 << 4)

Definition at line 93 of file execnodes.h.

◆ EEO_FLAG_OLD_IS_NULL

#define EEO_FLAG_OLD_IS_NULL   (1 << 3)

Definition at line 91 of file execnodes.h.

◆ FIELDNO_AGGSTATE_ALL_PERGROUPS

#define FIELDNO_AGGSTATE_ALL_PERGROUPS   54

Definition at line 2473 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURAGGCONTEXT

#define FIELDNO_AGGSTATE_CURAGGCONTEXT   14

Definition at line 2418 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURPERTRANS

#define FIELDNO_AGGSTATE_CURPERTRANS   16

Definition at line 2421 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURRENT_SET

#define FIELDNO_AGGSTATE_CURRENT_SET   20

Definition at line 2426 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_AGGNULLS

#define FIELDNO_EXPRCONTEXT_AGGNULLS   9

Definition at line 304 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_AGGVALUES

#define FIELDNO_EXPRCONTEXT_AGGVALUES   8

Definition at line 302 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_CASEDATUM

#define FIELDNO_EXPRCONTEXT_CASEDATUM   10

Definition at line 308 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_CASENULL

#define FIELDNO_EXPRCONTEXT_CASENULL   11

Definition at line 310 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_DOMAINDATUM

#define FIELDNO_EXPRCONTEXT_DOMAINDATUM   12

Definition at line 314 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_DOMAINNULL

#define FIELDNO_EXPRCONTEXT_DOMAINNULL   13

Definition at line 316 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_INNERTUPLE

#define FIELDNO_EXPRCONTEXT_INNERTUPLE   2

Definition at line 285 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_NEWTUPLE

#define FIELDNO_EXPRCONTEXT_NEWTUPLE   15

Definition at line 322 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_OLDTUPLE

#define FIELDNO_EXPRCONTEXT_OLDTUPLE   14

Definition at line 320 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_OUTERTUPLE

#define FIELDNO_EXPRCONTEXT_OUTERTUPLE   3

Definition at line 287 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_SCANTUPLE

#define FIELDNO_EXPRCONTEXT_SCANTUPLE   1

Definition at line 283 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_FLAGS

#define FIELDNO_EXPRSTATE_FLAGS   1

Definition at line 99 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_PARENT

#define FIELDNO_EXPRSTATE_PARENT   11

Definition at line 142 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESNULL

#define FIELDNO_EXPRSTATE_RESNULL   2

Definition at line 106 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESULTSLOT

#define FIELDNO_EXPRSTATE_RESULTSLOT   4

Definition at line 114 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESVALUE

#define FIELDNO_EXPRSTATE_RESVALUE   3

Definition at line 108 of file execnodes.h.

◆ InitTupleHashIterator

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

Definition at line 906 of file execnodes.h.

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

◆ innerPlanState

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

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

1282 { \
1283 if (((PlanState *)(node))->instrument) \
1284 ((PlanState *)(node))->instrument->nfiltered1 += (delta); \
1285 } while(0)

◆ InstrCountFiltered2

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

Definition at line 1286 of file execnodes.h.

1287 { \
1288 if (((PlanState *)(node))->instrument) \
1289 ((PlanState *)(node))->instrument->nfiltered2 += (delta); \
1290 } while(0)

◆ InstrCountTuples2

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

Definition at line 1276 of file execnodes.h.

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

◆ MERGE_DELETE

#define MERGE_DELETE   0x04

Definition at line 1407 of file execnodes.h.

◆ MERGE_INSERT

#define MERGE_INSERT   0x01

Definition at line 1405 of file execnodes.h.

◆ MERGE_UPDATE

#define MERGE_UPDATE   0x02

Definition at line 1406 of file execnodes.h.

◆ outerPlanState

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

Definition at line 1273 of file execnodes.h.

◆ ResetTupleHashIterator

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

Definition at line 910 of file execnodes.h.

◆ ScanTupleHashTable

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

Definition at line 912 of file execnodes.h.

◆ SH_DECLARE

#define SH_DECLARE

Definition at line 877 of file execnodes.h.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   TupleHashEntryData

Definition at line 874 of file execnodes.h.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   MinimalTuple

Definition at line 875 of file execnodes.h.

◆ SH_PREFIX

#define SH_PREFIX   tuplehash

Definition at line 873 of file execnodes.h.

◆ SH_SCOPE

#define SH_SCOPE   extern

Definition at line 876 of file execnodes.h.

◆ TermTupleHashIterator

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

Definition at line 908 of file execnodes.h.

Typedef Documentation

◆ AggState

◆ AggStatePerAgg

Definition at line 2396 of file execnodes.h.

◆ AggStatePerGroup

Definition at line 2398 of file execnodes.h.

◆ AggStatePerHash

Definition at line 2400 of file execnodes.h.

◆ AggStatePerPhase

Definition at line 2399 of file execnodes.h.

◆ AggStatePerTrans

Definition at line 2397 of file execnodes.h.

◆ AppendState

Definition at line 1501 of file execnodes.h.

◆ AsyncRequest

◆ BitmapAndState

◆ BitmapHeapScanState

◆ BitmapIndexScanState

◆ BitmapOrState

◆ BufferUsage

Definition at line 47 of file execnodes.h.

◆ CteScanState

◆ CustomScanState

◆ DomainConstraintState

◆ DomainConstraintType

◆ EPQState

◆ EState

◆ ExecAuxRowMark

◆ ExecProcNodeMtd

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

Definition at line 1162 of file execnodes.h.

◆ ExecRowMark

Definition at line 48 of file execnodes.h.

◆ ExprContext

Definition at line 50 of file execnodes.h.

◆ ExprContext_CB

◆ ExprContextCallbackFunction

typedef void(* ExprContextCallbackFunction) (Datum arg)

Definition at line 246 of file execnodes.h.

◆ ExprState

Definition at line 49 of file execnodes.h.

◆ ExprStateEvalFunc

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

Definition at line 79 of file execnodes.h.

◆ ForeignScanState

◆ FunctionScanState

◆ GatherMergeState

◆ GatherState

◆ GroupState

◆ HashJoinState

◆ HashJoinTable

Definition at line 2216 of file execnodes.h.

◆ HashJoinTuple

Definition at line 2215 of file execnodes.h.

◆ HashState

◆ HTAB

typedef struct HTAB HTAB

Definition at line 51 of file execnodes.h.

◆ IncrementalSortState

◆ IndexInfo

◆ IndexOnlyScanState

◆ IndexScanState

◆ Instrumentation

Definition at line 52 of file execnodes.h.

◆ JoinState

◆ JsonExprState

◆ JunkFilter

◆ LimitState

◆ LockRowsState

◆ MaterialState

◆ MemoizeState

◆ MergeActionState

◆ MergeAppendState

◆ MergeJoinClause

Definition at line 2161 of file execnodes.h.

◆ MergeJoinState

◆ ModifyTableState

◆ NamedTuplestoreScanState

◆ NestLoopState

◆ OnConflictActionState

◆ pairingheap

Definition at line 53 of file execnodes.h.

◆ ParallelAppendState

Definition at line 1503 of file execnodes.h.

◆ ParallelBitmapHeapState

◆ PlanState

Definition at line 54 of file execnodes.h.

◆ PresortedKeyData

◆ ProjectionInfo

◆ ProjectSetState

◆ QueryEnvironment

Definition at line 55 of file execnodes.h.

◆ RecursiveUnionState

◆ Relation

Definition at line 56 of file execnodes.h.

◆ RelationPtr

Definition at line 57 of file execnodes.h.

◆ ResultRelInfo

◆ ResultState

◆ ReturnSetInfo

◆ SampleScanState

◆ ScanKeyData

Definition at line 58 of file execnodes.h.

◆ ScanState

◆ SeqScanState

◆ SetExprState

◆ SetOpState

◆ SetOpStatePerInput

◆ Snapshot

Definition at line 59 of file execnodes.h.

◆ SortState

◆ SortSupport

Definition at line 60 of file execnodes.h.

◆ SubPlanState

◆ SubqueryScanState

◆ TableFuncScanState

◆ TIDBitmap

Definition at line 61 of file execnodes.h.

◆ TidRangeScanState

◆ TidScanState

◆ TupleConversionMap

Definition at line 62 of file execnodes.h.

◆ TupleDesc

Definition at line 63 of file execnodes.h.

◆ TupleHashEntry

Definition at line 856 of file execnodes.h.

◆ TupleHashEntryData

◆ TupleHashIterator

◆ TupleHashTable

Definition at line 857 of file execnodes.h.

◆ TupleHashTableData

◆ Tuplesortstate

Definition at line 64 of file execnodes.h.

◆ Tuplestorestate

Definition at line 65 of file execnodes.h.

◆ TupleTableSlot

Definition at line 66 of file execnodes.h.

◆ TupleTableSlotOps

Definition at line 67 of file execnodes.h.

◆ UniqueState

◆ ValuesScanState

◆ WalUsage

Definition at line 68 of file execnodes.h.

◆ WindowAggState

◆ WindowAggStatus

◆ WindowFuncExprState

◆ WindowStatePerAgg

Definition at line 2485 of file execnodes.h.

◆ WindowStatePerFunc

Definition at line 2484 of file execnodes.h.

◆ WorkerInstrumentation

◆ WorkTableScanState

Enumeration Type Documentation

◆ DomainConstraintType

Enumerator
DOM_CONSTRAINT_NOTNULL 
DOM_CONSTRAINT_CHECK 

Definition at line 1059 of file execnodes.h.

◆ ExprDoneCond

Enumerator
ExprSingleResult 
ExprMultipleResult 
ExprEndResult 

Definition at line 336 of file execnodes.h.

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

◆ IncrementalSortExecutionStatus

Enumerator
INCSORT_LOADFULLSORT 
INCSORT_LOADPREFIXSORT 
INCSORT_READFULLSORT 
INCSORT_READPREFIXSORT 

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

2757{
2758 LIMIT_INITIAL, /* initial state for LIMIT node */
2759 LIMIT_RESCAN, /* rescan after recomputing parameters */
2760 LIMIT_EMPTY, /* there are no returnable rows */
2761 LIMIT_INWINDOW, /* have returned a row in the window */
2762 LIMIT_WINDOWEND_TIES, /* have returned a tied row */
2763 LIMIT_SUBPLANEOF, /* at EOF of subplan (within window) */
2764 LIMIT_WINDOWEND, /* stepped off end of window */
2765 LIMIT_WINDOWSTART, /* stepped off beginning of window */

◆ SetFunctionReturnMode

Enumerator
SFRM_ValuePerCall 
SFRM_Materialize 
SFRM_Materialize_Random 
SFRM_Materialize_Preferred 

Definition at line 349 of file execnodes.h.

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

◆ WindowAggStatus

Enumerator
WINDOWAGG_DONE 
WINDOWAGG_RUN 
WINDOWAGG_PASSTHROUGH 
WINDOWAGG_PASSTHROUGH_STRICT 

Definition at line 2490 of file execnodes.h.

2491{
2492 WINDOWAGG_DONE, /* No more processing to do */
2493 WINDOWAGG_RUN, /* Normal processing of window funcs */
2494 WINDOWAGG_PASSTHROUGH, /* Don't eval window funcs */
2495 WINDOWAGG_PASSTHROUGH_STRICT, /* Pass-through plus don't store new
2496 * tuples during spool */