#ifndef EXECNODES_H
#define EXECNODES_H
#include "access/tupconvert.h"
#include "executor/instrument.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"
struct PlanState;
struct ParallelHashJoinState;
struct ExecRowMark;
struct ExprState;
struct ExprContext;
struct RangeTblEntry;
struct ExprEvalStep;
struct CopyMultiInsertBuffer;
struct LogicalTapeSet;
typedef Datum (*ExprStateEvalFunc) (struct ExprState *expression,
struct ExprContext *econtext,
bool *isNull);
#define EEO_FLAG_IS_QUAL (1 << 0)
typedef struct ExprState
{
NodeTag type;
uint8 flags;
#define FIELDNO_EXPRSTATE_RESNULL 2
bool resnull;
#define FIELDNO_EXPRSTATE_RESVALUE 3
Datum resvalue;
#define FIELDNO_EXPRSTATE_RESULTSLOT 4
TupleTableSlot *resultslot;
struct ExprEvalStep *steps;
ExprStateEvalFunc evalfunc;
Expr *expr;
void *evalfunc_private;
int steps_len;
int steps_alloc;
#define FIELDNO_EXPRSTATE_PARENT 11
struct PlanState *parent;
ParamListInfo ext_params;
Datum *innermost_caseval;
bool *innermost_casenull;
Datum *innermost_domainval;
bool *innermost_domainnull;
ErrorSaveContext *escontext;
} ExprState;
typedef struct IndexInfo
{
NodeTag type;
int ii_NumIndexAttrs;
int ii_NumIndexKeyAttrs;
AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS];
List *ii_Expressions;
List *ii_ExpressionsState;
List *ii_Predicate;
ExprState *ii_PredicateState;
Oid *ii_ExclusionOps;
Oid *ii_ExclusionProcs;
uint16 *ii_ExclusionStrats;
Oid *ii_UniqueOps;
Oid *ii_UniqueProcs;
uint16 *ii_UniqueStrats;
bool ii_Unique;
bool ii_NullsNotDistinct;
bool ii_ReadyForInserts;
bool ii_CheckedUnchanged;
bool ii_IndexUnchanged;
bool ii_Concurrent;
bool ii_BrokenHotChain;
bool ii_Summarizing;
int ii_ParallelWorkers;
Oid ii_Am;
void *ii_AmCache;
MemoryContext ii_Context;
} IndexInfo;
typedef void (*ExprContextCallbackFunction) (Datum arg);
typedef struct ExprContext_CB
{
struct ExprContext_CB *next;
ExprContextCallbackFunction function;
Datum arg;
} ExprContext_CB;
typedef struct ExprContext
{
NodeTag type;
#define FIELDNO_EXPRCONTEXT_SCANTUPLE 1
TupleTableSlot *ecxt_scantuple;
#define FIELDNO_EXPRCONTEXT_INNERTUPLE 2
TupleTableSlot *ecxt_innertuple;
#define FIELDNO_EXPRCONTEXT_OUTERTUPLE 3
TupleTableSlot *ecxt_outertuple;
MemoryContext ecxt_per_query_memory;
MemoryContext ecxt_per_tuple_memory;
ParamExecData *ecxt_param_exec_vals;
ParamListInfo ecxt_param_list_info;
#define FIELDNO_EXPRCONTEXT_AGGVALUES 8
Datum *ecxt_aggvalues;
#define FIELDNO_EXPRCONTEXT_AGGNULLS 9
bool *ecxt_aggnulls;
#define FIELDNO_EXPRCONTEXT_CASEDATUM 10
Datum caseValue_datum;
#define FIELDNO_EXPRCONTEXT_CASENULL 11
bool caseValue_isNull;
#define FIELDNO_EXPRCONTEXT_DOMAINDATUM 12
Datum domainValue_datum;
#define FIELDNO_EXPRCONTEXT_DOMAINNULL 13
bool domainValue_isNull;
struct EState *ecxt_estate;
ExprContext_CB *ecxt_callbacks;
} ExprContext;
typedef enum
{
ExprSingleResult,
ExprMultipleResult,
ExprEndResult,
} ExprDoneCond;
typedef enum
{
SFRM_ValuePerCall = 0x01,
SFRM_Materialize = 0x02,
SFRM_Materialize_Random = 0x04,
SFRM_Materialize_Preferred = 0x08,
} SetFunctionReturnMode;
typedef struct ReturnSetInfo
{
NodeTag type;
ExprContext *econtext;
TupleDesc expectedDesc;
int allowedModes;
SetFunctionReturnMode returnMode;
ExprDoneCond isDone;
Tuplestorestate *setResult;
TupleDesc setDesc;
} ReturnSetInfo;
typedef struct ProjectionInfo
{
NodeTag type;
ExprState pi_state;
ExprContext *pi_exprContext;
} ProjectionInfo;
typedef struct JunkFilter
{
NodeTag type;
List *jf_targetList;
TupleDesc jf_cleanTupType;
AttrNumber *jf_cleanMap;
TupleTableSlot *jf_resultSlot;
} JunkFilter;
typedef struct OnConflictSetState
{
NodeTag type;
TupleTableSlot *oc_Existing;
TupleTableSlot *oc_ProjSlot;
ProjectionInfo *oc_ProjInfo;
ExprState *oc_WhereClause;
} OnConflictSetState;
typedef struct MergeActionState
{
NodeTag type;
MergeAction *mas_action;
ProjectionInfo *mas_proj;
ExprState *mas_whenqual;
} MergeActionState;
typedef struct ResultRelInfo
{
NodeTag type;
Index ri_RangeTableIndex;
Relation ri_RelationDesc;
int ri_NumIndices;
RelationPtr ri_IndexRelationDescs;
IndexInfo **ri_IndexRelationInfo;
AttrNumber ri_RowIdAttNo;
Bitmapset *ri_extraUpdatedCols;
ProjectionInfo *ri_projectNew;
TupleTableSlot *ri_newTupleSlot;
TupleTableSlot *ri_oldTupleSlot;
bool ri_projectNewInfoValid;
bool ri_needLockTagTuple;
TriggerDesc *ri_TrigDesc;
FmgrInfo *ri_TrigFunctions;
ExprState **ri_TrigWhenExprs;
Instrumentation *ri_TrigInstrument;
TupleTableSlot *ri_ReturningSlot;
TupleTableSlot *ri_TrigOldSlot;
TupleTableSlot *ri_TrigNewSlot;
struct FdwRoutine *ri_FdwRoutine;
void *ri_FdwState;
bool ri_usesFdwDirectModify;
int ri_NumSlots;
int ri_NumSlotsInitialized;
int ri_BatchSize;
TupleTableSlot **ri_Slots;
TupleTableSlot **ri_PlanSlots;
List *ri_WithCheckOptions;
List *ri_WithCheckOptionExprs;
ExprState **ri_ConstraintExprs;
ExprState **ri_GeneratedExprsI;
ExprState **ri_GeneratedExprsU;
int ri_NumGeneratedNeededI;
int ri_NumGeneratedNeededU;
List *ri_returningList;
ProjectionInfo *ri_projectReturning;
List *ri_onConflictArbiterIndexes;
OnConflictSetState *ri_onConflict;
List *ri_MergeActions[NUM_MERGE_MATCH_KINDS];
ExprState *ri_MergeJoinCondition;
ExprState *ri_PartitionCheckExpr;
TupleConversionMap *ri_ChildToRootMap;
bool ri_ChildToRootMapValid;
TupleConversionMap *ri_RootToChildMap;
bool ri_RootToChildMapValid;
struct ResultRelInfo *ri_RootResultRelInfo;
TupleTableSlot *ri_PartitionTupleSlot;
struct CopyMultiInsertBuffer *ri_CopyMultiInsertBuffer;
List *ri_ancestorResultRels;
} ResultRelInfo;
typedef struct AsyncRequest
{
struct PlanState *requestor;
struct PlanState *requestee;
int request_index;
bool callback_pending;
bool request_complete;
TupleTableSlot *result;
} AsyncRequest;
typedef struct EState
{
NodeTag type;
ScanDirection es_direction;
Snapshot es_snapshot;
Snapshot es_crosscheck_snapshot;
List *es_range_table;
Index es_range_table_size;
Relation *es_relations;
struct ExecRowMark **es_rowmarks;
List *es_rteperminfos;
PlannedStmt *es_plannedstmt;
const char *es_sourceText;
JunkFilter *es_junkFilter;
CommandId es_output_cid;
ResultRelInfo **es_result_relations;
List *es_opened_result_relations;
PartitionDirectory es_partition_directory;
List *es_tuple_routing_result_relations;
List *es_trig_target_relations;
ParamListInfo es_param_list_info;
ParamExecData *es_param_exec_vals;
QueryEnvironment *es_queryEnv;
MemoryContext es_query_cxt;
List *es_tupleTable;
uint64 es_processed;
uint64 es_total_processed;
int es_top_eflags;
int es_instrument;
bool es_finished;
List *es_exprcontexts;
List *es_subplanstates;
List *es_auxmodifytables;
ExprContext *es_per_tuple_exprcontext;
struct EPQState *es_epq_active;
bool es_use_parallel_mode;
struct dsa_area *es_query_dsa;
int es_jit_flags;
struct JitContext *es_jit;
struct JitInstrumentation *es_jit_worker_instr;
List *es_insert_pending_result_relations;
List *es_insert_pending_modifytables;
} EState;
typedef struct ExecRowMark
{
Relation relation;
Oid relid;
Index rti;
Index prti;
Index rowmarkId;
RowMarkType markType;
LockClauseStrength strength;
LockWaitPolicy waitPolicy;
bool ermActive;
ItemPointerData curCtid;
void *ermExtra;
} ExecRowMark;
typedef struct ExecAuxRowMark
{
ExecRowMark *rowmark;
AttrNumber ctidAttNo;
AttrNumber toidAttNo;
AttrNumber wholeAttNo;
} ExecAuxRowMark;
typedef struct TupleHashEntryData *TupleHashEntry;
typedef struct TupleHashTableData *TupleHashTable;
typedef struct TupleHashEntryData
{
MinimalTuple firstTuple;
void *additional;
uint32 status;
uint32 hash;
} TupleHashEntryData;
#define SH_PREFIX tuplehash
#define SH_ELEMENT_TYPE TupleHashEntryData
#define SH_KEY_TYPE MinimalTuple
#define SH_SCOPE extern
#define SH_DECLARE
#include "lib/simplehash.h"
typedef struct TupleHashTableData
{
tuplehash_hash *hashtab;
int numCols;
AttrNumber *keyColIdx;
FmgrInfo *tab_hash_funcs;
ExprState *tab_eq_func;
Oid *tab_collations;
MemoryContext tablecxt;
MemoryContext tempcxt;
Size entrysize;
TupleTableSlot *tableslot;
TupleTableSlot *inputslot;
FmgrInfo *in_hash_funcs;
ExprState *cur_eq_func;
uint32 hash_iv;
ExprContext *exprcontext;
} TupleHashTableData;
typedef tuplehash_iterator TupleHashIterator;
#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)
typedef struct WindowFuncExprState
{
NodeTag type;
WindowFunc *wfunc;
List *args;
ExprState *aggfilter;
int wfuncno;
} WindowFuncExprState;
typedef struct SetExprState
{
NodeTag type;
Expr *expr;
List *args;
ExprState *elidedFuncState;
FmgrInfo func;
Tuplestorestate *funcResultStore;
TupleTableSlot *funcResultSlot;
TupleDesc funcResultDesc;
bool funcReturnsTuple;
bool funcReturnsSet;
bool setArgsValid;
bool shutdown_reg;
FunctionCallInfo fcinfo;
} SetExprState;
typedef struct SubPlanState
{
NodeTag type;
SubPlan *subplan;
struct PlanState *planstate;
struct PlanState *parent;
ExprState *testexpr;
List *args;
HeapTuple curTuple;
Datum curArray;
TupleDesc descRight;
ProjectionInfo *projLeft;
ProjectionInfo *projRight;
TupleHashTable hashtable;
TupleHashTable hashnulls;
bool havehashrows;
bool havenullrows;
MemoryContext hashtablecxt;
MemoryContext hashtempcxt;
ExprContext *innerecontext;
int numCols;
AttrNumber *keyColIdx;
Oid *tab_eq_funcoids;
Oid *tab_collations;
FmgrInfo *tab_hash_funcs;
FmgrInfo *tab_eq_funcs;
FmgrInfo *lhs_hash_funcs;
FmgrInfo *cur_eq_funcs;
ExprState *cur_eq_comp;
} SubPlanState;
typedef enum DomainConstraintType
{
DOM_CONSTRAINT_NOTNULL,
DOM_CONSTRAINT_CHECK,
} DomainConstraintType;
typedef struct DomainConstraintState
{
NodeTag type;
DomainConstraintType constrainttype;
char *name;
Expr *check_expr;
ExprState *check_exprstate;
} DomainConstraintState;
typedef struct JsonExprState
{
JsonExpr *jsexpr;
NullableDatum formatted_expr;
NullableDatum pathspec;
List *args;
NullableDatum error;
NullableDatum empty;
int jump_empty;
int jump_error;
int jump_eval_coercion;
int jump_end;
FunctionCallInfo input_fcinfo;
ErrorSaveContext escontext;
} JsonExprState;
typedef TupleTableSlot *(*ExecProcNodeMtd) (struct PlanState *pstate);
typedef struct PlanState
{
pg_node_attr(abstract)
NodeTag type;
Plan *plan;
EState *state;
ExecProcNodeMtd ExecProcNode;
ExecProcNodeMtd ExecProcNodeReal;
Instrumentation *instrument;
WorkerInstrumentation *worker_instrument;
struct SharedJitInstrumentation *worker_jit_instrument;
ExprState *qual;
struct PlanState *lefttree;
struct PlanState *righttree;
List *initPlan;
List *subPlan;
Bitmapset *chgParam;
TupleDesc ps_ResultTupleDesc;
TupleTableSlot *ps_ResultTupleSlot;
ExprContext *ps_ExprContext;
ProjectionInfo *ps_ProjInfo;
bool async_capable;
TupleDesc scandesc;
const TupleTableSlotOps *scanops;
const TupleTableSlotOps *outerops;
const TupleTableSlotOps *innerops;
const TupleTableSlotOps *resultops;
bool scanopsfixed;
bool outeropsfixed;
bool inneropsfixed;
bool resultopsfixed;
bool scanopsset;
bool outeropsset;
bool inneropsset;
bool resultopsset;
} PlanState;
#define innerPlanState(node) (((PlanState *)(node))->righttree)
#define outerPlanState(node) (((PlanState *)(node))->lefttree)
#define InstrCountTuples2(node, delta) \
do { \
if (((PlanState *)(node))->instrument) \
((PlanState *)(node))->instrument->ntuples2 += (delta); \
} while (0)
#define InstrCountFiltered1(node, delta) \
do { \
if (((PlanState *)(node))->instrument) \
((PlanState *)(node))->instrument->nfiltered1 += (delta); \
} while(0)
#define InstrCountFiltered2(node, delta) \
do { \
if (((PlanState *)(node))->instrument) \
((PlanState *)(node))->instrument->nfiltered2 += (delta); \
} while(0)
typedef struct EPQState
{
EState *parentestate;
int epqParam;
List *resultRelations;
List *tuple_table;
TupleTableSlot **relsubs_slot;
Plan *plan;
List *arowMarks;
TupleTableSlot *origslot;
EState *recheckestate;
ExecAuxRowMark **relsubs_rowmark;
bool *relsubs_done;
bool *relsubs_blocked;
PlanState *recheckplanstate;
} EPQState;
typedef struct ResultState
{
PlanState ps;
ExprState *resconstantqual;
bool rs_done;
bool rs_checkqual;
} ResultState;
typedef struct ProjectSetState
{
PlanState ps;
Node **elems;
ExprDoneCond *elemdone;
int nelems;
bool pending_srf_tuples;
MemoryContext argcontext;
} ProjectSetState;
#define MERGE_INSERT 0x01
#define MERGE_UPDATE 0x02
#define MERGE_DELETE 0x04
typedef struct ModifyTableState
{
PlanState ps;
CmdType operation;
bool canSetTag;
bool mt_done;
int mt_nrels;
ResultRelInfo *resultRelInfo;
ResultRelInfo *rootResultRelInfo;
EPQState mt_epqstate;
bool fireBSTriggers;
int mt_resultOidAttno;
Oid mt_lastResultOid;
int mt_lastResultIndex;
HTAB *mt_resultOidHash;
TupleTableSlot *mt_root_tuple_slot;
struct PartitionTupleRouting *mt_partition_tuple_routing;
struct TransitionCaptureState *mt_transition_capture;
struct TransitionCaptureState *mt_oc_transition_capture;
int mt_merge_subcommands;
MergeActionState *mt_merge_action;
TupleTableSlot *mt_merge_pending_not_matched;
double mt_merge_inserted;
double mt_merge_updated;
double mt_merge_deleted;
} ModifyTableState;
struct AppendState;
typedef struct AppendState AppendState;
struct ParallelAppendState;
typedef struct ParallelAppendState ParallelAppendState;
struct PartitionPruneState;
struct AppendState
{
PlanState ps;
PlanState **appendplans;
int as_nplans;
int as_whichplan;
bool as_begun;
Bitmapset *as_asyncplans;
int as_nasyncplans;
AsyncRequest **as_asyncrequests;
TupleTableSlot **as_asyncresults;
int as_nasyncresults;
bool as_syncdone;
int as_nasyncremain;
Bitmapset *as_needrequest;
struct WaitEventSet *as_eventset;
int as_first_partial_plan;
ParallelAppendState *as_pstate;
Size pstate_len;
struct PartitionPruneState *as_prune_state;
bool as_valid_subplans_identified;
Bitmapset *as_valid_subplans;
Bitmapset *as_valid_asyncplans;
bool (*choose_next_subplan) (AppendState *);
};
typedef struct MergeAppendState
{
PlanState ps;
PlanState **mergeplans;
int ms_nplans;
int ms_nkeys;
SortSupport ms_sortkeys;
TupleTableSlot **ms_slots;
struct binaryheap *ms_heap;
bool ms_initialized;
struct PartitionPruneState *ms_prune_state;
Bitmapset *ms_valid_subplans;
} MergeAppendState;
typedef struct RecursiveUnionState
{
PlanState ps;
bool recursing;
bool intermediate_empty;
Tuplestorestate *working_table;
Tuplestorestate *intermediate_table;
Oid *eqfuncoids;
FmgrInfo *hashfunctions;
MemoryContext tempContext;
TupleHashTable hashtable;
MemoryContext tableContext;
} RecursiveUnionState;
typedef struct BitmapAndState
{
PlanState ps;
PlanState **bitmapplans;
int nplans;
} BitmapAndState;
typedef struct BitmapOrState
{
PlanState ps;
PlanState **bitmapplans;
int nplans;
} BitmapOrState;
typedef struct ScanState
{
PlanState ps;
Relation ss_currentRelation;
struct TableScanDescData *ss_currentScanDesc;
TupleTableSlot *ss_ScanTupleSlot;
} ScanState;
typedef struct SeqScanState
{
ScanState ss;
Size pscan_len;
} SeqScanState;
typedef struct SampleScanState
{
ScanState ss;
List *args;
ExprState *repeatable;
struct TsmRoutine *tsmroutine;
void *tsm_state;
bool use_bulkread;
bool use_pagemode;
bool begun;
uint32 seed;
int64 donetuples;
bool haveblock;
bool done;
} SampleScanState;
typedef struct
{
struct ScanKeyData *scan_key;
ExprState *key_expr;
bool key_toastable;
} IndexRuntimeKeyInfo;
typedef struct
{
struct ScanKeyData *scan_key;
ExprState *array_expr;
int next_elem;
int num_elems;
Datum *elem_values;
bool *elem_nulls;
} IndexArrayKeyInfo;
typedef struct IndexScanState
{
ScanState ss;
ExprState *indexqualorig;
List *indexorderbyorig;
struct ScanKeyData *iss_ScanKeys;
int iss_NumScanKeys;
struct ScanKeyData *iss_OrderByKeys;
int iss_NumOrderByKeys;
IndexRuntimeKeyInfo *iss_RuntimeKeys;
int iss_NumRuntimeKeys;
bool iss_RuntimeKeysReady;
ExprContext *iss_RuntimeContext;
Relation iss_RelationDesc;
struct IndexScanDescData *iss_ScanDesc;
pairingheap *iss_ReorderQueue;
bool iss_ReachedEnd;
Datum *iss_OrderByValues;
bool *iss_OrderByNulls;
SortSupport iss_SortSupport;
bool *iss_OrderByTypByVals;
int16 *iss_OrderByTypLens;
Size iss_PscanLen;
} IndexScanState;
typedef struct IndexOnlyScanState
{
ScanState ss;
ExprState *recheckqual;
struct ScanKeyData *ioss_ScanKeys;
int ioss_NumScanKeys;
struct ScanKeyData *ioss_OrderByKeys;
int ioss_NumOrderByKeys;
IndexRuntimeKeyInfo *ioss_RuntimeKeys;
int ioss_NumRuntimeKeys;
bool ioss_RuntimeKeysReady;
ExprContext *ioss_RuntimeContext;
Relation ioss_RelationDesc;
struct IndexScanDescData *ioss_ScanDesc;
TupleTableSlot *ioss_TableSlot;
Buffer ioss_VMBuffer;
Size ioss_PscanLen;
AttrNumber *ioss_NameCStringAttNums;
int ioss_NameCStringCount;
} IndexOnlyScanState;
typedef struct BitmapIndexScanState
{
ScanState ss;
TIDBitmap *biss_result;
struct ScanKeyData *biss_ScanKeys;
int biss_NumScanKeys;
IndexRuntimeKeyInfo *biss_RuntimeKeys;
int biss_NumRuntimeKeys;
IndexArrayKeyInfo *biss_ArrayKeys;
int biss_NumArrayKeys;
bool biss_RuntimeKeysReady;
ExprContext *biss_RuntimeContext;
Relation biss_RelationDesc;
struct IndexScanDescData *biss_ScanDesc;
} BitmapIndexScanState;
typedef enum
{
BM_INITIAL,
BM_INPROGRESS,
BM_FINISHED,
} SharedBitmapState;
typedef struct ParallelBitmapHeapState
{
dsa_pointer tbmiterator;
dsa_pointer prefetch_iterator;
slock_t mutex;
int prefetch_pages;
int prefetch_target;
SharedBitmapState state;
ConditionVariable cv;
} ParallelBitmapHeapState;
typedef struct BitmapHeapScanState
{
ScanState ss;
ExprState *bitmapqualorig;
TIDBitmap *tbm;
TBMIterator *tbmiterator;
TBMIterateResult *tbmres;
Buffer pvmbuffer;
long exact_pages;
long lossy_pages;
TBMIterator *prefetch_iterator;
int prefetch_pages;
int prefetch_target;
int prefetch_maximum;
bool initialized;
TBMSharedIterator *shared_tbmiterator;
TBMSharedIterator *shared_prefetch_iterator;
ParallelBitmapHeapState *pstate;
} BitmapHeapScanState;
typedef struct TidScanState
{
ScanState ss;
List *tss_tidexprs;
bool tss_isCurrentOf;
int tss_NumTids;
int tss_TidPtr;
ItemPointerData *tss_TidList;
} TidScanState;
typedef struct TidRangeScanState
{
ScanState ss;
List *trss_tidexprs;
ItemPointerData trss_mintid;
ItemPointerData trss_maxtid;
bool trss_inScan;
} TidRangeScanState;
typedef struct SubqueryScanState
{
ScanState ss;
PlanState *subplan;
} SubqueryScanState;
struct FunctionScanPerFuncState;
typedef struct FunctionScanState
{
ScanState ss;
int eflags;
bool ordinality;
bool simple;
int64 ordinal;
int nfuncs;
struct FunctionScanPerFuncState *funcstates;
MemoryContext argcontext;
} FunctionScanState;
typedef struct ValuesScanState
{
ScanState ss;
ExprContext *rowcontext;
List **exprlists;
List **exprstatelists;
int array_len;
int curr_idx;
} ValuesScanState;
typedef struct TableFuncScanState
{
ScanState ss;
ExprState *docexpr;
ExprState *rowexpr;
List *colexprs;
List *coldefexprs;
List *colvalexprs;
List *passingvalexprs;
List *ns_names;
List *ns_uris;
Bitmapset *notnulls;
void *opaque;
const struct TableFuncRoutine *routine;
FmgrInfo *in_functions;
Oid *typioparams;
int64 ordinal;
MemoryContext perTableCxt;
Tuplestorestate *tupstore;
} TableFuncScanState;
typedef struct CteScanState
{
ScanState ss;
int eflags;
int readptr;
PlanState *cteplanstate;
struct CteScanState *leader;
Tuplestorestate *cte_table;
bool eof_cte;
} CteScanState;
typedef struct NamedTuplestoreScanState
{
ScanState ss;
int readptr;
TupleDesc tupdesc;
Tuplestorestate *relation;
} NamedTuplestoreScanState;
typedef struct WorkTableScanState
{
ScanState ss;
RecursiveUnionState *rustate;
} WorkTableScanState;
typedef struct ForeignScanState
{
ScanState ss;
ExprState *fdw_recheck_quals;
Size pscan_len;
ResultRelInfo *resultRelInfo;
struct FdwRoutine *fdwroutine;
void *fdw_state;
} ForeignScanState;
struct CustomExecMethods;
typedef struct CustomScanState
{
ScanState ss;
uint32 flags;
List *custom_ps;
Size pscan_len;
const struct CustomExecMethods *methods;
const struct TupleTableSlotOps *slotOps;
} CustomScanState;
typedef struct JoinState
{
PlanState ps;
JoinType jointype;
bool single_match;
ExprState *joinqual;
} JoinState;
typedef struct NestLoopState
{
JoinState js;
bool nl_NeedNewOuter;
bool nl_MatchedOuter;
TupleTableSlot *nl_NullInnerTupleSlot;
} NestLoopState;
typedef struct MergeJoinClauseData *MergeJoinClause;
typedef struct MergeJoinState
{
JoinState js;
int mj_NumClauses;
MergeJoinClause mj_Clauses;
int mj_JoinState;
bool mj_SkipMarkRestore;
bool mj_ExtraMarks;
bool mj_ConstFalseJoin;
bool mj_FillOuter;
bool mj_FillInner;
bool mj_MatchedOuter;
bool mj_MatchedInner;
TupleTableSlot *mj_OuterTupleSlot;
TupleTableSlot *mj_InnerTupleSlot;
TupleTableSlot *mj_MarkedTupleSlot;
TupleTableSlot *mj_NullOuterTupleSlot;
TupleTableSlot *mj_NullInnerTupleSlot;
ExprContext *mj_OuterEContext;
ExprContext *mj_InnerEContext;
} MergeJoinState;
typedef struct HashJoinTupleData *HashJoinTuple;
typedef struct HashJoinTableData *HashJoinTable;
typedef struct HashJoinState
{
JoinState js;
ExprState *hashclauses;
List *hj_OuterHashKeys;
List *hj_HashOperators;
List *hj_Collations;
HashJoinTable hj_HashTable;
uint32 hj_CurHashValue;
int hj_CurBucketNo;
int hj_CurSkewBucketNo;
HashJoinTuple hj_CurTuple;
TupleTableSlot *hj_OuterTupleSlot;
TupleTableSlot *hj_HashTupleSlot;
TupleTableSlot *hj_NullOuterTupleSlot;
TupleTableSlot *hj_NullInnerTupleSlot;
TupleTableSlot *hj_FirstOuterTupleSlot;
int hj_JoinState;
bool hj_MatchedOuter;
bool hj_OuterNotEmpty;
} HashJoinState;
typedef struct MaterialState
{
ScanState ss;
int eflags;
bool eof_underlying;
Tuplestorestate *tuplestorestate;
} MaterialState;
struct MemoizeEntry;
struct MemoizeTuple;
struct MemoizeKey;
typedef struct MemoizeInstrumentation
{
uint64 cache_hits;
uint64 cache_misses;
uint64 cache_evictions;
uint64 cache_overflows;
uint64 mem_peak;
} MemoizeInstrumentation;
typedef struct SharedMemoizeInfo
{
int num_workers;
MemoizeInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
} SharedMemoizeInfo;
typedef struct MemoizeState
{
ScanState ss;
int mstatus;
int nkeys;
struct memoize_hash *hashtable;
TupleDesc hashkeydesc;
TupleTableSlot *tableslot;
TupleTableSlot *probeslot;
ExprState *cache_eq_expr;
ExprState **param_exprs;
FmgrInfo *hashfunctions;
Oid *collations;
uint64 mem_used;
uint64 mem_limit;
MemoryContext tableContext;
dlist_head lru_list;
struct MemoizeTuple *last_tuple;
struct MemoizeEntry *entry;
bool singlerow;
bool binary_mode;
MemoizeInstrumentation stats;
SharedMemoizeInfo *shared_info;
Bitmapset *keyparamids;
} MemoizeState;
typedef struct PresortedKeyData
{
FmgrInfo flinfo;
FunctionCallInfo fcinfo;
OffsetNumber attno;
} PresortedKeyData;
typedef struct SharedSortInfo
{
int num_workers;
TuplesortInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
} SharedSortInfo;
typedef struct SortState
{
ScanState ss;
bool randomAccess;
bool bounded;
int64 bound;
bool sort_Done;
bool bounded_Done;
int64 bound_Done;
void *tuplesortstate;
bool am_worker;
bool datumSort;
SharedSortInfo *shared_info;
} SortState;
typedef struct IncrementalSortGroupInfo
{
int64 groupCount;
int64 maxDiskSpaceUsed;
int64 totalDiskSpaceUsed;
int64 maxMemorySpaceUsed;
int64 totalMemorySpaceUsed;
bits32 sortMethods;
} IncrementalSortGroupInfo;
typedef struct IncrementalSortInfo
{
IncrementalSortGroupInfo fullsortGroupInfo;
IncrementalSortGroupInfo prefixsortGroupInfo;
} IncrementalSortInfo;
typedef struct SharedIncrementalSortInfo
{
int num_workers;
IncrementalSortInfo sinfo[FLEXIBLE_ARRAY_MEMBER];
} SharedIncrementalSortInfo;
typedef enum
{
INCSORT_LOADFULLSORT,
INCSORT_LOADPREFIXSORT,
INCSORT_READFULLSORT,
INCSORT_READPREFIXSORT,
} IncrementalSortExecutionStatus;
typedef struct IncrementalSortState
{
ScanState ss;
bool bounded;
int64 bound;
bool outerNodeDone;
int64 bound_Done;
IncrementalSortExecutionStatus execution_status;
int64 n_fullsort_remaining;
Tuplesortstate *fullsort_state;
Tuplesortstate *prefixsort_state;
PresortedKeyData *presorted_keys;
IncrementalSortInfo incsort_info;
TupleTableSlot *group_pivot;
TupleTableSlot *transfer_tuple;
bool am_worker;
SharedIncrementalSortInfo *shared_info;
} IncrementalSortState;
typedef struct GroupState
{
ScanState ss;
ExprState *eqfunction;
bool grp_done;
} GroupState;
typedef struct AggregateInstrumentation
{
Size hash_mem_peak;
uint64 hash_disk_used;
int hash_batches_used;
} AggregateInstrumentation;
typedef struct SharedAggInfo
{
int num_workers;
AggregateInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
} SharedAggInfo;
typedef struct AggStatePerAggData *AggStatePerAgg;
typedef struct AggStatePerTransData *AggStatePerTrans;
typedef struct AggStatePerGroupData *AggStatePerGroup;
typedef struct AggStatePerPhaseData *AggStatePerPhase;
typedef struct AggStatePerHashData *AggStatePerHash;
typedef struct AggState
{
ScanState ss;
List *aggs;
int numaggs;
int numtrans;
AggStrategy aggstrategy;
AggSplit aggsplit;
AggStatePerPhase phase;
int numphases;
int current_phase;
AggStatePerAgg peragg;
AggStatePerTrans pertrans;
ExprContext *hashcontext;
ExprContext **aggcontexts;
ExprContext *tmpcontext;
#define FIELDNO_AGGSTATE_CURAGGCONTEXT 14
ExprContext *curaggcontext;
AggStatePerAgg curperagg;
#define FIELDNO_AGGSTATE_CURPERTRANS 16
AggStatePerTrans curpertrans;
bool input_done;
bool agg_done;
int projected_set;
#define FIELDNO_AGGSTATE_CURRENT_SET 20
int current_set;
Bitmapset *grouped_cols;
List *all_grouped_cols;
Bitmapset *colnos_needed;
int max_colno_needed;
bool all_cols_needed;
int maxsets;
AggStatePerPhase phases;
Tuplesortstate *sort_in;
Tuplesortstate *sort_out;
TupleTableSlot *sort_slot;
AggStatePerGroup *pergroups;
HeapTuple grp_firstTuple;
bool table_filled;
int num_hashes;
MemoryContext hash_metacxt;
struct LogicalTapeSet *hash_tapeset;
struct HashAggSpill *hash_spills;
TupleTableSlot *hash_spill_rslot;
TupleTableSlot *hash_spill_wslot;
List *hash_batches;
bool hash_ever_spilled;
bool hash_spill_mode;
Size hash_mem_limit;
uint64 hash_ngroups_limit;
int hash_planned_partitions;
double hashentrysize;
Size hash_mem_peak;
uint64 hash_ngroups_current;
uint64 hash_disk_used;
int hash_batches_used;
AggStatePerHash perhash;
AggStatePerGroup *hash_pergroup;
#define FIELDNO_AGGSTATE_ALL_PERGROUPS 53
AggStatePerGroup *all_pergroups;
SharedAggInfo *shared_info;
} AggState;
typedef struct WindowStatePerFuncData *WindowStatePerFunc;
typedef struct WindowStatePerAggData *WindowStatePerAgg;
typedef enum WindowAggStatus
{
WINDOWAGG_DONE,
WINDOWAGG_RUN,
WINDOWAGG_PASSTHROUGH,
WINDOWAGG_PASSTHROUGH_STRICT,
} WindowAggStatus;
typedef struct WindowAggState
{
ScanState ss;
List *funcs;
int numfuncs;
int numaggs;
WindowStatePerFunc perfunc;
WindowStatePerAgg peragg;
ExprState *partEqfunction;
ExprState *ordEqfunction;
Tuplestorestate *buffer;
int current_ptr;
int framehead_ptr;
int frametail_ptr;
int grouptail_ptr;
int64 spooled_rows;
int64 currentpos;
int64 frameheadpos;
int64 frametailpos;
struct WindowObjectData *agg_winobj;
int64 aggregatedbase;
int64 aggregatedupto;
WindowAggStatus status;
int frameOptions;
ExprState *startOffset;
ExprState *endOffset;
Datum startOffsetValue;
Datum endOffsetValue;
FmgrInfo startInRangeFunc;
FmgrInfo endInRangeFunc;
Oid inRangeColl;
bool inRangeAsc;
bool inRangeNullsFirst;
int64 currentgroup;
int64 frameheadgroup;
int64 frametailgroup;
int64 groupheadpos;
int64 grouptailpos;
MemoryContext partcontext;
MemoryContext aggcontext;
MemoryContext curaggcontext;
ExprContext *tmpcontext;
ExprState *runcondition;
bool use_pass_through;
bool top_window;
bool all_first;
bool partition_spooled;
bool more_partitions;
bool framehead_valid;
bool frametail_valid;
bool grouptail_valid;
TupleTableSlot *first_part_slot;
TupleTableSlot *framehead_slot;
TupleTableSlot *frametail_slot;
TupleTableSlot *agg_row_slot;
TupleTableSlot *temp_slot_1;
TupleTableSlot *temp_slot_2;
} WindowAggState;
typedef struct UniqueState
{
PlanState ps;
ExprState *eqfunction;
} UniqueState;
typedef struct GatherState
{
PlanState ps;
bool initialized;
bool need_to_scan_locally;
int64 tuples_needed;
TupleTableSlot *funnel_slot;
struct ParallelExecutorInfo *pei;
int nworkers_launched;
int nreaders;
int nextreader;
struct TupleQueueReader **reader;
} GatherState;
struct GMReaderTupleBuffer;
typedef struct GatherMergeState
{
PlanState ps;
bool initialized;
bool gm_initialized;
bool need_to_scan_locally;
int64 tuples_needed;
TupleDesc tupDesc;
int gm_nkeys;
SortSupport gm_sortkeys;
struct ParallelExecutorInfo *pei;
int nworkers_launched;
int nreaders;
TupleTableSlot **gm_slots;
struct TupleQueueReader **reader;
struct GMReaderTupleBuffer *gm_tuple_buffers;
struct binaryheap *gm_heap;
} GatherMergeState;
typedef struct HashInstrumentation
{
int nbuckets;
int nbuckets_original;
int nbatch;
int nbatch_original;
Size space_peak;
} HashInstrumentation;
typedef struct SharedHashInfo
{
int num_workers;
HashInstrumentation hinstrument[FLEXIBLE_ARRAY_MEMBER];
} SharedHashInfo;
typedef struct HashState
{
PlanState ps;
HashJoinTable hashtable;
List *hashkeys;
SharedHashInfo *shared_info;
HashInstrumentation *hinstrument;
struct ParallelHashJoinState *parallel_state;
} HashState;
typedef struct SetOpStatePerGroupData *SetOpStatePerGroup;
typedef struct SetOpState
{
PlanState ps;
ExprState *eqfunction;
Oid *eqfuncoids;
FmgrInfo *hashfunctions;
bool setop_done;
long numOutput;
SetOpStatePerGroup pergroup;
HeapTuple grp_firstTuple;
TupleHashTable hashtable;
MemoryContext tableContext;
bool table_filled;
TupleHashIterator hashiter;
} SetOpState;
typedef struct LockRowsState
{
PlanState ps;
List *lr_arowMarks;
EPQState lr_epqstate;
} LockRowsState;
typedef enum
{
LIMIT_INITIAL,
LIMIT_RESCAN,
LIMIT_EMPTY,
LIMIT_INWINDOW,
LIMIT_WINDOWEND_TIES,
LIMIT_SUBPLANEOF,
LIMIT_WINDOWEND,
LIMIT_WINDOWSTART,
} LimitStateCond;
typedef struct LimitState
{
PlanState ps;
ExprState *limitOffset;
ExprState *limitCount;
LimitOption limitOption;
int64 offset;
int64 count;
bool noCount;
LimitStateCond lstate;
int64 position;
TupleTableSlot *subSlot;
ExprState *eqfunction;
TupleTableSlot *last_slot;
} LimitState;
#endif