LCOV - code coverage report
Current view: top level - src/include/executor - executor.h (source / functions) Hit Total Coverage
Test: PostgreSQL 18devel Lines: 33 33 100.0 %
Date: 2024-12-02 19:14:57 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     1984998 : ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
     191             : {
     192             :     Assert(attno > 0);
     193     1984998 :     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 char *ExecBuildSlotValueDescription(Oid reloid, TupleTableSlot *slot,
     232             :                                            TupleDesc tupdesc,
     233             :                                            Bitmapset *modifiedCols,
     234             :                                            int maxfieldlen);
     235             : extern LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo);
     236             : extern ExecRowMark *ExecFindRowMark(EState *estate, Index rti, bool missing_ok);
     237             : extern ExecAuxRowMark *ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist);
     238             : extern TupleTableSlot *EvalPlanQual(EPQState *epqstate, Relation relation,
     239             :                                     Index rti, TupleTableSlot *inputslot);
     240             : extern void EvalPlanQualInit(EPQState *epqstate, EState *parentestate,
     241             :                              Plan *subplan, List *auxrowmarks,
     242             :                              int epqParam, List *resultRelations);
     243             : extern void EvalPlanQualSetPlan(EPQState *epqstate,
     244             :                                 Plan *subplan, List *auxrowmarks);
     245             : extern TupleTableSlot *EvalPlanQualSlot(EPQState *epqstate,
     246             :                                         Relation relation, Index rti);
     247             : 
     248             : #define EvalPlanQualSetSlot(epqstate, slot)  ((epqstate)->origslot = (slot))
     249             : extern bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot);
     250             : extern TupleTableSlot *EvalPlanQualNext(EPQState *epqstate);
     251             : extern void EvalPlanQualBegin(EPQState *epqstate);
     252             : extern void EvalPlanQualEnd(EPQState *epqstate);
     253             : 
     254             : /*
     255             :  * functions in execProcnode.c
     256             :  */
     257             : extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);
     258             : extern void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function);
     259             : extern Node *MultiExecProcNode(PlanState *node);
     260             : extern void ExecEndNode(PlanState *node);
     261             : extern void ExecShutdownNode(PlanState *node);
     262             : extern void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node);
     263             : 
     264             : 
     265             : /* ----------------------------------------------------------------
     266             :  *      ExecProcNode
     267             :  *
     268             :  *      Execute the given node to return a(nother) tuple.
     269             :  * ----------------------------------------------------------------
     270             :  */
     271             : #ifndef FRONTEND
     272             : static inline TupleTableSlot *
     273   115411636 : ExecProcNode(PlanState *node)
     274             : {
     275   115411636 :     if (node->chgParam != NULL) /* something changed? */
     276      217274 :         ExecReScan(node);       /* let ReScan handle this */
     277             : 
     278   115411636 :     return node->ExecProcNode(node);
     279             : }
     280             : #endif
     281             : 
     282             : /*
     283             :  * prototypes from functions in execExpr.c
     284             :  */
     285             : extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
     286             : extern ExprState *ExecInitExprWithParams(Expr *node, ParamListInfo ext_params);
     287             : extern ExprState *ExecInitQual(List *qual, PlanState *parent);
     288             : extern ExprState *ExecInitCheck(List *qual, PlanState *parent);
     289             : extern List *ExecInitExprList(List *nodes, PlanState *parent);
     290             : extern ExprState *ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase,
     291             :                                     bool doSort, bool doHash, bool nullcheck);
     292             : extern ExprState *ExecBuildHash32Expr(TupleDesc desc,
     293             :                                       const TupleTableSlotOps *ops,
     294             :                                       const Oid *hashfunc_oids,
     295             :                                       const List *collations,
     296             :                                       const List *hash_exprs,
     297             :                                       const bool *opstrict, PlanState *parent,
     298             :                                       uint32 init_value, bool keep_nulls);
     299             : extern ExprState *ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
     300             :                                          const TupleTableSlotOps *lops, const TupleTableSlotOps *rops,
     301             :                                          int numCols,
     302             :                                          const AttrNumber *keyColIdx,
     303             :                                          const Oid *eqfunctions,
     304             :                                          const Oid *collations,
     305             :                                          PlanState *parent);
     306             : extern ExprState *ExecBuildParamSetEqual(TupleDesc desc,
     307             :                                          const TupleTableSlotOps *lops,
     308             :                                          const TupleTableSlotOps *rops,
     309             :                                          const Oid *eqfunctions,
     310             :                                          const Oid *collations,
     311             :                                          const List *param_exprs,
     312             :                                          PlanState *parent);
     313             : extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
     314             :                                                ExprContext *econtext,
     315             :                                                TupleTableSlot *slot,
     316             :                                                PlanState *parent,
     317             :                                                TupleDesc inputDesc);
     318             : extern ProjectionInfo *ExecBuildUpdateProjection(List *targetList,
     319             :                                                  bool evalTargetList,
     320             :                                                  List *targetColnos,
     321             :                                                  TupleDesc relDesc,
     322             :                                                  ExprContext *econtext,
     323             :                                                  TupleTableSlot *slot,
     324             :                                                  PlanState *parent);
     325             : extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
     326             : extern ExprState *ExecPrepareQual(List *qual, EState *estate);
     327             : extern ExprState *ExecPrepareCheck(List *qual, EState *estate);
     328             : extern List *ExecPrepareExprList(List *nodes, EState *estate);
     329             : 
     330             : /*
     331             :  * ExecEvalExpr
     332             :  *
     333             :  * Evaluate expression identified by "state" in the execution context
     334             :  * given by "econtext".  *isNull is set to the is-null flag for the result,
     335             :  * and the Datum value is the function result.
     336             :  *
     337             :  * The caller should already have switched into the temporary memory
     338             :  * context econtext->ecxt_per_tuple_memory.  The convenience entry point
     339             :  * ExecEvalExprSwitchContext() is provided for callers who don't prefer to
     340             :  * do the switch in an outer loop.
     341             :  */
     342             : #ifndef FRONTEND
     343             : static inline Datum
     344    11873720 : ExecEvalExpr(ExprState *state,
     345             :              ExprContext *econtext,
     346             :              bool *isNull)
     347             : {
     348    11873720 :     return state->evalfunc(state, econtext, isNull);
     349             : }
     350             : #endif
     351             : 
     352             : /*
     353             :  * ExecEvalExprSwitchContext
     354             :  *
     355             :  * Same as ExecEvalExpr, but get into the right allocation context explicitly.
     356             :  */
     357             : #ifndef FRONTEND
     358             : static inline Datum
     359   189311530 : ExecEvalExprSwitchContext(ExprState *state,
     360             :                           ExprContext *econtext,
     361             :                           bool *isNull)
     362             : {
     363             :     Datum       retDatum;
     364             :     MemoryContext oldContext;
     365             : 
     366   189311530 :     oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
     367   189311530 :     retDatum = state->evalfunc(state, econtext, isNull);
     368   189294194 :     MemoryContextSwitchTo(oldContext);
     369   189294194 :     return retDatum;
     370             : }
     371             : #endif
     372             : 
     373             : /*
     374             :  * ExecProject
     375             :  *
     376             :  * Projects a tuple based on projection info and stores it in the slot passed
     377             :  * to ExecBuildProjectionInfo().
     378             :  *
     379             :  * Note: the result is always a virtual tuple; therefore it may reference
     380             :  * the contents of the exprContext's scan tuples and/or temporary results
     381             :  * constructed in the exprContext.  If the caller wishes the result to be
     382             :  * valid longer than that data will be valid, he must call ExecMaterializeSlot
     383             :  * on the result slot.
     384             :  */
     385             : #ifndef FRONTEND
     386             : static inline TupleTableSlot *
     387    62540056 : ExecProject(ProjectionInfo *projInfo)
     388             : {
     389    62540056 :     ExprContext *econtext = projInfo->pi_exprContext;
     390    62540056 :     ExprState  *state = &projInfo->pi_state;
     391    62540056 :     TupleTableSlot *slot = state->resultslot;
     392             :     bool        isnull;
     393             : 
     394             :     /*
     395             :      * Clear any former contents of the result slot.  This makes it safe for
     396             :      * us to use the slot's Datum/isnull arrays as workspace.
     397             :      */
     398    62540056 :     ExecClearTuple(slot);
     399             : 
     400             :     /* Run the expression, discarding scalar result from the last column. */
     401    62540056 :     (void) ExecEvalExprSwitchContext(state, econtext, &isnull);
     402             : 
     403             :     /*
     404             :      * Successfully formed a result row.  Mark the result slot as containing a
     405             :      * valid virtual tuple (inlined version of ExecStoreVirtualTuple()).
     406             :      */
     407    62526488 :     slot->tts_flags &= ~TTS_FLAG_EMPTY;
     408    62526488 :     slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
     409             : 
     410    62526488 :     return slot;
     411             : }
     412             : #endif
     413             : 
     414             : /*
     415             :  * ExecQual - evaluate a qual prepared with ExecInitQual (possibly via
     416             :  * ExecPrepareQual).  Returns true if qual is satisfied, else false.
     417             :  *
     418             :  * Note: ExecQual used to have a third argument "resultForNull".  The
     419             :  * behavior of this function now corresponds to resultForNull == false.
     420             :  * If you want the resultForNull == true behavior, see ExecCheck.
     421             :  */
     422             : #ifndef FRONTEND
     423             : static inline bool
     424    79721402 : ExecQual(ExprState *state, ExprContext *econtext)
     425             : {
     426             :     Datum       ret;
     427             :     bool        isnull;
     428             : 
     429             :     /* short-circuit (here and in ExecInitQual) for empty restriction list */
     430    79721402 :     if (state == NULL)
     431     4944030 :         return true;
     432             : 
     433             :     /* verify that expression was compiled using ExecInitQual */
     434             :     Assert(state->flags & EEO_FLAG_IS_QUAL);
     435             : 
     436    74777372 :     ret = ExecEvalExprSwitchContext(state, econtext, &isnull);
     437             : 
     438             :     /* EEOP_QUAL should never return NULL */
     439             :     Assert(!isnull);
     440             : 
     441    74777338 :     return DatumGetBool(ret);
     442             : }
     443             : #endif
     444             : 
     445             : /*
     446             :  * ExecQualAndReset() - evaluate qual with ExecQual() and reset expression
     447             :  * context.
     448             :  */
     449             : #ifndef FRONTEND
     450             : static inline bool
     451    20502034 : ExecQualAndReset(ExprState *state, ExprContext *econtext)
     452             : {
     453    20502034 :     bool        ret = ExecQual(state, econtext);
     454             : 
     455             :     /* inline ResetExprContext, to avoid ordering issue in this file */
     456    20502034 :     MemoryContextReset(econtext->ecxt_per_tuple_memory);
     457    20502034 :     return ret;
     458             : }
     459             : #endif
     460             : 
     461             : extern bool ExecCheck(ExprState *state, ExprContext *econtext);
     462             : 
     463             : /*
     464             :  * prototypes from functions in execSRF.c
     465             :  */
     466             : extern SetExprState *ExecInitTableFunctionResult(Expr *expr,
     467             :                                                  ExprContext *econtext, PlanState *parent);
     468             : extern Tuplestorestate *ExecMakeTableFunctionResult(SetExprState *setexpr,
     469             :                                                     ExprContext *econtext,
     470             :                                                     MemoryContext argContext,
     471             :                                                     TupleDesc expectedDesc,
     472             :                                                     bool randomAccess);
     473             : extern SetExprState *ExecInitFunctionResultSet(Expr *expr,
     474             :                                                ExprContext *econtext, PlanState *parent);
     475             : extern Datum ExecMakeFunctionResultSet(SetExprState *fcache,
     476             :                                        ExprContext *econtext,
     477             :                                        MemoryContext argContext,
     478             :                                        bool *isNull,
     479             :                                        ExprDoneCond *isDone);
     480             : 
     481             : /*
     482             :  * prototypes from functions in execScan.c
     483             :  */
     484             : typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
     485             : typedef bool (*ExecScanRecheckMtd) (ScanState *node, TupleTableSlot *slot);
     486             : 
     487             : extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd,
     488             :                                 ExecScanRecheckMtd recheckMtd);
     489             : extern void ExecAssignScanProjectionInfo(ScanState *node);
     490             : extern void ExecAssignScanProjectionInfoWithVarno(ScanState *node, int varno);
     491             : extern void ExecScanReScan(ScanState *node);
     492             : 
     493             : /*
     494             :  * prototypes from functions in execTuples.c
     495             :  */
     496             : extern void ExecInitResultTypeTL(PlanState *planstate);
     497             : extern void ExecInitResultSlot(PlanState *planstate,
     498             :                                const TupleTableSlotOps *tts_ops);
     499             : extern void ExecInitResultTupleSlotTL(PlanState *planstate,
     500             :                                       const TupleTableSlotOps *tts_ops);
     501             : extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate,
     502             :                                   TupleDesc tupledesc,
     503             :                                   const TupleTableSlotOps *tts_ops);
     504             : extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate,
     505             :                                               TupleDesc tupledesc,
     506             :                                               const TupleTableSlotOps *tts_ops);
     507             : extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, TupleDesc tupType,
     508             :                                              const TupleTableSlotOps *tts_ops);
     509             : extern TupleDesc ExecTypeFromTL(List *targetList);
     510             : extern TupleDesc ExecCleanTypeFromTL(List *targetList);
     511             : extern TupleDesc ExecTypeFromExprList(List *exprList);
     512             : extern void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList);
     513             : extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
     514             : 
     515             : typedef struct TupOutputState
     516             : {
     517             :     TupleTableSlot *slot;
     518             :     DestReceiver *dest;
     519             : } TupOutputState;
     520             : 
     521             : extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,
     522             :                                                 TupleDesc tupdesc,
     523             :                                                 const TupleTableSlotOps *tts_ops);
     524             : extern void do_tup_output(TupOutputState *tstate, const Datum *values, const bool *isnull);
     525             : extern void do_text_output_multiline(TupOutputState *tstate, const char *txt);
     526             : extern void end_tup_output(TupOutputState *tstate);
     527             : 
     528             : /*
     529             :  * Write a single line of text given as a C string.
     530             :  *
     531             :  * Should only be used with a single-TEXT-attribute tupdesc.
     532             :  */
     533             : #define do_text_output_oneline(tstate, str_to_emit) \
     534             :     do { \
     535             :         Datum   values_[1]; \
     536             :         bool    isnull_[1]; \
     537             :         values_[0] = PointerGetDatum(cstring_to_text(str_to_emit)); \
     538             :         isnull_[0] = false; \
     539             :         do_tup_output(tstate, values_, isnull_); \
     540             :         pfree(DatumGetPointer(values_[0])); \
     541             :     } while (0)
     542             : 
     543             : 
     544             : /*
     545             :  * prototypes from functions in execUtils.c
     546             :  */
     547             : extern EState *CreateExecutorState(void);
     548             : extern void FreeExecutorState(EState *estate);
     549             : extern ExprContext *CreateExprContext(EState *estate);
     550             : extern ExprContext *CreateWorkExprContext(EState *estate);
     551             : extern ExprContext *CreateStandaloneExprContext(void);
     552             : extern void FreeExprContext(ExprContext *econtext, bool isCommit);
     553             : extern void ReScanExprContext(ExprContext *econtext);
     554             : 
     555             : #define ResetExprContext(econtext) \
     556             :     MemoryContextReset((econtext)->ecxt_per_tuple_memory)
     557             : 
     558             : extern ExprContext *MakePerTupleExprContext(EState *estate);
     559             : 
     560             : /* Get an EState's per-output-tuple exprcontext, making it if first use */
     561             : #define GetPerTupleExprContext(estate) \
     562             :     ((estate)->es_per_tuple_exprcontext ? \
     563             :      (estate)->es_per_tuple_exprcontext : \
     564             :      MakePerTupleExprContext(estate))
     565             : 
     566             : #define GetPerTupleMemoryContext(estate) \
     567             :     (GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)
     568             : 
     569             : /* Reset an EState's per-output-tuple exprcontext, if one's been created */
     570             : #define ResetPerTupleExprContext(estate) \
     571             :     do { \
     572             :         if ((estate)->es_per_tuple_exprcontext) \
     573             :             ResetExprContext((estate)->es_per_tuple_exprcontext); \
     574             :     } while (0)
     575             : 
     576             : extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
     577             : extern TupleDesc ExecGetResultType(PlanState *planstate);
     578             : extern const TupleTableSlotOps *ExecGetResultSlotOps(PlanState *planstate,
     579             :                                                      bool *isfixed);
     580             : extern void ExecAssignProjectionInfo(PlanState *planstate,
     581             :                                      TupleDesc inputDesc);
     582             : extern void ExecConditionalAssignProjectionInfo(PlanState *planstate,
     583             :                                                 TupleDesc inputDesc, int varno);
     584             : extern void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc);
     585             : extern void ExecCreateScanSlotFromOuterPlan(EState *estate,
     586             :                                             ScanState *scanstate,
     587             :                                             const TupleTableSlotOps *tts_ops);
     588             : 
     589             : extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid);
     590             : 
     591             : extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags);
     592             : 
     593             : extern void ExecInitRangeTable(EState *estate, List *rangeTable, List *permInfos);
     594             : extern void ExecCloseRangeTableRelations(EState *estate);
     595             : extern void ExecCloseResultRelations(EState *estate);
     596             : 
     597             : static inline RangeTblEntry *
     598      754084 : exec_rt_fetch(Index rti, EState *estate)
     599             : {
     600      754084 :     return (RangeTblEntry *) list_nth(estate->es_range_table, rti - 1);
     601             : }
     602             : 
     603             : extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
     604             : extern void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo,
     605             :                                    Index rti);
     606             : 
     607             : extern int  executor_errposition(EState *estate, int location);
     608             : 
     609             : extern void RegisterExprContextCallback(ExprContext *econtext,
     610             :                                         ExprContextCallbackFunction function,
     611             :                                         Datum arg);
     612             : extern void UnregisterExprContextCallback(ExprContext *econtext,
     613             :                                           ExprContextCallbackFunction function,
     614             :                                           Datum arg);
     615             : 
     616             : extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
     617             :                                 bool *isNull);
     618             : extern Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno,
     619             :                                bool *isNull);
     620             : 
     621             : extern int  ExecTargetListLength(List *targetlist);
     622             : extern int  ExecCleanTargetListLength(List *targetlist);
     623             : 
     624             : extern TupleTableSlot *ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo);
     625             : extern TupleTableSlot *ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo);
     626             : extern TupleTableSlot *ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo);
     627             : extern TupleConversionMap *ExecGetChildToRootMap(ResultRelInfo *resultRelInfo);
     628             : extern TupleConversionMap *ExecGetRootToChildMap(ResultRelInfo *resultRelInfo, EState *estate);
     629             : 
     630             : extern Oid  ExecGetResultRelCheckAsUser(ResultRelInfo *relInfo, EState *estate);
     631             : extern Bitmapset *ExecGetInsertedCols(ResultRelInfo *relinfo, EState *estate);
     632             : extern Bitmapset *ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate);
     633             : extern Bitmapset *ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate);
     634             : extern Bitmapset *ExecGetAllUpdatedCols(ResultRelInfo *relinfo, EState *estate);
     635             : 
     636             : /*
     637             :  * prototypes from functions in execIndexing.c
     638             :  */
     639             : extern void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative);
     640             : extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
     641             : extern List *ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
     642             :                                    TupleTableSlot *slot, EState *estate,
     643             :                                    bool update,
     644             :                                    bool noDupErr,
     645             :                                    bool *specConflict, List *arbiterIndexes,
     646             :                                    bool onlySummarizing);
     647             : extern bool ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo,
     648             :                                       TupleTableSlot *slot,
     649             :                                       EState *estate, ItemPointer conflictTid,
     650             :                                       ItemPointer tupleid,
     651             :                                       List *arbiterIndexes);
     652             : extern void check_exclusion_constraint(Relation heap, Relation index,
     653             :                                        IndexInfo *indexInfo,
     654             :                                        ItemPointer tupleid,
     655             :                                        const Datum *values, const bool *isnull,
     656             :                                        EState *estate, bool newIndex);
     657             : 
     658             : /*
     659             :  * prototypes from functions in execReplication.c
     660             :  */
     661             : extern StrategyNumber get_equal_strategy_number_for_am(Oid am);
     662             : extern bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid,
     663             :                                          LockTupleMode lockmode,
     664             :                                          TupleTableSlot *searchslot,
     665             :                                          TupleTableSlot *outslot);
     666             : extern bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
     667             :                                      TupleTableSlot *searchslot, TupleTableSlot *outslot);
     668             : 
     669             : extern void ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo,
     670             :                                      EState *estate, TupleTableSlot *slot);
     671             : extern void ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo,
     672             :                                      EState *estate, EPQState *epqstate,
     673             :                                      TupleTableSlot *searchslot, TupleTableSlot *slot);
     674             : extern void ExecSimpleRelationDelete(ResultRelInfo *resultRelInfo,
     675             :                                      EState *estate, EPQState *epqstate,
     676             :                                      TupleTableSlot *searchslot);
     677             : extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);
     678             : 
     679             : extern void CheckSubscriptionRelkind(char relkind, const char *nspname,
     680             :                                      const char *relname);
     681             : 
     682             : /*
     683             :  * prototypes from functions in nodeModifyTable.c
     684             :  */
     685             : extern TupleTableSlot *ExecGetUpdateNewTuple(ResultRelInfo *relinfo,
     686             :                                              TupleTableSlot *planSlot,
     687             :                                              TupleTableSlot *oldSlot);
     688             : extern ResultRelInfo *ExecLookupResultRelByOid(ModifyTableState *node,
     689             :                                                Oid resultoid,
     690             :                                                bool missing_ok,
     691             :                                                bool update_cache);
     692             : 
     693             : #endif                          /* EXECUTOR_H  */

Generated by: LCOV version 1.14