/* Bits in ExprState->flags (see also execExpr.h for private flag bits): */ /* expression is for use with ExecQual() */ #define EEO_FLAG_IS_QUAL (1 << 0) /* expression refers to OLD table columns */ #define EEO_FLAG_HAS_OLD (1 << 1) /* expression refers to NEW table columns */ #define EEO_FLAG_HAS_NEW (1 << 2) /* OLD table row is NULL in RETURNING list */ #define EEO_FLAG_OLD_IS_NULL (1 << 3) /* NEW table row is NULL in RETURNING list */ #define EEO_FLAG_NEW_IS_NULL (1 << 4)
typedefstruct ExprState
{
NodeTag type;
#define FIELDNO_EXPRSTATE_FLAGS 1
uint8 flags; /* bitmask of EEO_FLAG_* bits, see above */
/* ---------------- *IndexInfoinformation * *thisstructholdstheinformationneededtoconstructnewindex *entriesforaparticularindex.Usedforbothindex_buildand *retailcreationofindexentries. * *NumIndexAttrstotalnumberofcolumnsinthisindex *NumIndexKeyAttrsnumberofkeycolumnsinindex *IndexAttrNumbersunderlying-relattributenumbersusedaskeys *(zeroesindicateexpressions).Italsocontains *infoaboutincludedcolumns. *Expressionsexprtreesforexpressionentries,orNILifnone *ExpressionsStateexecstateforexpressions,orNILifnone *Predicatepartial-indexpredicate,orNILifnone *PredicateStateexecstateforpredicate,orNILifnone *ExclusionOpsPer-columnexclusionoperators,orNULLifnone *ExclusionProcsUnderlyingfunctionOIDsforExclusionOps *ExclusionStratsOpclassstrategynumbersforExclusionOps *UniqueOpsThesearelikeExclusion*,butforuniqueindexes *UniqueProcs *UniqueStrats *Uniqueisitauniqueindex? *NullsNotDistinctisNULLSNOTDISTINCT? *ReadyForInsertsisitvalidforinserts? *CheckedUnchangedIndexUnchangedstatusdeterminedyet? *IndexUnchangedaminserthint,cachedforretailinserts *Concurrentarewedoingaconcurrentindexbuild? *BrokenHotChaindidwedetectanybrokenHOTchains? *WithoutOverlapsisitaWITHOUTOVERLAPSindex? *Summarizingisitasummarizingindex? *ParallelWorkers#ofworkersrequested(excludesleader) *AmOidofindexAM *AmCacheprivatecacheareaforindexAM *ContextmemorycontextholdingthisIndexInfo * *ii_Concurrent,ii_BrokenHotChain,andii_ParallelWorkersareusedonly *duringindexbuild;they'reconventionallyzeroedotherwise. *----------------
*/ typedefstruct IndexInfo
{
NodeTag type; int ii_NumIndexAttrs; /* total number of columns in index */ int ii_NumIndexKeyAttrs; /* number of key columns in index */
AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS];
List *ii_Expressions; /* list of Expr */
List *ii_ExpressionsState; /* list of ExprState */
List *ii_Predicate; /* list of Expr */
ExprState *ii_PredicateState;
Oid *ii_ExclusionOps; /* array with one entry per column */
Oid *ii_ExclusionProcs; /* array with one entry per column */
uint16 *ii_ExclusionStrats; /* array with one entry per column */
Oid *ii_UniqueOps; /* array with one entry per column */
Oid *ii_UniqueProcs; /* array with one entry per column */
uint16 *ii_UniqueStrats; /* array with one entry per column */ bool ii_Unique; bool ii_NullsNotDistinct; bool ii_ReadyForInserts; bool ii_CheckedUnchanged; bool ii_IndexUnchanged; bool ii_Concurrent; bool ii_BrokenHotChain; bool ii_Summarizing; bool ii_WithoutOverlaps; int ii_ParallelWorkers;
Oid ii_Am; void *ii_AmCache;
MemoryContext ii_Context;
} IndexInfo;
/* Tuples that Var nodes in expression may refer to */ #define FIELDNO_EXPRCONTEXT_SCANTUPLE 1
TupleTableSlot *ecxt_scantuple; #define FIELDNO_EXPRCONTEXT_INNERTUPLE 2
TupleTableSlot *ecxt_innertuple; #define FIELDNO_EXPRCONTEXT_OUTERTUPLE 3
TupleTableSlot *ecxt_outertuple;
/* Memory contexts for expression evaluation --- see notes above */
MemoryContext ecxt_per_query_memory;
MemoryContext ecxt_per_tuple_memory;
/* Values to substitute for Param nodes in expression */
ParamExecData *ecxt_param_exec_vals; /* for PARAM_EXEC params */
ParamListInfo ecxt_param_list_info; /* for other param types */
/* *ValuestosubstituteforAggrefnodesintheexpressionsofanAgg *node,orforWindowFuncnodeswithinaWindowAggnode.
*/ #define FIELDNO_EXPRCONTEXT_AGGVALUES 8
Datum *ecxt_aggvalues; /* precomputed values for aggs/windowfuncs */ #define FIELDNO_EXPRCONTEXT_AGGNULLS 9 bool *ecxt_aggnulls; /* null flags for aggs/windowfuncs */
/* Value to substitute for CaseTestExpr nodes in expression */ #define FIELDNO_EXPRCONTEXT_CASEDATUM 10
Datum caseValue_datum; #define FIELDNO_EXPRCONTEXT_CASENULL 11 bool caseValue_isNull;
/* Value to substitute for CoerceToDomainValue nodes in expression */ #define FIELDNO_EXPRCONTEXT_DOMAINDATUM 12
Datum domainValue_datum; #define FIELDNO_EXPRCONTEXT_DOMAINNULL 13 bool domainValue_isNull;
/* Tuples that OLD/NEW Var nodes in RETURNING may refer to */ #define FIELDNO_EXPRCONTEXT_OLDTUPLE 14
TupleTableSlot *ecxt_oldtuple; #define FIELDNO_EXPRCONTEXT_NEWTUPLE 15
TupleTableSlot *ecxt_newtuple;
/* Link to containing EState (NULL if a standalone ExprContext) */ struct EState *ecxt_estate;
/* Functions to call back when ExprContext is shut down or rescanned */
ExprContext_CB *ecxt_callbacks;
} ExprContext;
/* *Set-resultstatususedwhenevaluatingfunctionspotentiallyreturninga *set.
*/ typedefenum
{
ExprSingleResult, /* expression does not return a set */
ExprMultipleResult, /* this result is an element of a set */
ExprEndResult, /* there are no more elements in the set */
} ExprDoneCond;
/* *Returnmodesforfunctionsreturningsets.Notevaluesmustbechosen *asseparatebitssothatabitmaskcanbeformedtoindicatesupported *modes.SFRM_Materialize_RandomandSFRM_Materialize_Preferredare *auxiliaryflagsaboutSFRM_Materializemode,ratherthanseparatemodes.
*/ typedefenum
{
SFRM_ValuePerCall = 0x01, /* one value returned per call */
SFRM_Materialize = 0x02, /* result set instantiated in Tuplestore */
SFRM_Materialize_Random = 0x04, /* Tuplestore needs randomAccess */
SFRM_Materialize_Preferred = 0x08, /* caller prefers Tuplestore */
} SetFunctionReturnMode;
/* *Whencallingafunctionthatmightreturnaset(multiplerows), *anodeofthistypeispassedasfcinfo->resultinfotoallow *returnstatustobepassedback.Afunctionreturningsetshould *raiseanerrorifnosuchresultinfoisprovided.
*/ typedefstruct ReturnSetInfo
{
NodeTag type; /* values set by caller: */
ExprContext *econtext; /* context function is being called in */
TupleDesc expectedDesc; /* tuple descriptor expected by caller */ int allowedModes; /* bitmask: return modes caller can handle */ /* result status from function (but pre-initialized by caller): */
SetFunctionReturnMode returnMode; /* actual return mode */
ExprDoneCond isDone; /* status for ValuePerCall mode */ /* fields filled by function in Materialize return mode: */
Tuplestorestate *setResult; /* holds the complete returned tuple set */
TupleDesc setDesc; /* actual descriptor for returned tuples */
} ReturnSetInfo;
TupleTableSlot *oc_Existing; /* slot to store existing target tuple in */
TupleTableSlot *oc_ProjSlot; /* CONFLICT ... SET ... projection target */
ProjectionInfo *oc_ProjInfo; /* for ON CONFLICT DO UPDATE SET */
ExprState *oc_WhereClause; /* state for the WHERE clause */
} OnConflictSetState;
/* For UPDATE, attnums of generated columns to be computed */
Bitmapset *ri_extraUpdatedCols; /* true if the above has been computed */ bool ri_extraUpdatedCols_valid;
/* Projection to generate new tuple in an INSERT/UPDATE */
ProjectionInfo *ri_projectNew; /* Slot to hold that tuple */
TupleTableSlot *ri_newTupleSlot; /* Slot to hold the old tuple being updated */
TupleTableSlot *ri_oldTupleSlot; /* Have the projection and the slots above been initialized? */ bool ri_projectNewInfoValid;
/* updates do LockTuple() before oldtup read; see README.tuplock */ bool ri_needLockTagTuple;
/* triggers to be fired, if any */
TriggerDesc *ri_TrigDesc;
/* cached lookup info for trigger functions */
FmgrInfo *ri_TrigFunctions;
/* array of trigger WHEN expr states */
ExprState **ri_TrigWhenExprs;
/* optional runtime measurements for triggers */
Instrumentation *ri_TrigInstrument;
/* On-demand created slots for triggers / returning processing */
TupleTableSlot *ri_ReturningSlot; /* for trigger output tuples */
TupleTableSlot *ri_TrigOldSlot; /* for a trigger's old tuple */
TupleTableSlot *ri_TrigNewSlot; /* for a trigger's new tuple */
TupleTableSlot *ri_AllNullSlot; /* for RETURNING OLD/NEW */
/* available to save private state of FDW */ void *ri_FdwState;
/* true when modifying foreign table directly */ bool ri_usesFdwDirectModify;
/* batch insert stuff */ int ri_NumSlots; /* number of slots in the array */ int ri_NumSlotsInitialized; /* number of initialized slots */ int ri_BatchSize; /* max slots inserted in a single batch */
TupleTableSlot **ri_Slots; /* input tuples for batch insert */
TupleTableSlot **ri_PlanSlots;
/* list of WithCheckOption's to be checked */
List *ri_WithCheckOptions;
/* list of WithCheckOption expr states */
List *ri_WithCheckOptionExprs;
/* array of expr states for checking check constraints */
ExprState **ri_CheckConstraintExprs;
/* for use by copyfrom.c when performing multi-inserts */ struct CopyMultiInsertBuffer *ri_CopyMultiInsertBuffer;
/* *Usedwhenaleafpartitionisinvolvedinacross-partitionupdateof *oneofitsancestors;seeExecCrossPartitionUpdateForeignKey().
*/
List *ri_ancestorResultRels;
} ResultRelInfo;
/* ---------------- *AsyncRequest * *Stateforanasynchronoustuplerequest. *----------------
*/ typedefstruct AsyncRequest
{ struct PlanState *requestor; /* Node that wants a tuple */ struct PlanState *requestee; /* Node from which a tuple is wanted */ int request_index; /* Scratch space for requestor */ bool callback_pending; /* Callback is needed */ bool request_complete; /* Request complete, result valid */
TupleTableSlot *result; /* Result (NULL or an empty slot if no more
* tuples) */
} AsyncRequest;
/* Basic state for all query types: */
ScanDirection es_direction; /* current scan direction */
Snapshot es_snapshot; /* time qual to use */
Snapshot es_crosscheck_snapshot; /* crosscheck time qual for RI */
List *es_range_table; /* List of RangeTblEntry */
Index es_range_table_size; /* size of the range table arrays */
Relation *es_relations; /* Array of per-range-table-entry Relation
* pointers, or NULL if not yet opened */ struct ExecRowMark **es_rowmarks; /* Array of per-range-table-entry
* ExecRowMarks, or NULL if none */
List *es_rteperminfos; /* List of RTEPermissionInfo */
PlannedStmt *es_plannedstmt; /* link to top of plan tree */
List *es_part_prune_infos; /* List of PartitionPruneInfo */
List *es_part_prune_states; /* List of PartitionPruneState */
List *es_part_prune_results; /* List of Bitmapset */
Bitmapset *es_unpruned_relids; /* PlannedStmt.unprunableRelids + RT *indexesofleafpartitionsthatsurvive *initialpruning;see
* ExecDoInitialPruning() */ constchar *es_sourceText; /* Source text from QueryDesc */
JunkFilter *es_junkFilter; /* top-level junk filter, if any */
/* If query can insert/delete tuples, the command ID to mark them with */
CommandId es_output_cid;
/* Info about target table(s) for insert/update/delete queries: */
ResultRelInfo **es_result_relations; /* Array of per-range-table-entry *ResultRelInfopointers,orNULL
* if not a target table */
List *es_opened_result_relations; /* List of non-NULL entries in *es_result_relationsinno
* specific order */
PartitionDirectory es_partition_directory; /* for PartitionDesc lookup */
/* *ThefollowinglistcontainsResultRelInfoscreatedbythetuplerouting *codeforpartitionsthataren'tfoundinthees_result_relationsarray.
*/
List *es_tuple_routing_result_relations;
/* Stuff used for firing triggers: */
List *es_trig_target_relations; /* trigger-only ResultRelInfos */
/* Parameter info: */
ParamListInfo es_param_list_info; /* values of external params */
ParamExecData *es_param_exec_vals; /* values of internal params */
/* Other working state: */
MemoryContext es_query_cxt; /* per-query context in which EState lives */
List *es_tupleTable; /* List of TupleTableSlots */
uint64 es_processed; /* # of tuples processed during one
* ExecutorRun() call. */
uint64 es_total_processed; /* total # of tuples aggregated across all
* ExecutorRun() calls. */
int es_top_eflags; /* eflags passed to ExecutorStart */ int es_instrument; /* OR of InstrumentOption flags */ bool es_finished; /* true when ExecutorFinish is done */
List *es_exprcontexts; /* List of ExprContexts within EState */
List *es_subplanstates; /* List of PlanState for SubPlans */
List *es_auxmodifytables; /* List of secondary ModifyTableStates */
/* *ListsofResultRelInfosforforeigntablesonwhichbatch-insertsare *tobeexecutedandowningModifyTableStates,storedinthesameorder.
*/
List *es_insert_pending_result_relations;
List *es_insert_pending_modifytables;
} EState;
/* *ExecRowMark- *runtimerepresentationofFOR[KEY]UPDATE/SHAREclauses * *WhendoingUPDATE/DELETE/MERGE/SELECTFOR[KEY]UPDATE/SHARE,wewillhave *anExecRowMarkforeachnon-targetrelationinthequery(exceptinheritance *parentRTEs,whichcanbeignoredatruntime).Virtualrelationssuchas *subqueries-in-FROMwillhaveanExecRowMarkwithrelation==NULL.See *PlanRowMarkfordetailsaboutmostofthefields.Inadditiontofields *directlyderivedfromPlanRowMark,westoreanactivityflag(todenote *inactivechildrenofinheritancetrees),curCtid,whichisusedbythe *WHERECURRENTOFcode,andermExtra,whichisavailableforusebytheplan *nodethatsourcestherelation(e.g.,foraforeigntabletheFDWcanuse *ermExtratoholdinformation). * *EState->es_rowmarksisanarrayofthesestructs,indexedbyRTindex, *withNULLsforirrelevantRTindexes.es_rowmarksitselfisNULLif *therearenorowmarks.
*/ typedefstruct ExecRowMark
{
Relation relation; /* opened and suitably locked relation */
Oid relid; /* its OID (or InvalidOid, if subquery) */
Index rti; /* its range table index */
Index prti; /* parent range table index, if child */
Index rowmarkId; /* unique identifier for resjunk columns */
RowMarkType markType; /* see enum in nodes/plannodes.h */
LockClauseStrength strength; /* LockingClause's strength, or LCS_NONE */
LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */ bool ermActive; /* is this mark relevant for current tuple? */
ItemPointerData curCtid; /* ctid of currently locked tuple, if any */ void *ermExtra; /* available for use by relation source node */
} ExecRowMark;
/* *ExecAuxRowMark- *additionalruntimerepresentationofFOR[KEY]UPDATE/SHAREclauses * *EachLockRowsandModifyTablenodekeepsalistoftherowmarksitneedsto *dealwith.Inadditiontoapointertotherelatedentryines_rowmarks, *thisstructcarriesthecolumnnumber(s)oftheresjunkcolumnsassociated *withtherowmark(seecommentsforPlanRowMarkformoredetail).
*/ typedefstruct ExecAuxRowMark
{
ExecRowMark *rowmark; /* related entry in es_rowmarks */
AttrNumber ctidAttNo; /* resno of ctid junk attribute, if any */
AttrNumber toidAttNo; /* resno of tableoid junk attribute, if any */
AttrNumber wholeAttNo; /* resno of whole-row junk attribute, if any */
} ExecAuxRowMark;
typedefstruct TupleHashEntryData
{
MinimalTuple firstTuple; /* copy of first tuple in this group */
uint32 status; /* hash status */
uint32 hash; /* hash value (cached) */
} TupleHashEntryData;
/* ---------------- *WindowFuncExprStatenode *----------------
*/ typedefstruct WindowFuncExprState
{
NodeTag type;
WindowFunc *wfunc; /* expression plan node */
List *args; /* ExprStates for argument expressions */
ExprState *aggfilter; /* FILTER expression */ int wfuncno; /* ID number for wfunc within its plan node */
} WindowFuncExprState;
/* ---------------- *SetExprStatenode * *Stateforevaluatingapotentiallyset-returningexpression(likeFuncExpr *orOpExpr).Insomecases,likesomeoftheexpressionsinROWSFROM(...) *theexpressionmightnotbeaSRF,butnonethelessitusesthesame *machineryasSRFs;itwillbetreatedasaSRFreturningasinglerow. *----------------
*/ typedefstruct SetExprState
{
NodeTag type;
Expr *expr; /* expression plan node */
List *args; /* ExprStates for argument expressions */
/* ---------------- *SubPlanStatenode *----------------
*/ typedefstruct SubPlanState
{
NodeTag type;
SubPlan *subplan; /* expression plan node */ struct PlanState *planstate; /* subselect plan's state tree */ struct PlanState *parent; /* parent plan node's state tree */
ExprState *testexpr; /* state of combining expression */
HeapTuple curTuple; /* copy of most recent tuple from subplan */
Datum curArray; /* most recent array from ARRAY() subplan */ /* these are used when hashing the subselect's output: */
TupleDesc descRight; /* subselect desc after projection */
ProjectionInfo *projLeft; /* for projecting lefthand exprs */
ProjectionInfo *projRight; /* for projecting subselect output */
TupleHashTable hashtable; /* hash table for no-nulls subselect rows */
TupleHashTable hashnulls; /* hash table for rows with null(s) */ bool havehashrows; /* true if hashtable is not empty */ bool havenullrows; /* true if hashnulls is not empty */
MemoryContext hashtablecxt; /* memory context containing hash tables */
MemoryContext hashtempcxt; /* temp memory context for hash tables */
ExprContext *innerecontext; /* econtext for computing inner tuples */ int numCols; /* number of columns being hashed */ /* each of the remaining fields is an array of length numCols: */
AttrNumber *keyColIdx; /* control data for hash tables */
Oid *tab_eq_funcoids; /* equality func oids for table
* datatype(s) */
Oid *tab_collations; /* collations for hash and comparison */
FmgrInfo *tab_hash_funcs; /* hash functions for table datatype(s) */
ExprState *lhs_hash_expr; /* hash expr for lefthand datatype(s) */
FmgrInfo *cur_eq_funcs; /* equality functions for LHS vs. table */
ExprState *cur_eq_comp; /* equality comparator for LHS vs. table */
} SubPlanState;
/* Macros for inline access to certain instrumentation counters */ #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)
/* *EPQStateisstateforexecutinganEvalPlanQualrecheckonacandidate *tuplese.g.inModifyTableorLockRows. * *ToexecuteEPQaseparateEStateiscreated(storedin->recheckestate), *whichsharessomeresources,liketherangetable,withthemainquery's *EState(storedin->parentestate).The(sub-)treeoftheplanthatneedsto *berechecked(in->plan),isseparatelyinitialized(into *->recheckplanstate),butsharesplannodeswiththecorrespondingnodesin *themainquery.Thescannodesinthatseparateexecutortreearechanged *toreturnonlythecurrenttupleofinterestfortherespective *table.Thosetuplesareeitherprovidedbythecaller(using *EvalPlanQualSlot),and/orfoundusingtherowmarkmechanism(non-locking *rowmarksbytheEPQmachineryitself,lockingonesbythecaller). * *WhiletheplantobecheckedmaybechangedusingEvalPlanQualSetPlan(), *allsuchplansneedtosharethesameEState.
*/ typedefstruct EPQState
{ /* These are initialized by EvalPlanQualInit() and do not change later: */
EState *parentestate; /* main query's EState */ int epqParam; /* ID of Param to force scan node re-eval */
List *resultRelations; /* integer list of RT indexes, or NIL */
/* *relsubs_slot[scanrelid-1]holdstheEPQtesttupletobereturnedby *thescannodeforthescanrelid'thRTindex,inplaceofperformingan *actualtablescan.CallersshoulduseEvalPlanQualSlot()tofetch *theseslots.
*/
List *tuple_table; /* tuple table for relsubs_slot */
TupleTableSlot **relsubs_slot;
PlanState *recheckplanstate; /* EPQ specific exec nodes, for ->plan */
} EPQState;
/* ---------------- *ResultStateinformation *----------------
*/ typedefstruct ResultState
{
PlanState ps; /* its first field is NodeTag */
ExprState *resconstantqual; bool rs_done; /* are we done? */ bool rs_checkqual; /* do we need to check the qual? */
} ResultState;
/* ---------------- *ProjectSetStateinformation * *Note:atleastoneofthe"elems"willbeaSetExprState;therestare *regularExprStates. *----------------
*/ typedefstruct ProjectSetState
{
PlanState ps; /* its first field is NodeTag */
Node **elems; /* array of expression states */
ExprDoneCond *elemdone; /* array of per-SRF is-done states */ int nelems; /* length of elemdone[] array */ bool pending_srf_tuples; /* still evaluating srfs in tlist? */
MemoryContext argcontext; /* context for SRF arguments */
} ProjectSetState;
/* ---------------- *ModifyTableStateinformation *----------------
*/ typedefstruct ModifyTableState
{
PlanState ps; /* its first field is NodeTag */
CmdType operation; /* INSERT, UPDATE, DELETE, or MERGE */ bool canSetTag; /* do we set the command tag/es_processed? */ bool mt_done; /* are we done? */ int mt_nrels; /* number of entries in resultRelInfo[] */
ResultRelInfo *resultRelInfo; /* info about target relation(s) */
EPQState mt_epqstate; /* for evaluating EvalPlanQual rechecks */ bool fireBSTriggers; /* do we need to fire stmt triggers? */
/* *ThesefieldsareusedforinheritedUPDATEandDELETE,totrackwhich *targetrelationagiventupleisfrom.Iftherearealotoftarget *relations,weuseahashtabletotranslatetableOIDsto *resultRelInfo[]indexes;otherwisemt_resultOidHashisNULL.
*/ int mt_resultOidAttno; /* resno of "tableoid" junk attr */
Oid mt_lastResultOid; /* last-seen value of tableoid */ int mt_lastResultIndex; /* corresponding index in resultRelInfo[] */
HTAB *mt_resultOidHash; /* optional hash table to speed lookups */
/* *ListsofvalidupdateColnosLists,mergeActionLists,and *mergeJoinConditions.Thesecontainonlyentriesforunpruned *relations,filteredfromthecorrespondinglistsinModifyTable.
*/
List *mt_updateColnosLists;
List *mt_mergeActionLists;
List *mt_mergeJoinConditions;
} ModifyTableState;
struct AppendState
{
PlanState ps; /* its first field is NodeTag */
PlanState **appendplans; /* array of PlanStates for my inputs */ int as_nplans; int as_whichplan; bool as_begun; /* false means need to initialize */
Bitmapset *as_asyncplans; /* asynchronous plans indexes */ int as_nasyncplans; /* # of asynchronous plans */
AsyncRequest **as_asyncrequests; /* array of AsyncRequests */
TupleTableSlot **as_asyncresults; /* unreturned results of async plans */ int as_nasyncresults; /* # of valid entries in as_asyncresults */ bool as_syncdone; /* true if all synchronous plans done in
* asynchronous mode, else false */ int as_nasyncremain; /* # of remaining asynchronous plans */
Bitmapset *as_needrequest; /* asynchronous plans needing a new request */ struct WaitEventSet *as_eventset; /* WaitEventSet used to configure file
* descriptor wait events */ int as_first_partial_plan; /* Index of 'appendplans' containing
* the first partial plan */
ParallelAppendState *as_pstate; /* parallel coordination info */
Size pstate_len; /* size of parallel coordination info */ struct PartitionPruneState *as_prune_state; bool as_valid_subplans_identified; /* is as_valid_subplans valid? */
Bitmapset *as_valid_subplans;
Bitmapset *as_valid_asyncplans; /* valid asynchronous plans indexes */ bool (*choose_next_subplan) (AppendState *);
};
/* ---------------- *MergeAppendStateinformation * *nplanshowmanyplansareinthearray *nkeysnumberofsortkeycolumns *sortkeyssortkeysinSortSupportrepresentation *slotscurrentoutputtupleofeachsubplan *heapheapofactivetuples *initializedtrueifwehavefetchedfirsttuplefromeachsubplan *prune_statedetailsrequiredtoallowpartitionstobe *eliminatedfromthescan,orNULLifnotpossible. *valid_subplansforruntimepruning,validmergeplansindexesto *scan. *----------------
*/ typedefstruct MergeAppendState
{
PlanState ps; /* its first field is NodeTag */
PlanState **mergeplans; /* array of PlanStates for my inputs */ int ms_nplans; int ms_nkeys;
SortSupport ms_sortkeys; /* array of length ms_nkeys */
TupleTableSlot **ms_slots; /* array of length ms_nplans */ struct binaryheap *ms_heap; /* binary heap of slot indices */ bool ms_initialized; /* are subplans started? */ struct PartitionPruneState *ms_prune_state;
Bitmapset *ms_valid_subplans;
} MergeAppendState;
/* ---------------- *RecursiveUnionStateinformation * *RecursiveUnionStateisusedforperformingarecursiveunion. * *recursingTwhenwe'redonescanningthenon-recursiveterm *intermediate_emptyTifintermediate_tableiscurrentlyempty *working_tableworkingtable(tobescannedbyrecursiveterm) *intermediate_tablecurrentrecursiveoutput(nextgenerationofWT) *----------------
*/ typedefstruct RecursiveUnionState
{
PlanState ps; /* its first field is NodeTag */ bool recursing; bool intermediate_empty;
Tuplestorestate *working_table;
Tuplestorestate *intermediate_table; /* Remaining fields are unused in UNION ALL case */
Oid *eqfuncoids; /* per-grouping-field equality fns */
FmgrInfo *hashfunctions; /* per-grouping-field hash fns */
MemoryContext tempContext; /* short-term context for comparisons */
TupleHashTable hashtable; /* hash table for tuples already seen */
MemoryContext tableContext; /* memory context containing hash table */
} RecursiveUnionState;
/* ---------------- *BitmapAndStateinformation *----------------
*/ typedefstruct BitmapAndState
{
PlanState ps; /* its first field is NodeTag */
PlanState **bitmapplans; /* array of PlanStates for my inputs */ int nplans; /* number of input plans */
} BitmapAndState;
/* ---------------- *BitmapOrStateinformation *----------------
*/ typedefstruct BitmapOrState
{
PlanState ps; /* its first field is NodeTag */
PlanState **bitmapplans; /* array of PlanStates for my inputs */ int nplans; /* number of input plans */
} BitmapOrState;
/* ---------------- *ScanStateinformation * *ScanStateextendsPlanStatefornodetypesthatrepresent *scansofanunderlyingrelation.Itcanalsobeusedfornodes *thatscantheoutputofanunderlyingplannode---inthatcase, *onlyScanTupleSlotisactuallyuseful,anditreferstothetuple *retrievedfromthesubplan. * *currentRelationrelationbeingscanned(NULLifnone) *currentScanDesccurrentscandescriptorforscan(NULLifnone) *ScanTupleSlotpointertoslotintupletableholdingscantuple *----------------
*/ typedefstruct ScanState
{
PlanState ps; /* its first field is NodeTag */
Relation ss_currentRelation; struct TableScanDescData *ss_currentScanDesc;
TupleTableSlot *ss_ScanTupleSlot;
} ScanState;
/* ---------------- *SeqScanStateinformation *----------------
*/ typedefstruct SeqScanState
{
ScanState ss; /* its first field is NodeTag */
Size pscan_len; /* size of parallel heap scan descriptor */
} SeqScanState;
/* ---------------- *SampleScanStateinformation *----------------
*/ typedefstruct SampleScanState
{
ScanState ss;
List *args; /* expr states for TABLESAMPLE params */
ExprState *repeatable; /* expr state for REPEATABLE expr */ /* use struct pointer to avoid including tsmapi.h here */ struct TsmRoutine *tsmroutine; /* descriptor for tablesample method */ void *tsm_state; /* tablesample method can keep state here */ bool use_bulkread; /* use bulkread buffer access strategy? */ bool use_pagemode; /* use page-at-a-time visibility checking? */ bool begun; /* false means need to call BeginSampleScan */
uint32 seed; /* random seed */
int64 donetuples; /* number of tuples already returned */ bool haveblock; /* has a block for sampling been determined */ bool done; /* exhausted all tuples? */
} SampleScanState;
/* *Thesestructsstoreinformationaboutindexqualsthatdon'thavesimple *constantright-handsides.SeecommentsforExecIndexBuildScanKeys() *fordiscussion.
*/ typedefstruct
{ struct ScanKeyData *scan_key; /* scankey to put value into */
ExprState *key_expr; /* expr to evaluate to get value */ bool key_toastable; /* is expr's result a toastable datatype? */
} IndexRuntimeKeyInfo;
typedefstruct
{ struct ScanKeyData *scan_key; /* scankey to put value into */
ExprState *array_expr; /* expr to evaluate to get array value */ int next_elem; /* next array element to use */ int num_elems; /* number of elems in current array value */
Datum *elem_values; /* array of num_elems Datums */ bool *elem_nulls; /* array of num_elems is-null flags */
} IndexArrayKeyInfo;
/* ---------------- *IndexScanStateinformation * *indexqualorigexecutionstateforindexqualorigexpressions *indexorderbyorigexecutionstateforindexorderbyorigexpressions *ScanKeysSkeystructuresforindexquals *NumScanKeysnumberofScanKeys *OrderByKeysSkeystructuresforindexorderingoperators *NumOrderByKeysnumberofOrderByKeys *RuntimeKeysinfoaboutSkeysthatmustbeevaluatedatruntime *NumRuntimeKeysnumberofRuntimeKeys *RuntimeKeysReadytrueifruntimeSkeyshavebeencomputed *RuntimeContextexprcontextforevalingruntimeSkeys *RelationDescindexrelationdescriptor *ScanDescindexscandescriptor *Instrumentlocalindexscaninstrumentation *SharedInfoparallelworkerinstrumentation(noleaderentry) * *ReorderQueuetuplesthatneedreorderingduetore-check *ReachedEndhavewefetchedalltuplesfromindexalready? *OrderByValuesvaluesofORDERBYexprsoflastfetchedtuple *OrderByNullsnullflagsforOrderByValues *SortSupportforreorderingORDERBYexprs *OrderByTypByValsisthedatatypeoforderbyexpressionpass-by-value? *OrderByTypLenstyplensofthedatatypesoforderbyexpressions *PscanLensizeofparallelindexscandescriptor *----------------
*/ typedefstruct IndexScanState
{
ScanState ss; /* its first field is NodeTag */
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;
IndexScanInstrumentation iss_Instrument;
SharedIndexScanInstrumentation *iss_SharedInfo;
/* These are needed for re-checking ORDER BY expr ordering */
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;
/* ---------------- *IndexOnlyScanStateinformation * *recheckqualexecutionstateforrecheckqualexpressions *ScanKeysSkeystructuresforindexquals *NumScanKeysnumberofScanKeys *OrderByKeysSkeystructuresforindexorderingoperators *NumOrderByKeysnumberofOrderByKeys *RuntimeKeysinfoaboutSkeysthatmustbeevaluatedatruntime *NumRuntimeKeysnumberofRuntimeKeys *RuntimeKeysReadytrueifruntimeSkeyshavebeencomputed *RuntimeContextexprcontextforevalingruntimeSkeys *RelationDescindexrelationdescriptor *ScanDescindexscandescriptor *Instrumentlocalindexscaninstrumentation *SharedInfoparallelworkerinstrumentation(noleaderentry) *TableSlotslotforholdingtuplesfetchedfromthetable *VMBufferbufferinuseforvisibilitymaptesting,ifany *PscanLensizeofparallelindex-onlyscandescriptor *NameCStringAttNumsattnumsofnametypedcolumnstopadtoNAMEDATALEN *NameCStringCountnumberofelementsintheNameCStringAttNumsarray *----------------
*/ typedefstruct IndexOnlyScanState
{
ScanState ss; /* its first field is NodeTag */
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;
IndexScanInstrumentation ioss_Instrument;
SharedIndexScanInstrumentation *ioss_SharedInfo;
TupleTableSlot *ioss_TableSlot;
Buffer ioss_VMBuffer;
Size ioss_PscanLen;
AttrNumber *ioss_NameCStringAttNums; int ioss_NameCStringCount;
} IndexOnlyScanState;
/* ---------------- *BitmapIndexScanStateinformation * *resultbitmaptoreturnoutputinto,orNULL *ScanKeysSkeystructuresforindexquals *NumScanKeysnumberofScanKeys *RuntimeKeysinfoaboutSkeysthatmustbeevaluatedatruntime *NumRuntimeKeysnumberofRuntimeKeys *ArrayKeysinfoaboutSkeysthatcomefromScalarArrayOpExprs *NumArrayKeysnumberofArrayKeys *RuntimeKeysReadytrueifruntimeSkeyshavebeencomputed *RuntimeContextexprcontextforevalingruntimeSkeys *RelationDescindexrelationdescriptor *ScanDescindexscandescriptor *Instrumentlocalindexscaninstrumentation *SharedInfoparallelworkerinstrumentation(noleaderentry) *----------------
*/ typedefstruct BitmapIndexScanState
{
ScanState ss; /* its first field is NodeTag */
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;
IndexScanInstrumentation biss_Instrument;
SharedIndexScanInstrumentation *biss_SharedInfo;
} BitmapIndexScanState;
/* ---------------- *TidScanStateinformation * *tidexprslistofTidExprstructs(seenodeTidscan.c) *isCurrentOfscanhasaCurrentOfExprqual *NumTidsnumberoftidsinthisscan *TidPtrindexofcurrentlyfetchedtid *TidListevaluateditempointers(arrayofsizeNumTids) *----------------
*/ typedefstruct TidScanState
{
ScanState ss; /* its first field is NodeTag */
List *tss_tidexprs; bool tss_isCurrentOf; int tss_NumTids; int tss_TidPtr;
ItemPointerData *tss_TidList;
} TidScanState;
/* ---------------- *TidRangeScanStateinformation * *trss_tidexprslistofTidOpExprstructs(seenodeTidrangescan.c) *trss_mintidthelowestTIDinthescanrange *trss_maxtidthehighestTIDinthescanrange *trss_inScanisascancurrentlyinprogress? *----------------
*/ typedefstruct TidRangeScanState
{
ScanState ss; /* its first field is NodeTag */
List *trss_tidexprs;
ItemPointerData trss_mintid;
ItemPointerData trss_maxtid; bool trss_inScan;
} TidRangeScanState;
/* ---------------- *SubqueryScanStateinformation * *SubqueryScanStateisusedforscanningasub-queryintherangetable. *ScanTupleSlotreferencesthecurrentoutputtupleofthesub-query. *----------------
*/ typedefstruct SubqueryScanState
{
ScanState ss; /* its first field is NodeTag */
PlanState *subplan;
} SubqueryScanState;
typedefstruct FunctionScanState
{
ScanState ss; /* its first field is NodeTag */ int eflags; bool ordinality; bool simple;
int64 ordinal; int nfuncs; struct FunctionScanPerFuncState *funcstates; /* array of length nfuncs */
MemoryContext argcontext;
} FunctionScanState;
/* ---------------- *ValuesScanStateinformation * *ValuesScannodesareusedtoscantheresultsofaVALUESlist * *rowcontextper-expression-listcontext *exprlistsarrayofexpressionlistsbeingevaluated *exprstatelistsarrayofexpressionstatelists,forSubPlansonly *array_lensizeofabovearrays *curr_idxcurrentarrayindex(0-based) * *Note:ss.ps.ps_ExprContextisusedtoevaluateanyqualorprojection *expressionsattachedtothenode.WecreateasecondExprContext, *rowcontext,inwhichtobuildtheexecutorexpressionstateforeach *Valuessublist.Resettingthiscontextletsusgetridofexpression *stateforeachrow,avoidingmajormemoryleakageoveralongvalueslist. *However,thatdoesn'tworkforsublistscontainingSubPlans,becausea *SubPlanhastobeconnecteduptotheouterplantreetoworkproperly. *Therefore,foronlythosesublistscontainingSubPlans,wedoexpression *stateconstructionatexecutorstart,andstorethosepointersin *exprstatelists[].NULLentriesinthatarraycorrespondtosimple *subexpressionsthatarehandledasdescribedabove. *----------------
*/ typedefstruct ValuesScanState
{
ScanState ss; /* its first field is NodeTag */
ExprContext *rowcontext;
List **exprlists;
List **exprstatelists; int array_len; int curr_idx;
} ValuesScanState;
/* ---------------- *TableFuncScanStatenode * *Usedintable-expressionfunctionslikeXMLTABLE. *----------------
*/ typedefstruct TableFuncScanState
{
ScanState ss; /* its first field is NodeTag */
ExprState *docexpr; /* state for document expression */
ExprState *rowexpr; /* state for row-generating expression */
List *colexprs; /* state for column-generating expression */
List *coldefexprs; /* state for column default expressions */
List *colvalexprs; /* state for column value expressions */
List *passingvalexprs; /* state for PASSING argument expressions */
List *ns_names; /* same as TableFunc.ns_names */
List *ns_uris; /* list of states of namespace URI exprs */
Bitmapset *notnulls; /* nullability flag for each output column */ void *opaque; /* table builder private space */ conststruct TableFuncRoutine *routine; /* table builder methods */
FmgrInfo *in_functions; /* input function for each column */
Oid *typioparams; /* typioparam for each column */
int64 ordinal; /* row number to be output next */
MemoryContext perTableCxt; /* per-table context */
Tuplestorestate *tupstore; /* output tuple store */
} TableFuncScanState;
/* ---------------- *CteScanStateinformation * *CteScannodesareusedtoscanaCommonTableExprquery. * *MultipleCteScannodescanreadoutfromthesameCTEquery.Weuse *atuplestoretoholdrowsthathavebeenreadfromtheCTEquerybut *notyetconsumedbyallreaders. *----------------
*/ typedefstruct CteScanState
{
ScanState ss; /* its first field is NodeTag */ int eflags; /* capability flags to pass to tuplestore */ int readptr; /* index of my tuplestore read pointer */
PlanState *cteplanstate; /* PlanState for the CTE query itself */ /* Link to the "leader" CteScanState (possibly this same node) */ struct CteScanState *leader; /* The remaining fields are only valid in the "leader" CteScanState */
Tuplestorestate *cte_table; /* rows already read from the CTE query */ bool eof_cte; /* reached end of CTE query? */
} CteScanState;
/* ---------------- *NamedTuplestoreScanStateinformation * *NamedTuplestoreScannodesareusedtoscanaTuplestorecreatedand *namedpriortoexecutionofthequery.Anexampleisatransition *tableforanAFTERtrigger. * *MultipleNamedTuplestoreScannodescanreadoutfromthesameTuplestore. *----------------
*/ typedefstruct NamedTuplestoreScanState
{
ScanState ss; /* its first field is NodeTag */ int readptr; /* index of my tuplestore read pointer */
TupleDesc tupdesc; /* format of the tuples in the tuplestore */
Tuplestorestate *relation; /* the rows */
} NamedTuplestoreScanState;
/* ---------------- *WorkTableScanStateinformation * *WorkTableScannodesareusedtoscantheworktablecreatedby *aRecursiveUnionnode.WelocatetheRecursiveUnionnode *duringexecutorstartup. *----------------
*/ typedefstruct WorkTableScanState
{
ScanState ss; /* its first field is NodeTag */
RecursiveUnionState *rustate;
} WorkTableScanState;
/* ---------------- *ForeignScanStateinformation * *ForeignScannodesareusedtoscanforeign-datatables. *----------------
*/ typedefstruct ForeignScanState
{
ScanState ss; /* its first field is NodeTag */
ExprState *fdw_recheck_quals; /* original quals not in ss.ps.qual */
Size pscan_len; /* size of parallel coordination information */
ResultRelInfo *resultRelInfo; /* result rel info, if UPDATE or DELETE */ /* use struct pointer to avoid including fdwapi.h here */ struct FdwRoutine *fdwroutine; void *fdw_state; /* foreign-data wrapper can keep state here */
} ForeignScanState;
typedefstruct CustomScanState
{
ScanState ss;
uint32 flags; /* mask of CUSTOMPATH_* flags, see
* nodes/extensible.h */
List *custom_ps; /* list of child PlanState nodes, if any */
Size pscan_len; /* size of parallel coordination information */ conststruct CustomExecMethods *methods; conststruct TupleTableSlotOps *slotOps;
} CustomScanState;
/* ---------------- *JoinStateinformation * *Superclassforstatenodesofjoinplans. *----------------
*/ typedefstruct JoinState
{
PlanState ps;
JoinType jointype; bool single_match; /* True if we should skip to next outer tuple
* after finding one inner match */
ExprState *joinqual; /* JOIN quals (in addition to ps.qual) */
} JoinState;
/* ---------------- *NestLoopStateinformation * *NeedNewOutertrueifneednewoutertupleonnextcall *MatchedOutertrueiffoundajoinmatchforcurrentoutertuple *NullInnerTupleSlotpreparednulltupleforleftouterjoins *----------------
*/ typedefstruct NestLoopState
{
JoinState js; /* its first field is NodeTag */ bool nl_NeedNewOuter; bool nl_MatchedOuter;
TupleTableSlot *nl_NullInnerTupleSlot;
} NestLoopState;
/* these structs are defined in executor/hashjoin.h: */ typedefstruct HashJoinTupleData *HashJoinTuple; typedefstruct HashJoinTableData *HashJoinTable;
typedefstruct HashJoinState
{
JoinState js; /* its first field is NodeTag */
ExprState *hashclauses;
ExprState *hj_OuterHash;
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;
/* ---------------- *MaterialStateinformation * *materializenodesareusedtomaterializetheresults *ofasubplanintoatemporaryfile. * *ss.ss_ScanTupleSlotreferstooutputofunderlyingplan. *----------------
*/ typedefstruct MaterialState
{
ScanState ss; /* its first field is NodeTag */ int eflags; /* capability flags to pass to tuplestore */ bool eof_underlying; /* reached end of underlying plan? */
Tuplestorestate *tuplestorestate;
} MaterialState;
typedefstruct MemoizeInstrumentation
{
uint64 cache_hits; /* number of rescans where we've found the
* scan parameter values to be cached */
uint64 cache_misses; /* number of rescans where we've not found the
* scan parameter values to be cached. */
uint64 cache_evictions; /* number of cache entries removed due to
* the need to free memory */
uint64 cache_overflows; /* number of times we've had to bypass the *cachewhenfillingitduetonotbeing *abletofreeenoughspacetostorethe
* current scan's tuples. */
uint64 mem_peak; /* peak memory usage in bytes */
} MemoizeInstrumentation;
/* ---------------- *MemoizeStateinformation * *memoizenodesareusedtocacherecentandcommonlyseenresultsfrom *aparameterizedscan. *----------------
*/ typedefstruct MemoizeState
{
ScanState ss; /* its first field is NodeTag */ int mstatus; /* value of ExecMemoize state machine */ int nkeys; /* number of cache keys */ struct memoize_hash *hashtable; /* hash table for cache entries */
TupleDesc hashkeydesc; /* tuple descriptor for cache keys */
TupleTableSlot *tableslot; /* min tuple slot for existing cache entries */
TupleTableSlot *probeslot; /* virtual slot used for hash lookups */
ExprState *cache_eq_expr; /* Compare exec params to hash key */
ExprState **param_exprs; /* exprs containing the parameters to this
* node */
FmgrInfo *hashfunctions; /* lookup data for hash funcs nkeys in size */
Oid *collations; /* collation for comparisons nkeys in size */
uint64 mem_used; /* bytes of memory used by cache */
uint64 mem_limit; /* memory limit in bytes for the cache */
MemoryContext tableContext; /* memory context to store cache data */
dlist_head lru_list; /* least recently used entry list */ struct MemoizeTuple *last_tuple; /* Used to point to the last tuple *returnedduringacachehitandthe *tuplewelaststoredwhen
* populating the cache. */ struct MemoizeEntry *entry; /* the entry that 'last_tuple' belongs to or
* NULL if 'last_tuple' is NULL. */ bool singlerow; /* true if the cache entry is to be marked as
* complete after caching the first tuple. */ bool binary_mode; /* true when cache key should be compared bit
* by bit, false when using hash equality ops */
MemoizeInstrumentation stats; /* execution statistics */
SharedMemoizeInfo *shared_info; /* statistics for parallel workers */
Bitmapset *keyparamids; /* Param->paramids of expressions belonging to
* param_exprs */
} MemoizeState;
/* ---------------- *Whenperformingsortingbymultiplekeys,it'spossiblethattheinput *datasetisalreadysortedonaprefixofthosekeys.Wecallthese *"presortedkeys". *PresortedKeyDatarepresentsinformationaboutonesuchkey. *----------------
*/ typedefstruct PresortedKeyData
{
FmgrInfo flinfo; /* comparison function info */
FunctionCallInfo fcinfo; /* comparison function call info */
OffsetNumber attno; /* attribute number in tuple */
} PresortedKeyData;
/* ---------------- *SortStateinformation *----------------
*/ typedefstruct SortState
{
ScanState ss; /* its first field is NodeTag */ bool randomAccess; /* need random access to sort output? */ bool bounded; /* is the result set bounded? */
int64 bound; /* if bounded, how many tuples are needed */ bool sort_Done; /* sort completed yet? */ bool bounded_Done; /* value of bounded we did the sort with */
int64 bound_Done; /* value of bound we did the sort with */ void *tuplesortstate; /* private state of tuplesort.c */ bool am_worker; /* are we a worker? */ bool datumSort; /* Datum sort instead of tuple sort? */
SharedSortInfo *shared_info; /* one entry per worker */
} SortState;
typedefstruct IncrementalSortState
{
ScanState ss; /* its first field is NodeTag */ bool bounded; /* is the result set bounded? */
int64 bound; /* if bounded, how many tuples are needed */ bool outerNodeDone; /* finished fetching tuples from outer node */
int64 bound_Done; /* value of bound we did the sort with */
IncrementalSortExecutionStatus execution_status;
int64 n_fullsort_remaining;
Tuplesortstate *fullsort_state; /* private state of tuplesort.c */
Tuplesortstate *prefixsort_state; /* private state of tuplesort.c */ /* the keys by which the input path is already sorted */
PresortedKeyData *presorted_keys;
IncrementalSortInfo incsort_info;
/* slot for pivot tuple defining values of presorted keys within group */
TupleTableSlot *group_pivot;
TupleTableSlot *transfer_tuple; bool am_worker; /* are we a worker? */
SharedIncrementalSortInfo *shared_info; /* one entry per worker */
} IncrementalSortState;
/* --------------------- *GroupStateinformation *---------------------
*/ typedefstruct GroupState
{
ScanState ss; /* its first field is NodeTag */
ExprState *eqfunction; /* equality function */ bool grp_done; /* indicates completion of Group scan */
} GroupState;
/* --------------------- *per-workeraggregateinformation *---------------------
*/ typedefstruct AggregateInstrumentation
{
Size hash_mem_peak; /* peak hash table memory usage */
uint64 hash_disk_used; /* kB of disk space used */ int hash_batches_used; /* batches used during entire execution */
} AggregateInstrumentation;
typedefstruct AggState
{
ScanState ss; /* its first field is NodeTag */
List *aggs; /* all Aggref nodes in targetlist & quals */ int numaggs; /* length of list (could be zero!) */ int numtrans; /* number of pertrans items */
AggStrategy aggstrategy; /* strategy mode */
AggSplit aggsplit; /* agg-splitting mode, see nodes.h */
AggStatePerPhase phase; /* pointer to current phase data */ int numphases; /* number of phases (including phase 0) */ int current_phase; /* current phase number */
AggStatePerAgg peragg; /* per-Aggref information */
AggStatePerTrans pertrans; /* per-Trans state information */
ExprContext *hashcontext; /* econtexts for long-lived data (hashtable) */
ExprContext **aggcontexts; /* econtexts for long-lived data (per GS) */
ExprContext *tmpcontext; /* econtext for input expressions */ #define FIELDNO_AGGSTATE_CURAGGCONTEXT 14
ExprContext *curaggcontext; /* currently active aggcontext */
AggStatePerAgg curperagg; /* currently active aggregate, if any */ #define FIELDNO_AGGSTATE_CURPERTRANS 16
AggStatePerTrans curpertrans; /* currently active trans state, if any */ bool input_done; /* indicates end of input */ bool agg_done; /* indicates completion of Agg scan */ int projected_set; /* The last projected grouping set */ #define FIELDNO_AGGSTATE_CURRENT_SET 20 int current_set; /* The current grouping set being evaluated */
Bitmapset *grouped_cols; /* grouped cols in current projection */
List *all_grouped_cols; /* list of all grouped cols in DESC order */
Bitmapset *colnos_needed; /* all columns needed from the outer plan */ int max_colno_needed; /* highest colno needed from outer plan */ bool all_cols_needed; /* are all cols from outer plan needed? */ /* These fields are for grouping set phase data */ int maxsets; /* The max number of sets in any phase */
AggStatePerPhase phases; /* array of all phases */
Tuplesortstate *sort_in; /* sorted input to phases > 1 */
Tuplesortstate *sort_out; /* input is copied here for next phase */
TupleTableSlot *sort_slot; /* slot for sort results */ /* these fields are used in AGG_PLAIN and AGG_SORTED modes: */
AggStatePerGroup *pergroups; /* grouping set indexed array of per-group
* pointers */
HeapTuple grp_firstTuple; /* copy of first tuple of current group */ /* these fields are used in AGG_HASHED and AGG_MIXED modes: */ bool table_filled; /* hash table filled yet? */ int num_hashes;
MemoryContext hash_metacxt; /* memory for hash table bucket array */
MemoryContext hash_tablecxt; /* memory for hash table entries */ struct LogicalTapeSet *hash_tapeset; /* tape set for hash spill tapes */ struct HashAggSpill *hash_spills; /* HashAggSpill for each grouping set,
* exists only during first pass */
TupleTableSlot *hash_spill_rslot; /* for reading spill files */
TupleTableSlot *hash_spill_wslot; /* for writing spill files */
List *hash_batches; /* hash batches remaining to be processed */ bool hash_ever_spilled; /* ever spilled during this execution? */ bool hash_spill_mode; /* we hit a limit during the current batch
* and we must not create new groups */
Size hash_mem_limit; /* limit before spilling hash table */
uint64 hash_ngroups_limit; /* limit before spilling hash table */ int hash_planned_partitions; /* number of partitions planned
* for first pass */ double hashentrysize; /* estimate revised during execution */
Size hash_mem_peak; /* peak hash table memory usage */
uint64 hash_ngroups_current; /* number of groups currently in
* memory in all hash tables */
uint64 hash_disk_used; /* kB of disk space used */ int hash_batches_used; /* batches used during entire execution */
AggStatePerHash perhash; /* array of per-hashtable data */
AggStatePerGroup *hash_pergroup; /* grouping set indexed array of
* per-group pointers */
/* support for evaluation of agg input expressions: */ #define FIELDNO_AGGSTATE_ALL_PERGROUPS 54
AggStatePerGroup *all_pergroups; /* array of first ->pergroups, than
* ->hash_pergroup */
SharedAggInfo *shared_info; /* one entry per worker */
} AggState;
/* ---------------- *WindowAggStateinformation *----------------
*/ /* these structs are private in nodeWindowAgg.c: */ typedefstruct WindowStatePerFuncData *WindowStatePerFunc; typedefstruct WindowStatePerAggData *WindowStatePerAgg;
/* *WindowAggStatus--UsedtotrackthestatusofWindowAggState
*/ typedefenum WindowAggStatus
{
WINDOWAGG_DONE, /* No more processing to do */
WINDOWAGG_RUN, /* Normal processing of window funcs */
WINDOWAGG_PASSTHROUGH, /* Don't eval window funcs */
WINDOWAGG_PASSTHROUGH_STRICT, /* Pass-through plus don't store new
* tuples during spool */
} WindowAggStatus;
typedefstruct WindowAggState
{
ScanState ss; /* its first field is NodeTag */
/* these fields are filled in by ExecInitExpr: */
List *funcs; /* all WindowFunc nodes in targetlist */ int numfuncs; /* total number of window functions */ int numaggs; /* number that are plain aggregates */
WindowStatePerFunc perfunc; /* per-window-function information */
WindowStatePerAgg peragg; /* per-plain-aggregate information */
ExprState *partEqfunction; /* equality funcs for partition columns */
ExprState *ordEqfunction; /* equality funcs for ordering columns */
Tuplestorestate *buffer; /* stores rows of current partition */ int current_ptr; /* read pointer # for current row */ int framehead_ptr; /* read pointer # for frame head, if used */ int frametail_ptr; /* read pointer # for frame tail, if used */ int grouptail_ptr; /* read pointer # for group tail, if used */
int64 spooled_rows; /* total # of rows in buffer */
int64 currentpos; /* position of current row in partition */
int64 frameheadpos; /* current frame head position */
int64 frametailpos; /* current frame tail position (frame end+1) */ /* use struct pointer to avoid including windowapi.h here */ struct WindowObjectData *agg_winobj; /* winobj for aggregate fetches */
int64 aggregatedbase; /* start row for current aggregates */
int64 aggregatedupto; /* rows before this one are aggregated */
WindowAggStatus status; /* run status of WindowAggState */
int frameOptions; /* frame_clause options, see WindowDef */
ExprState *startOffset; /* expression for starting bound offset */
ExprState *endOffset; /* expression for ending bound offset */
Datum startOffsetValue; /* result of startOffset evaluation */
Datum endOffsetValue; /* result of endOffset evaluation */
/* these fields are used with RANGE offset PRECEDING/FOLLOWING: */
FmgrInfo startInRangeFunc; /* in_range function for startOffset */
FmgrInfo endInRangeFunc; /* in_range function for endOffset */
Oid inRangeColl; /* collation for in_range tests */ bool inRangeAsc; /* use ASC sort order for in_range tests? */ bool inRangeNullsFirst; /* nulls sort first for in_range tests? */
/* fields relating to runconditions */ bool use_pass_through; /* When false, stop execution when *runconditionisnolongertrue.Else
* just stop evaluating window funcs. */ bool top_window; /* true if this is the top-most WindowAgg or
* the only WindowAgg in this query level */
ExprState *runcondition; /* Condition which must remain true otherwise *executionoftheWindowAggwillfinishor *gointopass-throughmode.NULLwhenthere
* is no such condition. */
/* these fields are used in GROUPS mode: */
int64 currentgroup; /* peer group # of current row in partition */
int64 frameheadgroup; /* peer group # of frame head row */
int64 frametailgroup; /* peer group # of frame tail row */
int64 groupheadpos; /* current row's peer group head position */
int64 grouptailpos; /* " " " " tail position (group end+1) */
MemoryContext partcontext; /* context for partition-lifespan data */
MemoryContext aggcontext; /* shared context for aggregate working data */
MemoryContext curaggcontext; /* current aggregate's working data */
ExprContext *tmpcontext; /* short-term evaluation context */
bool all_first; /* true if the scan is starting */ bool partition_spooled; /* true if all tuples in current partition
* have been spooled into tuplestore */ bool next_partition; /* true if begin_partition needs to be called */ bool more_partitions; /* true if there's more partitions after
* this one */ bool framehead_valid; /* true if frameheadpos is known up to
* date for current row */ bool frametail_valid; /* true if frametailpos is known up to
* date for current row */ bool grouptail_valid; /* true if grouptailpos is known up to
* date for current row */
TupleTableSlot *first_part_slot; /* first tuple of current or next
* partition */
TupleTableSlot *framehead_slot; /* first tuple of current frame */
TupleTableSlot *frametail_slot; /* first tuple after current frame */
/* temporary slots for tuples fetched back from tuplestore */
TupleTableSlot *agg_row_slot;
TupleTableSlot *temp_slot_1;
TupleTableSlot *temp_slot_2;
} WindowAggState;
/* ---------------- *UniqueStateinformation * *Uniquenodesareused"ontopof"sortnodestodiscard *duplicatetuplesreturnedfromthesortphase.Basically *allitdoesiscomparethecurrenttuplefromthesubplan *withthepreviouslyfetchedtuple(storedinitsresultslot). *Ifthetwoareidenticalinallinterestingfields,then *wejustfetchanothertuplefromthesortandtryagain. *----------------
*/ typedefstruct UniqueState
{
PlanState ps; /* its first field is NodeTag */
ExprState *eqfunction; /* tuple equality qual */
} UniqueState;
/* ---------------- *GatherStateinformation * *Gathernodeslaunch1ormoreparallelworkers,runasubplan *inthoseworkers,andcollecttheresults. *----------------
*/ typedefstruct GatherState
{
PlanState ps; /* its first field is NodeTag */ bool initialized; /* workers launched? */ bool need_to_scan_locally; /* need to read from local plan? */
int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */ /* these fields are set up once: */
TupleTableSlot *funnel_slot; struct ParallelExecutorInfo *pei; /* all remaining fields are reinitialized during a rescan: */ int nworkers_launched; /* original number of workers */ int nreaders; /* number of still-active workers */ int nextreader; /* next one to try to read from */ struct TupleQueueReader **reader; /* array with nreaders active entries */
} GatherState;
typedefstruct GatherMergeState
{
PlanState ps; /* its first field is NodeTag */ bool initialized; /* workers launched? */ bool gm_initialized; /* gather_merge_init() done? */ bool need_to_scan_locally; /* need to read from local plan? */
int64 tuples_needed; /* tuple bound, see ExecSetTupleBound */ /* these fields are set up once: */
TupleDesc tupDesc; /* descriptor for subplan result tuples */ int gm_nkeys; /* number of sort columns */
SortSupport gm_sortkeys; /* array of length gm_nkeys */ struct ParallelExecutorInfo *pei; /* all remaining fields are reinitialized during a rescan */ /* (but the arrays are not reallocated, just cleared) */ int nworkers_launched; /* original number of workers */ int nreaders; /* number of active workers */
TupleTableSlot **gm_slots; /* array with nreaders+1 entries */ struct TupleQueueReader **reader; /* array with nreaders active entries */ struct GMReaderTupleBuffer *gm_tuple_buffers; /* nreaders tuple buffers */ struct binaryheap *gm_heap; /* binary heap of slot indices */
} GatherMergeState;
/* ---------------- *ValuesdisplayedbyEXPLAINANALYZE *----------------
*/ typedefstruct HashInstrumentation
{ int nbuckets; /* number of buckets at end of execution */ int nbuckets_original; /* planned number of buckets */ int nbatch; /* number of batches at end of execution */ int nbatch_original; /* planned number of batches */
Size space_peak; /* peak memory usage in bytes */
} HashInstrumentation;
/* ---------------- *HashStateinformation *----------------
*/ typedefstruct HashState
{
PlanState ps; /* its first field is NodeTag */
HashJoinTable hashtable; /* hash table for the hashjoin */
ExprState *hash_expr; /* ExprState to get hash value */
FmgrInfo *skew_hashfunction; /* lookup data for skew hash function */
Oid skew_collation; /* collation to call skew_hashfunction with */
/* ---------------- *SetOpStateinformation * *SetOpnodessupporteithersortedorhashedde-duplication. *ThesortedmodeisabitlikeMergeJoin,thehashedmodelikeAgg. *----------------
*/ typedefstruct SetOpStatePerInput
{
TupleTableSlot *firstTupleSlot; /* first tuple of current group */
int64 numTuples; /* number of tuples in current group */
TupleTableSlot *nextTupleSlot; /* next input tuple, if already read */ bool needGroup; /* do we need to load a new group? */
} SetOpStatePerInput;
typedefstruct SetOpState
{
PlanState ps; /* its first field is NodeTag */ bool setop_done; /* indicates completion of output scan */
int64 numOutput; /* number of dups left to output */ int numCols; /* number of grouping columns */
/* these fields are used in SETOP_SORTED mode: */
SortSupport sortKeys; /* per-grouping-field sort data */
SetOpStatePerInput leftInput; /* current outer-relation input state */
SetOpStatePerInput rightInput; /* current inner-relation input state */ bool need_init; /* have we read the first tuples yet? */
/* these fields are used in SETOP_HASHED mode: */
Oid *eqfuncoids; /* per-grouping-field equality fns */
FmgrInfo *hashfunctions; /* per-grouping-field hash fns */
TupleHashTable hashtable; /* hash table with one entry per group */
MemoryContext tableContext; /* memory context containing hash table */ bool table_filled; /* hash table filled yet? */
TupleHashIterator hashiter; /* for iterating through hash table */
} SetOpState;
/* ---------------- *LockRowsStateinformation * *LockRowsnodesareusedtoenforceFOR[KEY]UPDATE/SHARElocking. *----------------
*/ typedefstruct LockRowsState
{
PlanState ps; /* its first field is NodeTag */
List *lr_arowMarks; /* List of ExecAuxRowMarks */
EPQState lr_epqstate; /* for evaluating EvalPlanQual rechecks */
} LockRowsState;
/* ---------------- *LimitStateinformation * *LimitnodesareusedtoenforceLIMIT/OFFSETclauses. *Theyjustselectthedesiredsubrangeoftheirsubplan'soutput. * *offsetisthenumberofinitialtuplestoskip(0doesnothing). *countisthenumberoftuplestoreturnafterskippingtheoffsettuples. *Ifnolimitcountwasspecified,countisundefinedandnoCountistrue. *Whenlstate==LIMIT_INITIAL,offset/count/noCounthaven'tbeensetyet. *----------------
*/ typedefenum
{
LIMIT_INITIAL, /* initial state for LIMIT node */
LIMIT_RESCAN, /* rescan after recomputing parameters */
LIMIT_EMPTY, /* there are no returnable rows */
LIMIT_INWINDOW, /* have returned a row in the window */
LIMIT_WINDOWEND_TIES, /* have returned a tied row */
LIMIT_SUBPLANEOF, /* at EOF of subplan (within window) */
LIMIT_WINDOWEND, /* stepped off end of window */
LIMIT_WINDOWSTART, /* stepped off beginning of window */
} LimitStateCond;
typedefstruct LimitState
{
PlanState ps; /* its first field is NodeTag */
ExprState *limitOffset; /* OFFSET parameter, or NULL if none */
ExprState *limitCount; /* COUNT parameter, or NULL if none */
LimitOption limitOption; /* limit specification type */
int64 offset; /* current OFFSET value */
int64 count; /* current COUNT, if any */ bool noCount; /* if true, ignore count */
LimitStateCond lstate; /* state machine status, as above */
int64 position; /* 1-based index of last tuple returned */
TupleTableSlot *subSlot; /* tuple last obtained from subplan */
ExprState *eqfunction; /* tuple equality qual in case of WITH TIES
* option */
TupleTableSlot *last_slot; /* slot for evaluation of ties */
} LimitState;
#endif/* EXECNODES_H */
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.90 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.