Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
executor.h681 linesDownload Raw Back to executor
1/*-------------------------------------------------------------------------2 *3 * executor.h4 *	  support for the POSTGRES executor module5 *6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/executor/executor.h11 *12 *-------------------------------------------------------------------------13 */14#ifndef EXECUTOR_H15#define EXECUTOR_H16 17#include "executor/execdesc.h"18#include "fmgr.h"19#include "nodes/lockoptions.h"20#include "nodes/parsenodes.h"21#include "utils/memutils.h"22 23 24/*25 * The "eflags" argument to ExecutorStart and the various ExecInitNode26 * routines is a bitwise OR of the following flag bits, which tell the27 * called plan node what to expect.  Note that the flags will get modified28 * as they are passed down the plan tree, since an upper node may require29 * functionality in its subnode not demanded of the plan as a whole30 * (example: MergeJoin requires mark/restore capability in its inner input),31 * or an upper node may shield its input from some functionality requirement32 * (example: Materialize shields its input from needing to do backward scan).33 *34 * EXPLAIN_ONLY indicates that the plan tree is being initialized just so35 * EXPLAIN can print it out; it will not be run.  Hence, no side-effects36 * of startup should occur.  However, error checks (such as permission checks)37 * should be performed.38 *39 * EXPLAIN_GENERIC can only be used together with EXPLAIN_ONLY.  It indicates40 * that a generic plan is being shown using EXPLAIN (GENERIC_PLAN), which41 * means that missing parameter values must be tolerated.  Currently, the only42 * effect is to suppress execution-time partition pruning.43 *44 * REWIND indicates that the plan node should try to efficiently support45 * rescans without parameter changes.  (Nodes must support ExecReScan calls46 * in any case, but if this flag was not given, they are at liberty to do it47 * through complete recalculation.  Note that a parameter change forces a48 * full recalculation in any case.)49 *50 * BACKWARD indicates that the plan node must respect the es_direction flag.51 * When this is not passed, the plan node will only be run forwards.52 *53 * MARK indicates that the plan node must support Mark/Restore calls.54 * When this is not passed, no Mark/Restore will occur.55 *56 * SKIP_TRIGGERS tells ExecutorStart/ExecutorFinish to skip calling57 * AfterTriggerBeginQuery/AfterTriggerEndQuery.  This does not necessarily58 * mean that the plan can't queue any AFTER triggers; just that the caller59 * is responsible for there being a trigger context for them to be queued in.60 *61 * WITH_NO_DATA indicates that we are performing REFRESH MATERIALIZED VIEW62 * ... WITH NO DATA.  Currently, the only effect is to suppress errors about63 * scanning unpopulated materialized views.64 */65#define EXEC_FLAG_EXPLAIN_ONLY		0x0001	/* EXPLAIN, no ANALYZE */66#define EXEC_FLAG_EXPLAIN_GENERIC	0x0002	/* EXPLAIN (GENERIC_PLAN) */67#define EXEC_FLAG_REWIND			0x0004	/* need efficient rescan */68#define EXEC_FLAG_BACKWARD			0x0008	/* need backward scan */69#define EXEC_FLAG_MARK				0x0010	/* need mark/restore */70#define EXEC_FLAG_SKIP_TRIGGERS		0x0020	/* skip AfterTrigger setup */71#define EXEC_FLAG_WITH_NO_DATA		0x0040	/* REFRESH ... WITH NO DATA */72 73 74/* Hook for plugins to get control in ExecutorStart() */75typedef void (*ExecutorStart_hook_type) (QueryDesc *queryDesc, int eflags);76extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook;77 78/* Hook for plugins to get control in ExecutorRun() */79typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc,80									   ScanDirection direction,81									   uint64 count,82									   bool execute_once);83extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;84 85/* Hook for plugins to get control in ExecutorFinish() */86typedef void (*ExecutorFinish_hook_type) (QueryDesc *queryDesc);87extern PGDLLIMPORT ExecutorFinish_hook_type ExecutorFinish_hook;88 89/* Hook for plugins to get control in ExecutorEnd() */90typedef void (*ExecutorEnd_hook_type) (QueryDesc *queryDesc);91extern PGDLLIMPORT ExecutorEnd_hook_type ExecutorEnd_hook;92 93/* Hook for plugins to get control in ExecCheckPermissions() */94typedef bool (*ExecutorCheckPerms_hook_type) (List *rangeTable,95											  List *rtePermInfos,96											  bool ereport_on_violation);97extern PGDLLIMPORT ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook;98 99 100/*101 * prototypes from functions in execAmi.c102 */103struct Path;					/* avoid including pathnodes.h here */104 105extern void ExecReScan(PlanState *node);106extern void ExecMarkPos(PlanState *node);107extern void ExecRestrPos(PlanState *node);108extern bool ExecSupportsMarkRestore(struct Path *pathnode);109extern bool ExecSupportsBackwardScan(Plan *node);110extern bool ExecMaterializesOutput(NodeTag plantype);111 112/*113 * prototypes from functions in execCurrent.c114 */115extern bool execCurrentOf(CurrentOfExpr *cexpr,116						  ExprContext *econtext,117						  Oid table_oid,118						  ItemPointer current_tid);119 120/*121 * prototypes from functions in execGrouping.c122 */123extern ExprState *execTuplesMatchPrepare(TupleDesc desc,124										 int numCols,125										 const AttrNumber *keyColIdx,126										 const Oid *eqOperators,127										 const Oid *collations,128										 PlanState *parent);129extern void execTuplesHashPrepare(int numCols,130								  const Oid *eqOperators,131								  Oid **eqFuncOids,132								  FmgrInfo **hashFunctions);133extern TupleHashTable BuildTupleHashTable(PlanState *parent,134										  TupleDesc inputDesc,135										  int numCols, AttrNumber *keyColIdx,136										  const Oid *eqfuncoids,137										  FmgrInfo *hashfunctions,138										  Oid *collations,139										  long nbuckets, Size additionalsize,140										  MemoryContext tablecxt,141										  MemoryContext tempcxt, bool use_variable_hash_iv);142extern TupleHashTable BuildTupleHashTableExt(PlanState *parent,143											 TupleDesc inputDesc,144											 int numCols, AttrNumber *keyColIdx,145											 const Oid *eqfuncoids,146											 FmgrInfo *hashfunctions,147											 Oid *collations,148											 long nbuckets, Size additionalsize,149											 MemoryContext metacxt,150											 MemoryContext tablecxt,151											 MemoryContext tempcxt, bool use_variable_hash_iv);152extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,153										   TupleTableSlot *slot,154										   bool *isnew, uint32 *hash);155extern uint32 TupleHashTableHash(TupleHashTable hashtable,156								 TupleTableSlot *slot);157extern TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable,158											   TupleTableSlot *slot,159											   bool *isnew, uint32 hash);160extern TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable,161										 TupleTableSlot *slot,162										 ExprState *eqcomp,163										 FmgrInfo *hashfunctions);164extern void ResetTupleHashTable(TupleHashTable hashtable);165 166/*167 * prototypes from functions in execJunk.c168 */169extern JunkFilter *ExecInitJunkFilter(List *targetList,170									  TupleTableSlot *slot);171extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,172												TupleDesc cleanTupType,173												TupleTableSlot *slot);174extern AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter,175										const char *attrName);176extern AttrNumber ExecFindJunkAttributeInTlist(List *targetlist,177											   const char *attrName);178extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,179									  TupleTableSlot *slot);180 181/*182 * ExecGetJunkAttribute183 *184 * Given a junk filter's input tuple (slot) and a junk attribute's number185 * previously found by ExecFindJunkAttribute, extract & return the value and186 * isNull flag of the attribute.187 */188#ifndef FRONTEND189static inline Datum190ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)191{192	Assert(attno > 0);193	return slot_getattr(slot, attno, isNull);194}195#endif196 197/*198 * prototypes from functions in execMain.c199 */200extern void ExecutorStart(QueryDesc *queryDesc, int eflags);201extern void standard_ExecutorStart(QueryDesc *queryDesc, int eflags);202extern void ExecutorRun(QueryDesc *queryDesc,203						ScanDirection direction, uint64 count, bool execute_once);204extern void standard_ExecutorRun(QueryDesc *queryDesc,205								 ScanDirection direction, uint64 count, bool execute_once);206extern void ExecutorFinish(QueryDesc *queryDesc);207extern void standard_ExecutorFinish(QueryDesc *queryDesc);208extern void ExecutorEnd(QueryDesc *queryDesc);209extern void standard_ExecutorEnd(QueryDesc *queryDesc);210extern void ExecutorRewind(QueryDesc *queryDesc);211extern bool ExecCheckPermissions(List *rangeTable,212								 List *rteperminfos, bool ereport_on_violation);213extern void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation);214extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,215							  Relation resultRelationDesc,216							  Index resultRelationIndex,217							  ResultRelInfo *partition_root_rri,218							  int instrument_options);219extern ResultRelInfo *ExecGetTriggerResultRel(EState *estate, Oid relid,220											  ResultRelInfo *rootRelInfo);221extern List *ExecGetAncestorResultRels(EState *estate, ResultRelInfo *resultRelInfo);222extern void ExecConstraints(ResultRelInfo *resultRelInfo,223							TupleTableSlot *slot, EState *estate);224extern bool ExecPartitionCheck(ResultRelInfo *resultRelInfo,225							   TupleTableSlot *slot, EState *estate, bool emitError);226extern void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,227										TupleTableSlot *slot, EState *estate);228extern void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,229								 TupleTableSlot *slot, EState *estate);230extern LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo);231extern ExecRowMark *ExecFindRowMark(EState *estate, Index rti, bool missing_ok);232extern ExecAuxRowMark *ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist);233extern TupleTableSlot *EvalPlanQual(EPQState *epqstate, Relation relation,234									Index rti, TupleTableSlot *inputslot);235extern void EvalPlanQualInit(EPQState *epqstate, EState *parentestate,236							 Plan *subplan, List *auxrowmarks,237							 int epqParam, List *resultRelations);238extern void EvalPlanQualSetPlan(EPQState *epqstate,239								Plan *subplan, List *auxrowmarks);240extern TupleTableSlot *EvalPlanQualSlot(EPQState *epqstate,241										Relation relation, Index rti);242 243#define EvalPlanQualSetSlot(epqstate, slot)  ((epqstate)->origslot = (slot))244extern bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot);245extern TupleTableSlot *EvalPlanQualNext(EPQState *epqstate);246extern void EvalPlanQualBegin(EPQState *epqstate);247extern void EvalPlanQualEnd(EPQState *epqstate);248 249/*250 * functions in execProcnode.c251 */252extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);253extern void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function);254extern Node *MultiExecProcNode(PlanState *node);255extern void ExecEndNode(PlanState *node);256extern void ExecShutdownNode(PlanState *node);257extern void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node);258 259 260/* ----------------------------------------------------------------261 *		ExecProcNode262 *263 *		Execute the given node to return a(nother) tuple.264 * ----------------------------------------------------------------265 */266#ifndef FRONTEND267static inline TupleTableSlot *268ExecProcNode(PlanState *node)269{270	if (node->chgParam != NULL) /* something changed? */271		ExecReScan(node);		/* let ReScan handle this */272 273	return node->ExecProcNode(node);274}275#endif276 277/*278 * prototypes from functions in execExpr.c279 */280extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);281extern ExprState *ExecInitExprWithParams(Expr *node, ParamListInfo ext_params);282extern ExprState *ExecInitQual(List *qual, PlanState *parent);283extern ExprState *ExecInitCheck(List *qual, PlanState *parent);284extern List *ExecInitExprList(List *nodes, PlanState *parent);285extern ExprState *ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase,286									bool doSort, bool doHash, bool nullcheck);287extern ExprState *ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,288										 const TupleTableSlotOps *lops, const TupleTableSlotOps *rops,289										 int numCols,290										 const AttrNumber *keyColIdx,291										 const Oid *eqfunctions,292										 const Oid *collations,293										 PlanState *parent);294extern ExprState *ExecBuildParamSetEqual(TupleDesc desc,295										 const TupleTableSlotOps *lops,296										 const TupleTableSlotOps *rops,297										 const Oid *eqfunctions,298										 const Oid *collations,299										 const List *param_exprs,300										 PlanState *parent);301extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,302											   ExprContext *econtext,303											   TupleTableSlot *slot,304											   PlanState *parent,305											   TupleDesc inputDesc);306extern ProjectionInfo *ExecBuildUpdateProjection(List *targetList,307												 bool evalTargetList,308												 List *targetColnos,309												 TupleDesc relDesc,310												 ExprContext *econtext,311												 TupleTableSlot *slot,312												 PlanState *parent);313extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);314extern ExprState *ExecPrepareQual(List *qual, EState *estate);315extern ExprState *ExecPrepareCheck(List *qual, EState *estate);316extern List *ExecPrepareExprList(List *nodes, EState *estate);317 318/*319 * ExecEvalExpr320 *321 * Evaluate expression identified by "state" in the execution context322 * given by "econtext".  *isNull is set to the is-null flag for the result,323 * and the Datum value is the function result.324 *325 * The caller should already have switched into the temporary memory326 * context econtext->ecxt_per_tuple_memory.  The convenience entry point327 * ExecEvalExprSwitchContext() is provided for callers who don't prefer to328 * do the switch in an outer loop.329 */330#ifndef FRONTEND331static inline Datum332ExecEvalExpr(ExprState *state,333			 ExprContext *econtext,334			 bool *isNull)335{336	return state->evalfunc(state, econtext, isNull);337}338#endif339 340/*341 * ExecEvalExprSwitchContext342 *343 * Same as ExecEvalExpr, but get into the right allocation context explicitly.344 */345#ifndef FRONTEND346static inline Datum347ExecEvalExprSwitchContext(ExprState *state,348						  ExprContext *econtext,349						  bool *isNull)350{351	Datum		retDatum;352	MemoryContext oldContext;353 354	oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);355	retDatum = state->evalfunc(state, econtext, isNull);356	MemoryContextSwitchTo(oldContext);357	return retDatum;358}359#endif360 361/*362 * ExecProject363 *364 * Projects a tuple based on projection info and stores it in the slot passed365 * to ExecBuildProjectionInfo().366 *367 * Note: the result is always a virtual tuple; therefore it may reference368 * the contents of the exprContext's scan tuples and/or temporary results369 * constructed in the exprContext.  If the caller wishes the result to be370 * valid longer than that data will be valid, he must call ExecMaterializeSlot371 * on the result slot.372 */373#ifndef FRONTEND374static inline TupleTableSlot *375ExecProject(ProjectionInfo *projInfo)376{377	ExprContext *econtext = projInfo->pi_exprContext;378	ExprState  *state = &projInfo->pi_state;379	TupleTableSlot *slot = state->resultslot;380	bool		isnull;381 382	/*383	 * Clear any former contents of the result slot.  This makes it safe for384	 * us to use the slot's Datum/isnull arrays as workspace.385	 */386	ExecClearTuple(slot);387 388	/* Run the expression, discarding scalar result from the last column. */389	(void) ExecEvalExprSwitchContext(state, econtext, &isnull);390 391	/*392	 * Successfully formed a result row.  Mark the result slot as containing a393	 * valid virtual tuple (inlined version of ExecStoreVirtualTuple()).394	 */395	slot->tts_flags &= ~TTS_FLAG_EMPTY;396	slot->tts_nvalid = slot->tts_tupleDescriptor->natts;397 398	return slot;399}400#endif401 402/*403 * ExecQual - evaluate a qual prepared with ExecInitQual (possibly via404 * ExecPrepareQual).  Returns true if qual is satisfied, else false.405 *406 * Note: ExecQual used to have a third argument "resultForNull".  The407 * behavior of this function now corresponds to resultForNull == false.408 * If you want the resultForNull == true behavior, see ExecCheck.409 */410#ifndef FRONTEND411static inline bool412ExecQual(ExprState *state, ExprContext *econtext)413{414	Datum		ret;415	bool		isnull;416 417	/* short-circuit (here and in ExecInitQual) for empty restriction list */418	if (state == NULL)419		return true;420 421	/* verify that expression was compiled using ExecInitQual */422	Assert(state->flags & EEO_FLAG_IS_QUAL);423 424	ret = ExecEvalExprSwitchContext(state, econtext, &isnull);425 426	/* EEOP_QUAL should never return NULL */427	Assert(!isnull);428 429	return DatumGetBool(ret);430}431#endif432 433/*434 * ExecQualAndReset() - evaluate qual with ExecQual() and reset expression435 * context.436 */437#ifndef FRONTEND438static inline bool439ExecQualAndReset(ExprState *state, ExprContext *econtext)440{441	bool		ret = ExecQual(state, econtext);442 443	/* inline ResetExprContext, to avoid ordering issue in this file */444	MemoryContextReset(econtext->ecxt_per_tuple_memory);445	return ret;446}447#endif448 449extern bool ExecCheck(ExprState *state, ExprContext *econtext);450 451/*452 * prototypes from functions in execSRF.c453 */454extern SetExprState *ExecInitTableFunctionResult(Expr *expr,455												 ExprContext *econtext, PlanState *parent);456extern Tuplestorestate *ExecMakeTableFunctionResult(SetExprState *setexpr,457													ExprContext *econtext,458													MemoryContext argContext,459													TupleDesc expectedDesc,460													bool randomAccess);461extern SetExprState *ExecInitFunctionResultSet(Expr *expr,462											   ExprContext *econtext, PlanState *parent);463extern Datum ExecMakeFunctionResultSet(SetExprState *fcache,464									   ExprContext *econtext,465									   MemoryContext argContext,466									   bool *isNull,467									   ExprDoneCond *isDone);468 469/*470 * prototypes from functions in execScan.c471 */472typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);473typedef bool (*ExecScanRecheckMtd) (ScanState *node, TupleTableSlot *slot);474 475extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd,476								ExecScanRecheckMtd recheckMtd);477extern void ExecAssignScanProjectionInfo(ScanState *node);478extern void ExecAssignScanProjectionInfoWithVarno(ScanState *node, int varno);479extern void ExecScanReScan(ScanState *node);480 481/*482 * prototypes from functions in execTuples.c483 */484extern void ExecInitResultTypeTL(PlanState *planstate);485extern void ExecInitResultSlot(PlanState *planstate,486							   const TupleTableSlotOps *tts_ops);487extern void ExecInitResultTupleSlotTL(PlanState *planstate,488									  const TupleTableSlotOps *tts_ops);489extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate,490								  TupleDesc tupledesc,491								  const TupleTableSlotOps *tts_ops);492extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate,493											  TupleDesc tupledesc,494											  const TupleTableSlotOps *tts_ops);495extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, TupleDesc tupType,496											 const TupleTableSlotOps *tts_ops);497extern TupleDesc ExecTypeFromTL(List *targetList);498extern TupleDesc ExecCleanTypeFromTL(List *targetList);499extern TupleDesc ExecTypeFromExprList(List *exprList);500extern void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList);501extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);502 503typedef struct TupOutputState504{505	TupleTableSlot *slot;506	DestReceiver *dest;507} TupOutputState;508 509extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,510												TupleDesc tupdesc,511												const TupleTableSlotOps *tts_ops);512extern void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull);513extern void do_text_output_multiline(TupOutputState *tstate, const char *txt);514extern void end_tup_output(TupOutputState *tstate);515 516/*517 * Write a single line of text given as a C string.518 *519 * Should only be used with a single-TEXT-attribute tupdesc.520 */521#define do_text_output_oneline(tstate, str_to_emit) \522	do { \523		Datum	values_[1]; \524		bool	isnull_[1]; \525		values_[0] = PointerGetDatum(cstring_to_text(str_to_emit)); \526		isnull_[0] = false; \527		do_tup_output(tstate, values_, isnull_); \528		pfree(DatumGetPointer(values_[0])); \529	} while (0)530 531 532/*533 * prototypes from functions in execUtils.c534 */535extern EState *CreateExecutorState(void);536extern void FreeExecutorState(EState *estate);537extern ExprContext *CreateExprContext(EState *estate);538extern ExprContext *CreateWorkExprContext(EState *estate);539extern ExprContext *CreateStandaloneExprContext(void);540extern void FreeExprContext(ExprContext *econtext, bool isCommit);541extern void ReScanExprContext(ExprContext *econtext);542 543#define ResetExprContext(econtext) \544	MemoryContextReset((econtext)->ecxt_per_tuple_memory)545 546extern ExprContext *MakePerTupleExprContext(EState *estate);547 548/* Get an EState's per-output-tuple exprcontext, making it if first use */549#define GetPerTupleExprContext(estate) \550	((estate)->es_per_tuple_exprcontext ? \551	 (estate)->es_per_tuple_exprcontext : \552	 MakePerTupleExprContext(estate))553 554#define GetPerTupleMemoryContext(estate) \555	(GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)556 557/* Reset an EState's per-output-tuple exprcontext, if one's been created */558#define ResetPerTupleExprContext(estate) \559	do { \560		if ((estate)->es_per_tuple_exprcontext) \561			ResetExprContext((estate)->es_per_tuple_exprcontext); \562	} while (0)563 564extern void ExecAssignExprContext(EState *estate, PlanState *planstate);565extern TupleDesc ExecGetResultType(PlanState *planstate);566extern const TupleTableSlotOps *ExecGetResultSlotOps(PlanState *planstate,567													 bool *isfixed);568extern void ExecAssignProjectionInfo(PlanState *planstate,569									 TupleDesc inputDesc);570extern void ExecConditionalAssignProjectionInfo(PlanState *planstate,571												TupleDesc inputDesc, int varno);572extern void ExecFreeExprContext(PlanState *planstate);573extern void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc);574extern void ExecCreateScanSlotFromOuterPlan(EState *estate,575											ScanState *scanstate,576											const TupleTableSlotOps *tts_ops);577 578extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid);579 580extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags);581 582extern void ExecInitRangeTable(EState *estate, List *rangeTable, List *permInfos);583extern void ExecCloseRangeTableRelations(EState *estate);584extern void ExecCloseResultRelations(EState *estate);585 586static inline RangeTblEntry *587exec_rt_fetch(Index rti, EState *estate)588{589	return (RangeTblEntry *) list_nth(estate->es_range_table, rti - 1);590}591 592extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);593extern void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo,594								   Index rti);595 596extern int	executor_errposition(EState *estate, int location);597 598extern void RegisterExprContextCallback(ExprContext *econtext,599										ExprContextCallbackFunction function,600										Datum arg);601extern void UnregisterExprContextCallback(ExprContext *econtext,602										  ExprContextCallbackFunction function,603										  Datum arg);604 605extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,606								bool *isNull);607extern Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno,608							   bool *isNull);609 610extern int	ExecTargetListLength(List *targetlist);611extern int	ExecCleanTargetListLength(List *targetlist);612 613extern TupleTableSlot *ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo);614extern TupleTableSlot *ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo);615extern TupleTableSlot *ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo);616extern TupleConversionMap *ExecGetChildToRootMap(ResultRelInfo *resultRelInfo);617extern TupleConversionMap *ExecGetRootToChildMap(ResultRelInfo *resultRelInfo, EState *estate);618 619extern Oid	ExecGetResultRelCheckAsUser(ResultRelInfo *relInfo, EState *estate);620extern Bitmapset *ExecGetInsertedCols(ResultRelInfo *relinfo, EState *estate);621extern Bitmapset *ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate);622extern Bitmapset *ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate);623extern Bitmapset *ExecGetAllUpdatedCols(ResultRelInfo *relinfo, EState *estate);624 625/*626 * prototypes from functions in execIndexing.c627 */628extern void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative);629extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);630extern List *ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,631								   TupleTableSlot *slot, EState *estate,632								   bool update,633								   bool noDupErr,634								   bool *specConflict, List *arbiterIndexes,635								   bool onlySummarizing);636extern bool ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo,637									  TupleTableSlot *slot,638									  EState *estate, ItemPointer conflictTid,639									  List *arbiterIndexes);640extern void check_exclusion_constraint(Relation heap, Relation index,641									   IndexInfo *indexInfo,642									   ItemPointer tupleid,643									   Datum *values, bool *isnull,644									   EState *estate, bool newIndex);645 646/*647 * prototypes from functions in execReplication.c648 */649extern bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid,650										 LockTupleMode lockmode,651										 TupleTableSlot *searchslot,652										 TupleTableSlot *outslot);653extern bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,654									 TupleTableSlot *searchslot, TupleTableSlot *outslot);655 656extern void ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo,657									 EState *estate, TupleTableSlot *slot);658extern void ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo,659									 EState *estate, EPQState *epqstate,660									 TupleTableSlot *searchslot, TupleTableSlot *slot);661extern void ExecSimpleRelationDelete(ResultRelInfo *resultRelInfo,662									 EState *estate, EPQState *epqstate,663									 TupleTableSlot *searchslot);664extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);665 666extern void CheckSubscriptionRelkind(char relkind, const char *nspname,667									 const char *relname);668 669/*670 * prototypes from functions in nodeModifyTable.c671 */672extern TupleTableSlot *ExecGetUpdateNewTuple(ResultRelInfo *relinfo,673											 TupleTableSlot *planSlot,674											 TupleTableSlot *oldSlot);675extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,676											   Oid resultoid,677											   bool missing_ok,678											   bool update_cache);679 680#endif							/* EXECUTOR_H  */681 
codekingpro/portable-devtools · Team Ai