LCOV - code coverage report
Current view: top level - src/include/executor - executor.h (source / functions) Hit Total Coverage
Test: PostgreSQL 17devel Lines: 33 33 100.0 %
Date: 2024-04-19 11:11:06 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * executor.h
       4             :  *    support for the POSTGRES executor module
       5             :  *
       6             :  *
       7             :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
       8             :  * Portions Copyright (c) 1994, Regents of the University of California
       9             :  *
      10             :  * src/include/executor/executor.h
      11             :  *
      12             :  *-------------------------------------------------------------------------
      13             :  */
      14             : #ifndef EXECUTOR_H
      15             : #define EXECUTOR_H
      16             : 
      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 ExecInitNode
      26             :  * routines is a bitwise OR of the following flag bits, which tell the
      27             :  * called plan node what to expect.  Note that the flags will get modified
      28             :  * as they are passed down the plan tree, since an upper node may require
      29             :  * functionality in its subnode not demanded of the plan as a whole
      30             :  * (example: MergeJoin requires mark/restore capability in its inner input),
      31             :  * or an upper node may shield its input from some functionality requirement
      32             :  * (example: Materialize shields its input from needing to do backward scan).
      33             :  *
      34             :  * EXPLAIN_ONLY indicates that the plan tree is being initialized just so
      35             :  * EXPLAIN can print it out; it will not be run.  Hence, no side-effects
      36             :  * 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 indicates
      40             :  * that a generic plan is being shown using EXPLAIN (GENERIC_PLAN), which
      41             :  * means that missing parameter values must be tolerated.  Currently, the only
      42             :  * effect is to suppress execution-time partition pruning.
      43             :  *
      44             :  * REWIND indicates that the plan node should try to efficiently support
      45             :  * rescans without parameter changes.  (Nodes must support ExecReScan calls
      46             :  * in any case, but if this flag was not given, they are at liberty to do it
      47             :  * through complete recalculation.  Note that a parameter change forces a
      48             :  * 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 calling
      57             :  * AfterTriggerBeginQuery/AfterTriggerEndQuery.  This does not necessarily
      58             :  * mean that the plan can't queue any AFTER triggers; just that the caller
      59             :  * 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 VIEW
      62             :  * ... WITH NO DATA.  Currently, the only effect is to suppress errors about
      63             :  * 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() */
      75             : typedef void (*ExecutorStart_hook_type) (QueryDesc *queryDesc, int eflags);
      76             : extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook;
      77             : 
      78             : /* Hook for plugins to get control in ExecutorRun() */
      79             : typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc,
      80             :                                        ScanDirection direction,
      81             :                                        uint64 count,
      82             :                                        bool execute_once);
      83             : extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;
      84             : 
      85             : /* Hook for plugins to get control in ExecutorFinish() */
      86             : typedef void (*ExecutorFinish_hook_type) (QueryDesc *queryDesc);
      87             : extern PGDLLIMPORT ExecutorFinish_hook_type ExecutorFinish_hook;
      88             : 
      89             : /* Hook for plugins to get control in ExecutorEnd() */
      90             : typedef void (*ExecutorEnd_hook_type) (QueryDesc *queryDesc);
      91             : extern PGDLLIMPORT ExecutorEnd_hook_type ExecutorEnd_hook;
      92             : 
      93             : /* Hook for plugins to get control in ExecCheckPermissions() */
      94             : typedef bool (*ExecutorCheckPerms_hook_type) (List *rangeTable,
      95             :                                               List *rtePermInfos,
      96             :                                               bool ereport_on_violation);
      97             : extern PGDLLIMPORT ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook;
      98             : 
      99             : 
     100             : /*
     101             :  * prototypes from functions in execAmi.c
     102             :  */
     103             : struct Path;                    /* avoid including pathnodes.h here */
     104             : 
     105             : extern void ExecReScan(PlanState *node);
     106             : extern void ExecMarkPos(PlanState *node);
     107             : extern void ExecRestrPos(PlanState *node);
     108             : extern bool ExecSupportsMarkRestore(struct Path *pathnode);
     109             : extern bool ExecSupportsBackwardScan(Plan *node);
     110             : extern bool ExecMaterializesOutput(NodeTag plantype);
     111             : 
     112             : /*
     113             :  * prototypes from functions in execCurrent.c
     114             :  */
     115             : extern bool execCurrentOf(CurrentOfExpr *cexpr,
     116             :                           ExprContext *econtext,
     117             :                           Oid table_oid,
     118             :                           ItemPointer current_tid);
     119             : 
     120             : /*
     121             :  * prototypes from functions in execGrouping.c
     122             :  */
     123             : extern ExprState *execTuplesMatchPrepare(TupleDesc desc,
     124             :                                          int numCols,
     125             :                                          const AttrNumber *keyColIdx,
     126             :                                          const Oid *eqOperators,
     127             :                                          const Oid *collations,
     128             :                                          PlanState *parent);
     129             : extern void execTuplesHashPrepare(int numCols,
     130             :                                   const Oid *eqOperators,
     131             :                                   Oid **eqFuncOids,
     132             :                                   FmgrInfo **hashFunctions);
     133             : extern 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);
     142             : extern 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);
     152             : extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
     153             :                                            TupleTableSlot *slot,
     154             :                                            bool *isnew, uint32 *hash);
     155             : extern uint32 TupleHashTableHash(TupleHashTable hashtable,
     156             :                                  TupleTableSlot *slot);
     157             : extern TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable,
     158             :                                                TupleTableSlot *slot,
     159             :                                                bool *isnew, uint32 hash);
     160             : extern TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable,
     161             :                                          TupleTableSlot *slot,
     162             :                                          ExprState *eqcomp,
     163             :                                          FmgrInfo *hashfunctions);
     164             : extern void ResetTupleHashTable(TupleHashTable hashtable);
     165             : 
     166             : /*
     167             :  * prototypes from functions in execJunk.c
     168             :  */
     169             : extern JunkFilter *ExecInitJunkFilter(List *targetList,
     170             :                                       TupleTableSlot *slot);
     171             : extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
     172             :                                                 TupleDesc cleanTupType,
     173             :                                                 TupleTableSlot *slot);
     174             : extern AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter,
     175             :                                         const char *attrName);
     176             : extern AttrNumber ExecFindJunkAttributeInTlist(List *targetlist,
     177             :                                                const char *attrName);
     178             : extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,
     179             :                                       TupleTableSlot *slot);
     180             : 
     181             : /*
     182             :  * ExecGetJunkAttribute
     183             :  *
     184             :  * Given a junk filter's input tuple (slot) and a junk attribute's number
     185             :  * previously found by ExecFindJunkAttribute, extract & return the value and
     186             :  * isNull flag of the attribute.
     187             :  */
     188             : #ifndef FRONTEND
     189             : static inline Datum
     190     1857200 : ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
     191             : {
     192             :     Assert(attno > 0);
     193     1857200 :     return slot_getattr(slot, attno, isNull);
     194             : }
     195             : #endif
     196             : 
     197             : /*
     198             :  * prototypes from functions in execMain.c
     199             :  */
     200             : extern void ExecutorStart(QueryDesc *queryDesc, int eflags);
     201             : extern void standard_ExecutorStart(QueryDesc *queryDesc, int eflags);
     202             : extern void ExecutorRun(QueryDesc *queryDesc,
     203             :                         ScanDirection direction, uint64 count, bool execute_once);
     204             : extern void standard_ExecutorRun(QueryDesc *queryDesc,
     205             :                                  ScanDirection direction, uint64 count, bool execute_once);
     206             : extern void ExecutorFinish(QueryDesc *queryDesc);
     207             : extern void standard_ExecutorFinish(QueryDesc *queryDesc);
     208             : extern void ExecutorEnd(QueryDesc *queryDesc);
     209             : extern void standard_ExecutorEnd(QueryDesc *queryDesc);
     210             : extern void ExecutorRewind(QueryDesc *queryDesc);
     211             : extern bool ExecCheckPermissions(List *rangeTable,
     212             :                                  List *rteperminfos, bool ereport_on_violation);
     213             : extern void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation,
     214             :                                 List *mergeActions);
     215             : extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,
     216             :                               Relation resultRelationDesc,
     217             :                               Index resultRelationIndex,
     218             :                               ResultRelInfo *partition_root_rri,
     219             :                               int instrument_options);
     220             : extern ResultRelInfo *ExecGetTriggerResultRel(EState *estate, Oid relid,
     221             :                                               ResultRelInfo *rootRelInfo);
     222             : extern List *ExecGetAncestorResultRels(EState *estate, ResultRelInfo *resultRelInfo);
     223             : extern void ExecConstraints(ResultRelInfo *resultRelInfo,
     224             :                             TupleTableSlot *slot, EState *estate);
     225             : extern bool ExecPartitionCheck(ResultRelInfo *resultRelInfo,
     226             :                                TupleTableSlot *slot, EState *estate, bool emitError);
     227             : extern void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
     228             :                                         TupleTableSlot *slot, EState *estate);
     229             : extern void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
     230             :                                  TupleTableSlot *slot, EState *estate);
     231             : extern LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo);
     232             : extern ExecRowMark *ExecFindRowMark(EState *estate, Index rti, bool missing_ok);
     233             : extern ExecAuxRowMark *ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist);
     234             : extern TupleTableSlot *EvalPlanQual(EPQState *epqstate, Relation relation,
     235             :                                     Index rti, TupleTableSlot *inputslot);
     236             : extern void EvalPlanQualInit(EPQState *epqstate, EState *parentestate,
     237             :                              Plan *subplan, List *auxrowmarks,
     238             :                              int epqParam, List *resultRelations);
     239             : extern void EvalPlanQualSetPlan(EPQState *epqstate,
     240             :                                 Plan *subplan, List *auxrowmarks);
     241             : extern TupleTableSlot *EvalPlanQualSlot(EPQState *epqstate,
     242             :                                         Relation relation, Index rti);
     243             : 
     244             : #define EvalPlanQualSetSlot(epqstate, slot)  ((epqstate)->origslot = (slot))
     245             : extern bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot);
     246             : extern TupleTableSlot *EvalPlanQualNext(EPQState *epqstate);
     247             : extern void EvalPlanQualBegin(EPQState *epqstate);
     248             : extern void EvalPlanQualEnd(EPQState *epqstate);
     249             : 
     250             : /*
     251             :  * functions in execProcnode.c
     252             :  */
     253             : extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);
     254             : extern void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function);
     255             : extern Node *MultiExecProcNode(PlanState *node);
     256             : extern void ExecEndNode(PlanState *node);
     257             : extern void ExecShutdownNode(PlanState *node);
     258             : extern void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node);
     259             : 
     260             : 
     261             : /* ----------------------------------------------------------------
     262             :  *      ExecProcNode
     263             :  *
     264             :  *      Execute the given node to return a(nother) tuple.
     265             :  * ----------------------------------------------------------------
     266             :  */
     267             : #ifndef FRONTEND
     268             : static inline TupleTableSlot *
     269   113299422 : ExecProcNode(PlanState *node)
     270             : {
     271   113299422 :     if (node->chgParam != NULL) /* something changed? */
     272      205328 :         ExecReScan(node);       /* let ReScan handle this */
     273             : 
     274   113299422 :     return node->ExecProcNode(node);
     275             : }
     276             : #endif
     277             : 
     278             : /*
     279             :  * prototypes from functions in execExpr.c
     280             :  */
     281             : extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
     282             : extern ExprState *ExecInitExprWithParams(Expr *node, ParamListInfo ext_params);
     283             : extern ExprState *ExecInitQual(List *qual, PlanState *parent);
     284             : extern ExprState *ExecInitCheck(List *qual, PlanState *parent);
     285             : extern List *ExecInitExprList(List *nodes, PlanState *parent);
     286             : extern ExprState *ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase,
     287             :                                     bool doSort, bool doHash, bool nullcheck);
     288             : extern ExprState *ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
     289             :                                          const TupleTableSlotOps *lops, const TupleTableSlotOps *rops,
     290             :                                          int numCols,
     291             :                                          const AttrNumber *keyColIdx,
     292             :                                          const Oid *eqfunctions,
     293             :                                          const Oid *collations,
     294             :                                          PlanState *parent);
     295             : extern ExprState *ExecBuildParamSetEqual(TupleDesc desc,
     296             :                                          const TupleTableSlotOps *lops,
     297             :                                          const TupleTableSlotOps *rops,
     298             :                                          const Oid *eqfunctions,
     299             :                                          const Oid *collations,
     300             :                                          const List *param_exprs,
     301             :                                          PlanState *parent);
     302             : extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
     303             :                                                ExprContext *econtext,
     304             :                                                TupleTableSlot *slot,
     305             :                                                PlanState *parent,
     306             :                                                TupleDesc inputDesc);
     307             : extern ProjectionInfo *ExecBuildUpdateProjection(List *targetList,
     308             :                                                  bool evalTargetList,
     309             :                                                  List *targetColnos,
     310             :                                                  TupleDesc relDesc,
     311             :                                                  ExprContext *econtext,
     312             :                                                  TupleTableSlot *slot,
     313             :                                                  PlanState *parent);
     314             : extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
     315             : extern ExprState *ExecPrepareQual(List *qual, EState *estate);
     316             : extern ExprState *ExecPrepareCheck(List *qual, EState *estate);
     317             : extern List *ExecPrepareExprList(List *nodes, EState *estate);
     318             : 
     319             : /*
     320             :  * ExecEvalExpr
     321             :  *
     322             :  * Evaluate expression identified by "state" in the execution context
     323             :  * given by "econtext".  *isNull is set to the is-null flag for the result,
     324             :  * and the Datum value is the function result.
     325             :  *
     326             :  * The caller should already have switched into the temporary memory
     327             :  * context econtext->ecxt_per_tuple_memory.  The convenience entry point
     328             :  * ExecEvalExprSwitchContext() is provided for callers who don't prefer to
     329             :  * do the switch in an outer loop.
     330             :  */
     331             : #ifndef FRONTEND
     332             : static inline Datum
     333    38268338 : ExecEvalExpr(ExprState *state,
     334             :              ExprContext *econtext,
     335             :              bool *isNull)
     336             : {
     337    38268338 :     return state->evalfunc(state, econtext, isNull);
     338             : }
     339             : #endif
     340             : 
     341             : /*
     342             :  * ExecEvalExprSwitchContext
     343             :  *
     344             :  * Same as ExecEvalExpr, but get into the right allocation context explicitly.
     345             :  */
     346             : #ifndef FRONTEND
     347             : static inline Datum
     348   153998712 : ExecEvalExprSwitchContext(ExprState *state,
     349             :                           ExprContext *econtext,
     350             :                           bool *isNull)
     351             : {
     352             :     Datum       retDatum;
     353             :     MemoryContext oldContext;
     354             : 
     355   153998712 :     oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
     356   153998712 :     retDatum = state->evalfunc(state, econtext, isNull);
     357   153981510 :     MemoryContextSwitchTo(oldContext);
     358   153981510 :     return retDatum;
     359             : }
     360             : #endif
     361             : 
     362             : /*
     363             :  * ExecProject
     364             :  *
     365             :  * Projects a tuple based on projection info and stores it in the slot passed
     366             :  * to ExecBuildProjectionInfo().
     367             :  *
     368             :  * Note: the result is always a virtual tuple; therefore it may reference
     369             :  * the contents of the exprContext's scan tuples and/or temporary results
     370             :  * constructed in the exprContext.  If the caller wishes the result to be
     371             :  * valid longer than that data will be valid, he must call ExecMaterializeSlot
     372             :  * on the result slot.
     373             :  */
     374             : #ifndef FRONTEND
     375             : static inline TupleTableSlot *
     376    61801024 : ExecProject(ProjectionInfo *projInfo)
     377             : {
     378    61801024 :     ExprContext *econtext = projInfo->pi_exprContext;
     379    61801024 :     ExprState  *state = &projInfo->pi_state;
     380    61801024 :     TupleTableSlot *slot = state->resultslot;
     381             :     bool        isnull;
     382             : 
     383             :     /*
     384             :      * Clear any former contents of the result slot.  This makes it safe for
     385             :      * us to use the slot's Datum/isnull arrays as workspace.
     386             :      */
     387    61801024 :     ExecClearTuple(slot);
     388             : 
     389             :     /* Run the expression, discarding scalar result from the last column. */
     390    61801024 :     (void) ExecEvalExprSwitchContext(state, econtext, &isnull);
     391             : 
     392             :     /*
     393             :      * Successfully formed a result row.  Mark the result slot as containing a
     394             :      * valid virtual tuple (inlined version of ExecStoreVirtualTuple()).
     395             :      */
     396    61787506 :     slot->tts_flags &= ~TTS_FLAG_EMPTY;
     397    61787506 :     slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
     398             : 
     399    61787506 :     return slot;
     400             : }
     401             : #endif
     402             : 
     403             : /*
     404             :  * ExecQual - evaluate a qual prepared with ExecInitQual (possibly via
     405             :  * ExecPrepareQual).  Returns true if qual is satisfied, else false.
     406             :  *
     407             :  * Note: ExecQual used to have a third argument "resultForNull".  The
     408             :  * behavior of this function now corresponds to resultForNull == false.
     409             :  * If you want the resultForNull == true behavior, see ExecCheck.
     410             :  */
     411             : #ifndef FRONTEND
     412             : static inline bool
     413    69250312 : ExecQual(ExprState *state, ExprContext *econtext)
     414             : {
     415             :     Datum       ret;
     416             :     bool        isnull;
     417             : 
     418             :     /* short-circuit (here and in ExecInitQual) for empty restriction list */
     419    69250312 :     if (state == NULL)
     420     4953918 :         return true;
     421             : 
     422             :     /* verify that expression was compiled using ExecInitQual */
     423             :     Assert(state->flags & EEO_FLAG_IS_QUAL);
     424             : 
     425    64296394 :     ret = ExecEvalExprSwitchContext(state, econtext, &isnull);
     426             : 
     427             :     /* EEOP_QUAL should never return NULL */
     428             :     Assert(!isnull);
     429             : 
     430    64296336 :     return DatumGetBool(ret);
     431             : }
     432             : #endif
     433             : 
     434             : /*
     435             :  * ExecQualAndReset() - evaluate qual with ExecQual() and reset expression
     436             :  * context.
     437             :  */
     438             : #ifndef FRONTEND
     439             : static inline bool
     440    20240128 : ExecQualAndReset(ExprState *state, ExprContext *econtext)
     441             : {
     442    20240128 :     bool        ret = ExecQual(state, econtext);
     443             : 
     444             :     /* inline ResetExprContext, to avoid ordering issue in this file */
     445    20240128 :     MemoryContextReset(econtext->ecxt_per_tuple_memory);
     446    20240128 :     return ret;
     447             : }
     448             : #endif
     449             : 
     450             : extern bool ExecCheck(ExprState *state, ExprContext *econtext);
     451             : 
     452             : /*
     453             :  * prototypes from functions in execSRF.c
     454             :  */
     455             : extern SetExprState *ExecInitTableFunctionResult(Expr *expr,
     456             :                                                  ExprContext *econtext, PlanState *parent);
     457             : extern Tuplestorestate *ExecMakeTableFunctionResult(SetExprState *setexpr,
     458             :                                                     ExprContext *econtext,
     459             :                                                     MemoryContext argContext,
     460             :                                                     TupleDesc expectedDesc,
     461             :                                                     bool randomAccess);
     462             : extern SetExprState *ExecInitFunctionResultSet(Expr *expr,
     463             :                                                ExprContext *econtext, PlanState *parent);
     464             : extern Datum ExecMakeFunctionResultSet(SetExprState *fcache,
     465             :                                        ExprContext *econtext,
     466             :                                        MemoryContext argContext,
     467             :                                        bool *isNull,
     468             :                                        ExprDoneCond *isDone);
     469             : 
     470             : /*
     471             :  * prototypes from functions in execScan.c
     472             :  */
     473             : typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
     474             : typedef bool (*ExecScanRecheckMtd) (ScanState *node, TupleTableSlot *slot);
     475             : 
     476             : extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd,
     477             :                                 ExecScanRecheckMtd recheckMtd);
     478             : extern void ExecAssignScanProjectionInfo(ScanState *node);
     479             : extern void ExecAssignScanProjectionInfoWithVarno(ScanState *node, int varno);
     480             : extern void ExecScanReScan(ScanState *node);
     481             : 
     482             : /*
     483             :  * prototypes from functions in execTuples.c
     484             :  */
     485             : extern void ExecInitResultTypeTL(PlanState *planstate);
     486             : extern void ExecInitResultSlot(PlanState *planstate,
     487             :                                const TupleTableSlotOps *tts_ops);
     488             : extern void ExecInitResultTupleSlotTL(PlanState *planstate,
     489             :                                       const TupleTableSlotOps *tts_ops);
     490             : extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate,
     491             :                                   TupleDesc tupledesc,
     492             :                                   const TupleTableSlotOps *tts_ops);
     493             : extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate,
     494             :                                               TupleDesc tupledesc,
     495             :                                               const TupleTableSlotOps *tts_ops);
     496             : extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, TupleDesc tupType,
     497             :                                              const TupleTableSlotOps *tts_ops);
     498             : extern TupleDesc ExecTypeFromTL(List *targetList);
     499             : extern TupleDesc ExecCleanTypeFromTL(List *targetList);
     500             : extern TupleDesc ExecTypeFromExprList(List *exprList);
     501             : extern void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList);
     502             : extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
     503             : 
     504             : typedef struct TupOutputState
     505             : {
     506             :     TupleTableSlot *slot;
     507             :     DestReceiver *dest;
     508             : } TupOutputState;
     509             : 
     510             : extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,
     511             :                                                 TupleDesc tupdesc,
     512             :                                                 const TupleTableSlotOps *tts_ops);
     513             : extern void do_tup_output(TupOutputState *tstate, const Datum *values, const bool *isnull);
     514             : extern void do_text_output_multiline(TupOutputState *tstate, const char *txt);
     515             : extern void end_tup_output(TupOutputState *tstate);
     516             : 
     517             : /*
     518             :  * Write a single line of text given as a C string.
     519             :  *
     520             :  * Should only be used with a single-TEXT-attribute tupdesc.
     521             :  */
     522             : #define do_text_output_oneline(tstate, str_to_emit) \
     523             :     do { \
     524             :         Datum   values_[1]; \
     525             :         bool    isnull_[1]; \
     526             :         values_[0] = PointerGetDatum(cstring_to_text(str_to_emit)); \
     527             :         isnull_[0] = false; \
     528             :         do_tup_output(tstate, values_, isnull_); \
     529             :         pfree(DatumGetPointer(values_[0])); \
     530             :     } while (0)
     531             : 
     532             : 
     533             : /*
     534             :  * prototypes from functions in execUtils.c
     535             :  */
     536             : extern EState *CreateExecutorState(void);
     537             : extern void FreeExecutorState(EState *estate);
     538             : extern ExprContext *CreateExprContext(EState *estate);
     539             : extern ExprContext *CreateWorkExprContext(EState *estate);
     540             : extern ExprContext *CreateStandaloneExprContext(void);
     541             : extern void FreeExprContext(ExprContext *econtext, bool isCommit);
     542             : extern void ReScanExprContext(ExprContext *econtext);
     543             : 
     544             : #define ResetExprContext(econtext) \
     545             :     MemoryContextReset((econtext)->ecxt_per_tuple_memory)
     546             : 
     547             : extern ExprContext *MakePerTupleExprContext(EState *estate);
     548             : 
     549             : /* Get an EState's per-output-tuple exprcontext, making it if first use */
     550             : #define GetPerTupleExprContext(estate) \
     551             :     ((estate)->es_per_tuple_exprcontext ? \
     552             :      (estate)->es_per_tuple_exprcontext : \
     553             :      MakePerTupleExprContext(estate))
     554             : 
     555             : #define GetPerTupleMemoryContext(estate) \
     556             :     (GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)
     557             : 
     558             : /* Reset an EState's per-output-tuple exprcontext, if one's been created */
     559             : #define ResetPerTupleExprContext(estate) \
     560             :     do { \
     561             :         if ((estate)->es_per_tuple_exprcontext) \
     562             :             ResetExprContext((estate)->es_per_tuple_exprcontext); \
     563             :     } while (0)
     564             : 
     565             : extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
     566             : extern TupleDesc ExecGetResultType(PlanState *planstate);
     567             : extern const TupleTableSlotOps *ExecGetResultSlotOps(PlanState *planstate,
     568             :                                                      bool *isfixed);
     569             : extern void ExecAssignProjectionInfo(PlanState *planstate,
     570             :                                      TupleDesc inputDesc);
     571             : extern void ExecConditionalAssignProjectionInfo(PlanState *planstate,
     572             :                                                 TupleDesc inputDesc, int varno);
     573             : extern void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc);
     574             : extern void ExecCreateScanSlotFromOuterPlan(EState *estate,
     575             :                                             ScanState *scanstate,
     576             :                                             const TupleTableSlotOps *tts_ops);
     577             : 
     578             : extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid);
     579             : 
     580             : extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags);
     581             : 
     582             : extern void ExecInitRangeTable(EState *estate, List *rangeTable, List *permInfos);
     583             : extern void ExecCloseRangeTableRelations(EState *estate);
     584             : extern void ExecCloseResultRelations(EState *estate);
     585             : 
     586             : static inline RangeTblEntry *
     587      722468 : exec_rt_fetch(Index rti, EState *estate)
     588             : {
     589      722468 :     return (RangeTblEntry *) list_nth(estate->es_range_table, rti - 1);
     590             : }
     591             : 
     592             : extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
     593             : extern void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo,
     594             :                                    Index rti);
     595             : 
     596             : extern int  executor_errposition(EState *estate, int location);
     597             : 
     598             : extern void RegisterExprContextCallback(ExprContext *econtext,
     599             :                                         ExprContextCallbackFunction function,
     600             :                                         Datum arg);
     601             : extern void UnregisterExprContextCallback(ExprContext *econtext,
     602             :                                           ExprContextCallbackFunction function,
     603             :                                           Datum arg);
     604             : 
     605             : extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
     606             :                                 bool *isNull);
     607             : extern Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno,
     608             :                                bool *isNull);
     609             : 
     610             : extern int  ExecTargetListLength(List *targetlist);
     611             : extern int  ExecCleanTargetListLength(List *targetlist);
     612             : 
     613             : extern TupleTableSlot *ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo);
     614             : extern TupleTableSlot *ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo);
     615             : extern TupleTableSlot *ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo);
     616             : extern TupleConversionMap *ExecGetChildToRootMap(ResultRelInfo *resultRelInfo);
     617             : extern TupleConversionMap *ExecGetRootToChildMap(ResultRelInfo *resultRelInfo, EState *estate);
     618             : 
     619             : extern Oid  ExecGetResultRelCheckAsUser(ResultRelInfo *relInfo, EState *estate);
     620             : extern Bitmapset *ExecGetInsertedCols(ResultRelInfo *relinfo, EState *estate);
     621             : extern Bitmapset *ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate);
     622             : extern Bitmapset *ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate);
     623             : extern Bitmapset *ExecGetAllUpdatedCols(ResultRelInfo *relinfo, EState *estate);
     624             : 
     625             : /*
     626             :  * prototypes from functions in execIndexing.c
     627             :  */
     628             : extern void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative);
     629             : extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
     630             : extern List *ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
     631             :                                    TupleTableSlot *slot, EState *estate,
     632             :                                    bool update,
     633             :                                    bool noDupErr,
     634             :                                    bool *specConflict, List *arbiterIndexes,
     635             :                                    bool onlySummarizing);
     636             : extern bool ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo,
     637             :                                       TupleTableSlot *slot,
     638             :                                       EState *estate, ItemPointer conflictTid,
     639             :                                       List *arbiterIndexes);
     640             : extern void check_exclusion_constraint(Relation heap, Relation index,
     641             :                                        IndexInfo *indexInfo,
     642             :                                        ItemPointer tupleid,
     643             :                                        const Datum *values, const bool *isnull,
     644             :                                        EState *estate, bool newIndex);
     645             : 
     646             : /*
     647             :  * prototypes from functions in execReplication.c
     648             :  */
     649             : extern StrategyNumber get_equal_strategy_number_for_am(Oid am);
     650             : extern bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid,
     651             :                                          LockTupleMode lockmode,
     652             :                                          TupleTableSlot *searchslot,
     653             :                                          TupleTableSlot *outslot);
     654             : extern bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
     655             :                                      TupleTableSlot *searchslot, TupleTableSlot *outslot);
     656             : 
     657             : extern void ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo,
     658             :                                      EState *estate, TupleTableSlot *slot);
     659             : extern void ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo,
     660             :                                      EState *estate, EPQState *epqstate,
     661             :                                      TupleTableSlot *searchslot, TupleTableSlot *slot);
     662             : extern void ExecSimpleRelationDelete(ResultRelInfo *resultRelInfo,
     663             :                                      EState *estate, EPQState *epqstate,
     664             :                                      TupleTableSlot *searchslot);
     665             : extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);
     666             : 
     667             : extern void CheckSubscriptionRelkind(char relkind, const char *nspname,
     668             :                                      const char *relname);
     669             : 
     670             : /*
     671             :  * prototypes from functions in nodeModifyTable.c
     672             :  */
     673             : extern TupleTableSlot *ExecGetUpdateNewTuple(ResultRelInfo *relinfo,
     674             :                                              TupleTableSlot *planSlot,
     675             :                                              TupleTableSlot *oldSlot);
     676             : extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,
     677             :                                                Oid resultoid,
     678             :                                                bool missing_ok,
     679             :                                                bool update_cache);
     680             : 
     681             : #endif                          /* EXECUTOR_H  */

Generated by: LCOV version 1.14