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

Go to the source code of this file.

Data Structures

struct  ExprState
 
struct  IndexInfo
 
struct  ExprContext_CB
 
struct  ExprContext
 
struct  ReturnSetInfo
 
struct  ProjectionInfo
 
struct  JunkFilter
 
struct  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  ParallelBitmapHeapState
 
struct  BitmapHeapScanState
 
struct  TidScanState
 
struct  TidRangeScanState
 
struct  SubqueryScanState
 
struct  FunctionScanState
 
struct  ValuesScanState
 
struct  TableFuncScanState
 
struct  CteScanState
 
struct  NamedTuplestoreScanState
 
struct  WorkTableScanState
 
struct  ForeignScanState
 
struct  CustomScanState
 
struct  JoinState
 
struct  NestLoopState
 
struct  MergeJoinState
 
struct  HashJoinState
 
struct  MaterialState
 
struct  MemoizeState
 
struct  PresortedKeyData
 
struct  SortState
 
struct  IncrementalSortState
 
struct  GroupState
 
struct  AggState
 
struct  WindowAggState
 
struct  UniqueState
 
struct  GatherState
 
struct  GatherMergeState
 
struct  HashState
 
struct  SetOpStatePerInput
 
struct  SetOpState
 
struct  LockRowsState
 
struct  LimitState
 

Macros

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

Typedefs

typedef struct PlanState PlanState
 
typedef struct ExecRowMark ExecRowMark
 
typedef struct ExprState ExprState
 
typedef struct ExprContext ExprContext
 
typedef Datum(* ExprStateEvalFunc) (ExprState *expression, ExprContext *econtext, bool *isNull)
 
typedef struct IndexInfo IndexInfo
 
typedef void(* ExprContextCallbackFunction) (Datum arg)
 
typedef struct ExprContext_CB ExprContext_CB
 
typedef struct ReturnSetInfo ReturnSetInfo
 
typedef struct ProjectionInfo ProjectionInfo
 
typedef struct JunkFilter JunkFilter
 
typedef struct 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  SharedBitmapState { BM_INITIAL , BM_INPROGRESS , BM_FINISHED }
 
enum  IncrementalSortExecutionStatus { INCSORT_LOADFULLSORT , INCSORT_LOADPREFIXSORT , INCSORT_READFULLSORT , INCSORT_READPREFIXSORT }
 
enum  WindowAggStatus { WINDOWAGG_DONE , WINDOWAGG_RUN , WINDOWAGG_PASSTHROUGH , WINDOWAGG_PASSTHROUGH_STRICT }
 
enum  LimitStateCond {
  LIMIT_INITIAL , LIMIT_RESCAN , LIMIT_EMPTY , LIMIT_INWINDOW ,
  LIMIT_WINDOWEND_TIES , LIMIT_SUBPLANEOF , LIMIT_WINDOWEND , LIMIT_WINDOWSTART
}
 

Macro Definition Documentation

◆ EEO_FLAG_HAS_NEW

#define EEO_FLAG_HAS_NEW   (1 << 2)

Definition at line 80 of file execnodes.h.

◆ EEO_FLAG_HAS_OLD

#define EEO_FLAG_HAS_OLD   (1 << 1)

Definition at line 78 of file execnodes.h.

◆ EEO_FLAG_IS_QUAL

#define EEO_FLAG_IS_QUAL   (1 << 0)

Definition at line 76 of file execnodes.h.

◆ EEO_FLAG_NEW_IS_NULL

#define EEO_FLAG_NEW_IS_NULL   (1 << 4)

Definition at line 84 of file execnodes.h.

◆ EEO_FLAG_OLD_IS_NULL

#define EEO_FLAG_OLD_IS_NULL   (1 << 3)

Definition at line 82 of file execnodes.h.

◆ FIELDNO_AGGSTATE_ALL_PERGROUPS

#define FIELDNO_AGGSTATE_ALL_PERGROUPS   54

Definition at line 2490 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURAGGCONTEXT

#define FIELDNO_AGGSTATE_CURAGGCONTEXT   14

Definition at line 2435 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURPERTRANS

#define FIELDNO_AGGSTATE_CURPERTRANS   16

Definition at line 2438 of file execnodes.h.

◆ FIELDNO_AGGSTATE_CURRENT_SET

#define FIELDNO_AGGSTATE_CURRENT_SET   20

Definition at line 2443 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_AGGNULLS

#define FIELDNO_EXPRCONTEXT_AGGNULLS   9

Definition at line 295 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_AGGVALUES

#define FIELDNO_EXPRCONTEXT_AGGVALUES   8

Definition at line 293 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_CASEDATUM

#define FIELDNO_EXPRCONTEXT_CASEDATUM   10

Definition at line 299 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_CASENULL

#define FIELDNO_EXPRCONTEXT_CASENULL   11

Definition at line 301 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_DOMAINDATUM

#define FIELDNO_EXPRCONTEXT_DOMAINDATUM   12

Definition at line 305 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_DOMAINNULL

#define FIELDNO_EXPRCONTEXT_DOMAINNULL   13

Definition at line 307 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_INNERTUPLE

#define FIELDNO_EXPRCONTEXT_INNERTUPLE   2

Definition at line 276 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_NEWTUPLE

#define FIELDNO_EXPRCONTEXT_NEWTUPLE   15

Definition at line 313 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_OLDTUPLE

#define FIELDNO_EXPRCONTEXT_OLDTUPLE   14

Definition at line 311 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_OUTERTUPLE

#define FIELDNO_EXPRCONTEXT_OUTERTUPLE   3

Definition at line 278 of file execnodes.h.

◆ FIELDNO_EXPRCONTEXT_SCANTUPLE

#define FIELDNO_EXPRCONTEXT_SCANTUPLE   1

Definition at line 274 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_FLAGS

#define FIELDNO_EXPRSTATE_FLAGS   1

Definition at line 90 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_PARENT

#define FIELDNO_EXPRSTATE_PARENT   11

Definition at line 133 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESNULL

#define FIELDNO_EXPRSTATE_RESNULL   2

Definition at line 97 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESULTSLOT

#define FIELDNO_EXPRSTATE_RESULTSLOT   4

Definition at line 105 of file execnodes.h.

◆ FIELDNO_EXPRSTATE_RESVALUE

#define FIELDNO_EXPRSTATE_RESVALUE   3

Definition at line 99 of file execnodes.h.

◆ InitTupleHashIterator

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

Definition at line 897 of file execnodes.h.

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

◆ innerPlanState

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

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

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

◆ InstrCountFiltered2

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

Definition at line 1277 of file execnodes.h.

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

◆ InstrCountTuples2

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

Definition at line 1267 of file execnodes.h.

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

◆ MERGE_DELETE

#define MERGE_DELETE   0x04

Definition at line 1398 of file execnodes.h.

◆ MERGE_INSERT

#define MERGE_INSERT   0x01

Definition at line 1396 of file execnodes.h.

◆ MERGE_UPDATE

#define MERGE_UPDATE   0x02

Definition at line 1397 of file execnodes.h.

◆ outerPlanState

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

Definition at line 1264 of file execnodes.h.

◆ ResetTupleHashIterator

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

Definition at line 901 of file execnodes.h.

◆ ScanTupleHashTable

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

Definition at line 903 of file execnodes.h.

◆ SH_DECLARE

#define SH_DECLARE

Definition at line 868 of file execnodes.h.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   TupleHashEntryData

Definition at line 865 of file execnodes.h.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   MinimalTuple

Definition at line 866 of file execnodes.h.

◆ SH_PREFIX

#define SH_PREFIX   tuplehash

Definition at line 864 of file execnodes.h.

◆ SH_SCOPE

#define SH_SCOPE   extern

Definition at line 867 of file execnodes.h.

◆ TermTupleHashIterator

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

Definition at line 899 of file execnodes.h.

Typedef Documentation

◆ AggState

◆ AggStatePerAgg

Definition at line 2413 of file execnodes.h.

◆ AggStatePerGroup

Definition at line 2415 of file execnodes.h.

◆ AggStatePerHash

Definition at line 2417 of file execnodes.h.

◆ AggStatePerPhase

Definition at line 2416 of file execnodes.h.

◆ AggStatePerTrans

Definition at line 2414 of file execnodes.h.

◆ AppendState

Definition at line 1492 of file execnodes.h.

◆ AsyncRequest

◆ BitmapAndState

◆ BitmapHeapScanState

◆ BitmapIndexScanState

◆ BitmapOrState

◆ CteScanState

◆ CustomScanState

◆ DomainConstraintState

◆ DomainConstraintType

◆ EPQState

◆ EState

◆ ExecAuxRowMark

◆ ExecProcNodeMtd

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

Definition at line 1153 of file execnodes.h.

◆ ExecRowMark

Definition at line 58 of file execnodes.h.

◆ ExprContext

Definition at line 60 of file execnodes.h.

◆ ExprContext_CB

◆ ExprContextCallbackFunction

typedef void(* ExprContextCallbackFunction) (Datum arg)

Definition at line 237 of file execnodes.h.

◆ ExprState

Definition at line 59 of file execnodes.h.

◆ ExprStateEvalFunc

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

Definition at line 70 of file execnodes.h.

◆ ForeignScanState

◆ FunctionScanState

◆ GatherMergeState

◆ GatherState

◆ GroupState

◆ HashJoinState

◆ HashJoinTable

Definition at line 2235 of file execnodes.h.

◆ HashJoinTuple

Definition at line 2234 of file execnodes.h.

◆ HashState

◆ IncrementalSortState

◆ IndexInfo

◆ IndexOnlyScanState

◆ IndexScanState

◆ JoinState

◆ JsonExprState

◆ JunkFilter

◆ LimitState

◆ LockRowsState

◆ MaterialState

◆ MemoizeState

◆ MergeActionState

◆ MergeAppendState

◆ MergeJoinClause

Definition at line 2183 of file execnodes.h.

◆ MergeJoinState

◆ ModifyTableState

◆ NamedTuplestoreScanState

◆ NestLoopState

◆ OnConflictActionState

◆ ParallelAppendState

Definition at line 1494 of file execnodes.h.

◆ ParallelBitmapHeapState

◆ PlanState

Definition at line 57 of file execnodes.h.

◆ PresortedKeyData

◆ ProjectionInfo

◆ ProjectSetState

◆ RecursiveUnionState

◆ ResultRelInfo

◆ ResultState

◆ ReturnSetInfo

◆ SampleScanState

◆ ScanState

◆ SeqScanState

◆ SetExprState

◆ SetOpState

◆ SetOpStatePerInput

◆ SortState

◆ SubPlanState

◆ SubqueryScanState

◆ TableFuncScanState

◆ TidRangeScanState

◆ TidScanState

◆ TupleHashEntry

Definition at line 847 of file execnodes.h.

◆ TupleHashEntryData

◆ TupleHashIterator

◆ TupleHashTable

Definition at line 848 of file execnodes.h.

◆ TupleHashTableData

◆ UniqueState

◆ ValuesScanState

◆ WindowAggState

◆ WindowAggStatus

◆ WindowFuncExprState

◆ WindowStatePerAgg

Definition at line 2502 of file execnodes.h.

◆ WindowStatePerFunc

Definition at line 2501 of file execnodes.h.

◆ WorkTableScanState

Enumeration Type Documentation

◆ DomainConstraintType

Enumerator
DOM_CONSTRAINT_NOTNULL 
DOM_CONSTRAINT_CHECK 

Definition at line 1050 of file execnodes.h.

◆ ExprDoneCond

Enumerator
ExprSingleResult 
ExprMultipleResult 
ExprEndResult 

Definition at line 327 of file execnodes.h.

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

◆ IncrementalSortExecutionStatus

Enumerator
INCSORT_LOADFULLSORT 
INCSORT_LOADPREFIXSORT 
INCSORT_READFULLSORT 
INCSORT_READPREFIXSORT 

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

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

◆ SetFunctionReturnMode

Enumerator
SFRM_ValuePerCall 
SFRM_Materialize 
SFRM_Materialize_Random 
SFRM_Materialize_Preferred 

Definition at line 340 of file execnodes.h.

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

◆ SharedBitmapState

Enumerator
BM_INITIAL 
BM_INPROGRESS 
BM_FINISHED 

Definition at line 1835 of file execnodes.h.

1836{
1837 BM_INITIAL,

◆ WindowAggStatus

Enumerator
WINDOWAGG_DONE 
WINDOWAGG_RUN 
WINDOWAGG_PASSTHROUGH 
WINDOWAGG_PASSTHROUGH_STRICT 

Definition at line 2507 of file execnodes.h.

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