LCOV - code coverage report
Current view: top level - src/include/executor - executor.h (source / functions) Hit Total Coverage
Test: PostgreSQL 13beta1 Lines: 31 31 100.0 %
Date: 2020-05-31 23:07:13 Functions: 7 7 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-2020, 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             :  * REWIND indicates that the plan node should try to efficiently support
      40             :  * rescans without parameter changes.  (Nodes must support ExecReScan calls
      41             :  * in any case, but if this flag was not given, they are at liberty to do it
      42             :  * through complete recalculation.  Note that a parameter change forces a
      43             :  * full recalculation in any case.)
      44             :  *
      45             :  * BACKWARD indicates that the plan node must respect the es_direction flag.
      46             :  * When this is not passed, the plan node will only be run forwards.
      47             :  *
      48             :  * MARK indicates that the plan node must support Mark/Restore calls.
      49             :  * When this is not passed, no Mark/Restore will occur.
      50             :  *
      51             :  * SKIP_TRIGGERS tells ExecutorStart/ExecutorFinish to skip calling
      52             :  * AfterTriggerBeginQuery/AfterTriggerEndQuery.  This does not necessarily
      53             :  * mean that the plan can't queue any AFTER triggers; just that the caller
      54             :  * is responsible for there being a trigger context for them to be queued in.
      55             :  */
      56             : #define EXEC_FLAG_EXPLAIN_ONLY  0x0001  /* EXPLAIN, no ANALYZE */
      57             : #define EXEC_FLAG_REWIND        0x0002  /* need efficient rescan */
      58             : #define EXEC_FLAG_BACKWARD      0x0004  /* need backward scan */
      59             : #define EXEC_FLAG_MARK          0x0008  /* need mark/restore */
      60             : #define EXEC_FLAG_SKIP_TRIGGERS 0x0010  /* skip AfterTrigger calls */
      61             : #define EXEC_FLAG_WITH_NO_DATA  0x0020  /* rel scannability doesn't matter */
      62             : 
      63             : 
      64             : /* Hook for plugins to get control in ExecutorStart() */
      65             : typedef void (*ExecutorStart_hook_type) (QueryDesc *queryDesc, int eflags);
      66             : extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook;
      67             : 
      68             : /* Hook for plugins to get control in ExecutorRun() */
      69             : typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc,
      70             :                                        ScanDirection direction,
      71             :                                        uint64 count,
      72             :                                        bool execute_once);
      73             : extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;
      74             : 
      75             : /* Hook for plugins to get control in ExecutorFinish() */
      76             : typedef void (*ExecutorFinish_hook_type) (QueryDesc *queryDesc);
      77             : extern PGDLLIMPORT ExecutorFinish_hook_type ExecutorFinish_hook;
      78             : 
      79             : /* Hook for plugins to get control in ExecutorEnd() */
      80             : typedef void (*ExecutorEnd_hook_type) (QueryDesc *queryDesc);
      81             : extern PGDLLIMPORT ExecutorEnd_hook_type ExecutorEnd_hook;
      82             : 
      83             : /* Hook for plugins to get control in ExecCheckRTPerms() */
      84             : typedef bool (*ExecutorCheckPerms_hook_type) (List *, bool);
      85             : extern PGDLLIMPORT ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook;
      86             : 
      87             : 
      88             : /*
      89             :  * prototypes from functions in execAmi.c
      90             :  */
      91             : struct Path;                    /* avoid including pathnodes.h here */
      92             : 
      93             : extern void ExecReScan(PlanState *node);
      94             : extern void ExecMarkPos(PlanState *node);
      95             : extern void ExecRestrPos(PlanState *node);
      96             : extern bool ExecSupportsMarkRestore(struct Path *pathnode);
      97             : extern bool ExecSupportsBackwardScan(Plan *node);
      98             : extern bool ExecMaterializesOutput(NodeTag plantype);
      99             : 
     100             : /*
     101             :  * prototypes from functions in execCurrent.c
     102             :  */
     103             : extern bool execCurrentOf(CurrentOfExpr *cexpr,
     104             :                           ExprContext *econtext,
     105             :                           Oid table_oid,
     106             :                           ItemPointer current_tid);
     107             : 
     108             : /*
     109             :  * prototypes from functions in execGrouping.c
     110             :  */
     111             : extern ExprState *execTuplesMatchPrepare(TupleDesc desc,
     112             :                                          int numCols,
     113             :                                          const AttrNumber *keyColIdx,
     114             :                                          const Oid *eqOperators,
     115             :                                          const Oid *collations,
     116             :                                          PlanState *parent);
     117             : extern void execTuplesHashPrepare(int numCols,
     118             :                                   const Oid *eqOperators,
     119             :                                   Oid **eqFuncOids,
     120             :                                   FmgrInfo **hashFunctions);
     121             : extern TupleHashTable BuildTupleHashTable(PlanState *parent,
     122             :                                           TupleDesc inputDesc,
     123             :                                           int numCols, AttrNumber *keyColIdx,
     124             :                                           const Oid *eqfuncoids,
     125             :                                           FmgrInfo *hashfunctions,
     126             :                                           Oid *collations,
     127             :                                           long nbuckets, Size additionalsize,
     128             :                                           MemoryContext tablecxt,
     129             :                                           MemoryContext tempcxt, bool use_variable_hash_iv);
     130             : extern TupleHashTable BuildTupleHashTableExt(PlanState *parent,
     131             :                                              TupleDesc inputDesc,
     132             :                                              int numCols, AttrNumber *keyColIdx,
     133             :                                              const Oid *eqfuncoids,
     134             :                                              FmgrInfo *hashfunctions,
     135             :                                              Oid *collations,
     136             :                                              long nbuckets, Size additionalsize,
     137             :                                              MemoryContext metacxt,
     138             :                                              MemoryContext tablecxt,
     139             :                                              MemoryContext tempcxt, bool use_variable_hash_iv);
     140             : extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable,
     141             :                                            TupleTableSlot *slot,
     142             :                                            bool *isnew);
     143             : extern uint32 TupleHashTableHash(TupleHashTable hashtable,
     144             :                                  TupleTableSlot *slot);
     145             : extern TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable,
     146             :                                                TupleTableSlot *slot,
     147             :                                                bool *isnew, uint32 hash);
     148             : extern TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable,
     149             :                                          TupleTableSlot *slot,
     150             :                                          ExprState *eqcomp,
     151             :                                          FmgrInfo *hashfunctions);
     152             : extern void ResetTupleHashTable(TupleHashTable hashtable);
     153             : 
     154             : /*
     155             :  * prototypes from functions in execJunk.c
     156             :  */
     157             : extern JunkFilter *ExecInitJunkFilter(List *targetList,
     158             :                                       TupleTableSlot *slot);
     159             : extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
     160             :                                                 TupleDesc cleanTupType,
     161             :                                                 TupleTableSlot *slot);
     162             : extern AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter,
     163             :                                         const char *attrName);
     164             : extern AttrNumber ExecFindJunkAttributeInTlist(List *targetlist,
     165             :                                                const char *attrName);
     166             : extern Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno,
     167             :                                   bool *isNull);
     168             : extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,
     169             :                                       TupleTableSlot *slot);
     170             : 
     171             : 
     172             : /*
     173             :  * prototypes from functions in execMain.c
     174             :  */
     175             : extern void ExecutorStart(QueryDesc *queryDesc, int eflags);
     176             : extern void standard_ExecutorStart(QueryDesc *queryDesc, int eflags);
     177             : extern void ExecutorRun(QueryDesc *queryDesc,
     178             :                         ScanDirection direction, uint64 count, bool execute_once);
     179             : extern void standard_ExecutorRun(QueryDesc *queryDesc,
     180             :                                  ScanDirection direction, uint64 count, bool execute_once);
     181             : extern void ExecutorFinish(QueryDesc *queryDesc);
     182             : extern void standard_ExecutorFinish(QueryDesc *queryDesc);
     183             : extern void ExecutorEnd(QueryDesc *queryDesc);
     184             : extern void standard_ExecutorEnd(QueryDesc *queryDesc);
     185             : extern void ExecutorRewind(QueryDesc *queryDesc);
     186             : extern bool ExecCheckRTPerms(List *rangeTable, bool ereport_on_violation);
     187             : extern void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation);
     188             : extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,
     189             :                               Relation resultRelationDesc,
     190             :                               Index resultRelationIndex,
     191             :                               Relation partition_root,
     192             :                               int instrument_options);
     193             : extern ResultRelInfo *ExecGetTriggerResultRel(EState *estate, Oid relid);
     194             : extern void ExecCleanUpTriggerState(EState *estate);
     195             : extern void ExecConstraints(ResultRelInfo *resultRelInfo,
     196             :                             TupleTableSlot *slot, EState *estate);
     197             : extern bool ExecPartitionCheck(ResultRelInfo *resultRelInfo,
     198             :                                TupleTableSlot *slot, EState *estate, bool emitError);
     199             : extern void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
     200             :                                         TupleTableSlot *slot, EState *estate);
     201             : extern void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
     202             :                                  TupleTableSlot *slot, EState *estate);
     203             : extern LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo);
     204             : extern ExecRowMark *ExecFindRowMark(EState *estate, Index rti, bool missing_ok);
     205             : extern ExecAuxRowMark *ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist);
     206             : extern TupleTableSlot *EvalPlanQual(EPQState *epqstate, Relation relation,
     207             :                                     Index rti, TupleTableSlot *testslot);
     208             : extern void EvalPlanQualInit(EPQState *epqstate, EState *parentestate,
     209             :                              Plan *subplan, List *auxrowmarks, int epqParam);
     210             : extern void EvalPlanQualSetPlan(EPQState *epqstate,
     211             :                                 Plan *subplan, List *auxrowmarks);
     212             : extern TupleTableSlot *EvalPlanQualSlot(EPQState *epqstate,
     213             :                                         Relation relation, Index rti);
     214             : 
     215             : #define EvalPlanQualSetSlot(epqstate, slot)  ((epqstate)->origslot = (slot))
     216             : extern bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot);
     217             : extern TupleTableSlot *EvalPlanQualNext(EPQState *epqstate);
     218             : extern void EvalPlanQualBegin(EPQState *epqstate);
     219             : extern void EvalPlanQualEnd(EPQState *epqstate);
     220             : 
     221             : /*
     222             :  * functions in execProcnode.c
     223             :  */
     224             : extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);
     225             : extern void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function);
     226             : extern Node *MultiExecProcNode(PlanState *node);
     227             : extern void ExecEndNode(PlanState *node);
     228             : extern bool ExecShutdownNode(PlanState *node);
     229             : extern void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node);
     230             : 
     231             : 
     232             : /* ----------------------------------------------------------------
     233             :  *      ExecProcNode
     234             :  *
     235             :  *      Execute the given node to return a(nother) tuple.
     236             :  * ----------------------------------------------------------------
     237             :  */
     238             : #ifndef FRONTEND
     239             : static inline TupleTableSlot *
     240    84501238 : ExecProcNode(PlanState *node)
     241             : {
     242    84501238 :     if (node->chgParam != NULL) /* something changed? */
     243     2684464 :         ExecReScan(node);       /* let ReScan handle this */
     244             : 
     245    84501238 :     return node->ExecProcNode(node);
     246             : }
     247             : #endif
     248             : 
     249             : /*
     250             :  * prototypes from functions in execExpr.c
     251             :  */
     252             : extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
     253             : extern ExprState *ExecInitExprWithParams(Expr *node, ParamListInfo ext_params);
     254             : extern ExprState *ExecInitQual(List *qual, PlanState *parent);
     255             : extern ExprState *ExecInitCheck(List *qual, PlanState *parent);
     256             : extern List *ExecInitExprList(List *nodes, PlanState *parent);
     257             : extern ExprState *ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase,
     258             :                                     bool doSort, bool doHash, bool nullcheck);
     259             : extern ExprState *ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
     260             :                                          const TupleTableSlotOps *lops, const TupleTableSlotOps *rops,
     261             :                                          int numCols,
     262             :                                          const AttrNumber *keyColIdx,
     263             :                                          const Oid *eqfunctions,
     264             :                                          const Oid *collations,
     265             :                                          PlanState *parent);
     266             : extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
     267             :                                                ExprContext *econtext,
     268             :                                                TupleTableSlot *slot,
     269             :                                                PlanState *parent,
     270             :                                                TupleDesc inputDesc);
     271             : extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
     272             : extern ExprState *ExecPrepareQual(List *qual, EState *estate);
     273             : extern ExprState *ExecPrepareCheck(List *qual, EState *estate);
     274             : extern List *ExecPrepareExprList(List *nodes, EState *estate);
     275             : 
     276             : /*
     277             :  * ExecEvalExpr
     278             :  *
     279             :  * Evaluate expression identified by "state" in the execution context
     280             :  * given by "econtext".  *isNull is set to the is-null flag for the result,
     281             :  * and the Datum value is the function result.
     282             :  *
     283             :  * The caller should already have switched into the temporary memory
     284             :  * context econtext->ecxt_per_tuple_memory.  The convenience entry point
     285             :  * ExecEvalExprSwitchContext() is provided for callers who don't prefer to
     286             :  * do the switch in an outer loop.
     287             :  */
     288             : #ifndef FRONTEND
     289             : static inline Datum
     290    26400798 : ExecEvalExpr(ExprState *state,
     291             :              ExprContext *econtext,
     292             :              bool *isNull)
     293             : {
     294    26400798 :     return state->evalfunc(state, econtext, isNull);
     295             : }
     296             : #endif
     297             : 
     298             : /*
     299             :  * ExecEvalExprSwitchContext
     300             :  *
     301             :  * Same as ExecEvalExpr, but get into the right allocation context explicitly.
     302             :  */
     303             : #ifndef FRONTEND
     304             : static inline Datum
     305   117797126 : ExecEvalExprSwitchContext(ExprState *state,
     306             :                           ExprContext *econtext,
     307             :                           bool *isNull)
     308             : {
     309             :     Datum       retDatum;
     310             :     MemoryContext oldContext;
     311             : 
     312   117797126 :     oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
     313   117797126 :     retDatum = state->evalfunc(state, econtext, isNull);
     314   117786734 :     MemoryContextSwitchTo(oldContext);
     315   117786734 :     return retDatum;
     316             : }
     317             : #endif
     318             : 
     319             : /*
     320             :  * ExecProject
     321             :  *
     322             :  * Projects a tuple based on projection info and stores it in the slot passed
     323             :  * to ExecBuildProjectionInfo().
     324             :  *
     325             :  * Note: the result is always a virtual tuple; therefore it may reference
     326             :  * the contents of the exprContext's scan tuples and/or temporary results
     327             :  * constructed in the exprContext.  If the caller wishes the result to be
     328             :  * valid longer than that data will be valid, he must call ExecMaterializeSlot
     329             :  * on the result slot.
     330             :  */
     331             : #ifndef FRONTEND
     332             : static inline TupleTableSlot *
     333    44304036 : ExecProject(ProjectionInfo *projInfo)
     334             : {
     335    44304036 :     ExprContext *econtext = projInfo->pi_exprContext;
     336    44304036 :     ExprState  *state = &projInfo->pi_state;
     337    44304036 :     TupleTableSlot *slot = state->resultslot;
     338             :     bool        isnull;
     339             : 
     340             :     /*
     341             :      * Clear any former contents of the result slot.  This makes it safe for
     342             :      * us to use the slot's Datum/isnull arrays as workspace.
     343             :      */
     344    44304036 :     ExecClearTuple(slot);
     345             : 
     346             :     /* Run the expression, discarding scalar result from the last column. */
     347    44304036 :     (void) ExecEvalExprSwitchContext(state, econtext, &isnull);
     348             : 
     349             :     /*
     350             :      * Successfully formed a result row.  Mark the result slot as containing a
     351             :      * valid virtual tuple (inlined version of ExecStoreVirtualTuple()).
     352             :      */
     353    44295158 :     slot->tts_flags &= ~TTS_FLAG_EMPTY;
     354    44295158 :     slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
     355             : 
     356    44295158 :     return slot;
     357             : }
     358             : #endif
     359             : 
     360             : /*
     361             :  * ExecQual - evaluate a qual prepared with ExecInitQual (possibly via
     362             :  * ExecPrepareQual).  Returns true if qual is satisfied, else false.
     363             :  *
     364             :  * Note: ExecQual used to have a third argument "resultForNull".  The
     365             :  * behavior of this function now corresponds to resultForNull == false.
     366             :  * If you want the resultForNull == true behavior, see ExecCheck.
     367             :  */
     368             : #ifndef FRONTEND
     369             : static inline bool
     370    57435336 : ExecQual(ExprState *state, ExprContext *econtext)
     371             : {
     372             :     Datum       ret;
     373             :     bool        isnull;
     374             : 
     375             :     /* short-circuit (here and in ExecInitQual) for empty restriction list */
     376    57435336 :     if (state == NULL)
     377     3044160 :         return true;
     378             : 
     379             :     /* verify that expression was compiled using ExecInitQual */
     380             :     Assert(state->flags & EEO_FLAG_IS_QUAL);
     381             : 
     382    54391176 :     ret = ExecEvalExprSwitchContext(state, econtext, &isnull);
     383             : 
     384             :     /* EEOP_QUAL should never return NULL */
     385             :     Assert(!isnull);
     386             : 
     387    54391158 :     return DatumGetBool(ret);
     388             : }
     389             : #endif
     390             : 
     391             : /*
     392             :  * ExecQualAndReset() - evaluate qual with ExecQual() and reset expression
     393             :  * context.
     394             :  */
     395             : #ifndef FRONTEND
     396             : static inline bool
     397    11020924 : ExecQualAndReset(ExprState *state, ExprContext *econtext)
     398             : {
     399    11020924 :     bool        ret = ExecQual(state, econtext);
     400             : 
     401             :     /* inline ResetExprContext, to avoid ordering issue in this file */
     402    11020924 :     MemoryContextReset(econtext->ecxt_per_tuple_memory);
     403    11020924 :     return ret;
     404             : }
     405             : #endif
     406             : 
     407             : extern bool ExecCheck(ExprState *state, ExprContext *context);
     408             : 
     409             : /*
     410             :  * prototypes from functions in execSRF.c
     411             :  */
     412             : extern SetExprState *ExecInitTableFunctionResult(Expr *expr,
     413             :                                                  ExprContext *econtext, PlanState *parent);
     414             : extern Tuplestorestate *ExecMakeTableFunctionResult(SetExprState *setexpr,
     415             :                                                     ExprContext *econtext,
     416             :                                                     MemoryContext argContext,
     417             :                                                     TupleDesc expectedDesc,
     418             :                                                     bool randomAccess);
     419             : extern SetExprState *ExecInitFunctionResultSet(Expr *expr,
     420             :                                                ExprContext *econtext, PlanState *parent);
     421             : extern Datum ExecMakeFunctionResultSet(SetExprState *fcache,
     422             :                                        ExprContext *econtext,
     423             :                                        MemoryContext argContext,
     424             :                                        bool *isNull,
     425             :                                        ExprDoneCond *isDone);
     426             : 
     427             : /*
     428             :  * prototypes from functions in execScan.c
     429             :  */
     430             : typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
     431             : typedef bool (*ExecScanRecheckMtd) (ScanState *node, TupleTableSlot *slot);
     432             : 
     433             : extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd,
     434             :                                 ExecScanRecheckMtd recheckMtd);
     435             : extern void ExecAssignScanProjectionInfo(ScanState *node);
     436             : extern void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno);
     437             : extern void ExecScanReScan(ScanState *node);
     438             : 
     439             : /*
     440             :  * prototypes from functions in execTuples.c
     441             :  */
     442             : extern void ExecInitResultTypeTL(PlanState *planstate);
     443             : extern void ExecInitResultSlot(PlanState *planstate,
     444             :                                const TupleTableSlotOps *tts_ops);
     445             : extern void ExecInitResultTupleSlotTL(PlanState *planstate,
     446             :                                       const TupleTableSlotOps *tts_ops);
     447             : extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate,
     448             :                                   TupleDesc tupleDesc,
     449             :                                   const TupleTableSlotOps *tts_ops);
     450             : extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate,
     451             :                                               TupleDesc tupledesc,
     452             :                                               const TupleTableSlotOps *tts_ops);
     453             : extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, TupleDesc tupType,
     454             :                                              const TupleTableSlotOps *tts_ops);
     455             : extern TupleDesc ExecTypeFromTL(List *targetList);
     456             : extern TupleDesc ExecCleanTypeFromTL(List *targetList);
     457             : extern TupleDesc ExecTypeFromExprList(List *exprList);
     458             : extern void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList);
     459             : extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
     460             : 
     461             : typedef struct TupOutputState
     462             : {
     463             :     TupleTableSlot *slot;
     464             :     DestReceiver *dest;
     465             : } TupOutputState;
     466             : 
     467             : extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,
     468             :                                                 TupleDesc tupdesc,
     469             :                                                 const TupleTableSlotOps *tts_ops);
     470             : extern void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull);
     471             : extern void do_text_output_multiline(TupOutputState *tstate, const char *txt);
     472             : extern void end_tup_output(TupOutputState *tstate);
     473             : 
     474             : /*
     475             :  * Write a single line of text given as a C string.
     476             :  *
     477             :  * Should only be used with a single-TEXT-attribute tupdesc.
     478             :  */
     479             : #define do_text_output_oneline(tstate, str_to_emit) \
     480             :     do { \
     481             :         Datum   values_[1]; \
     482             :         bool    isnull_[1]; \
     483             :         values_[0] = PointerGetDatum(cstring_to_text(str_to_emit)); \
     484             :         isnull_[0] = false; \
     485             :         do_tup_output(tstate, values_, isnull_); \
     486             :         pfree(DatumGetPointer(values_[0])); \
     487             :     } while (0)
     488             : 
     489             : 
     490             : /*
     491             :  * prototypes from functions in execUtils.c
     492             :  */
     493             : extern EState *CreateExecutorState(void);
     494             : extern void FreeExecutorState(EState *estate);
     495             : extern ExprContext *CreateExprContext(EState *estate);
     496             : extern ExprContext *CreateWorkExprContext(EState *estate);
     497             : extern ExprContext *CreateStandaloneExprContext(void);
     498             : extern void FreeExprContext(ExprContext *econtext, bool isCommit);
     499             : extern void ReScanExprContext(ExprContext *econtext);
     500             : 
     501             : #define ResetExprContext(econtext) \
     502             :     MemoryContextReset((econtext)->ecxt_per_tuple_memory)
     503             : 
     504             : extern ExprContext *MakePerTupleExprContext(EState *estate);
     505             : 
     506             : /* Get an EState's per-output-tuple exprcontext, making it if first use */
     507             : #define GetPerTupleExprContext(estate) \
     508             :     ((estate)->es_per_tuple_exprcontext ? \
     509             :      (estate)->es_per_tuple_exprcontext : \
     510             :      MakePerTupleExprContext(estate))
     511             : 
     512             : #define GetPerTupleMemoryContext(estate) \
     513             :     (GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)
     514             : 
     515             : /* Reset an EState's per-output-tuple exprcontext, if one's been created */
     516             : #define ResetPerTupleExprContext(estate) \
     517             :     do { \
     518             :         if ((estate)->es_per_tuple_exprcontext) \
     519             :             ResetExprContext((estate)->es_per_tuple_exprcontext); \
     520             :     } while (0)
     521             : 
     522             : extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
     523             : extern TupleDesc ExecGetResultType(PlanState *planstate);
     524             : extern const TupleTableSlotOps *ExecGetResultSlotOps(PlanState *planstate,
     525             :                                                      bool *isfixed);
     526             : extern void ExecAssignProjectionInfo(PlanState *planstate,
     527             :                                      TupleDesc inputDesc);
     528             : extern void ExecConditionalAssignProjectionInfo(PlanState *planstate,
     529             :                                                 TupleDesc inputDesc, Index varno);
     530             : extern void ExecFreeExprContext(PlanState *planstate);
     531             : extern void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc);
     532             : extern void ExecCreateScanSlotFromOuterPlan(EState *estate,
     533             :                                             ScanState *scanstate,
     534             :                                             const TupleTableSlotOps *tts_ops);
     535             : 
     536             : extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid);
     537             : 
     538             : extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags);
     539             : 
     540             : extern void ExecInitRangeTable(EState *estate, List *rangeTable);
     541             : 
     542             : static inline RangeTblEntry *
     543      460840 : exec_rt_fetch(Index rti, EState *estate)
     544             : {
     545      460840 :     return (RangeTblEntry *) list_nth(estate->es_range_table, rti - 1);
     546             : }
     547             : 
     548             : extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
     549             : 
     550             : extern int  executor_errposition(EState *estate, int location);
     551             : 
     552             : extern void RegisterExprContextCallback(ExprContext *econtext,
     553             :                                         ExprContextCallbackFunction function,
     554             :                                         Datum arg);
     555             : extern void UnregisterExprContextCallback(ExprContext *econtext,
     556             :                                           ExprContextCallbackFunction function,
     557             :                                           Datum arg);
     558             : 
     559             : extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
     560             :                                 bool *isNull);
     561             : extern Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno,
     562             :                                bool *isNull);
     563             : 
     564             : extern int  ExecTargetListLength(List *targetlist);
     565             : extern int  ExecCleanTargetListLength(List *targetlist);
     566             : 
     567             : extern TupleTableSlot *ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo);
     568             : extern TupleTableSlot *ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo);
     569             : extern TupleTableSlot *ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo);
     570             : 
     571             : /*
     572             :  * prototypes from functions in execIndexing.c
     573             :  */
     574             : extern void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative);
     575             : extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
     576             : extern List *ExecInsertIndexTuples(TupleTableSlot *slot, EState *estate, bool noDupErr,
     577             :                                    bool *specConflict, List *arbiterIndexes);
     578             : extern bool ExecCheckIndexConstraints(TupleTableSlot *slot, EState *estate,
     579             :                                       ItemPointer conflictTid, List *arbiterIndexes);
     580             : extern void check_exclusion_constraint(Relation heap, Relation index,
     581             :                                        IndexInfo *indexInfo,
     582             :                                        ItemPointer tupleid,
     583             :                                        Datum *values, bool *isnull,
     584             :                                        EState *estate, bool newIndex);
     585             : 
     586             : /*
     587             :  * prototypes from functions in execReplication.c
     588             :  */
     589             : extern bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid,
     590             :                                          LockTupleMode lockmode,
     591             :                                          TupleTableSlot *searchslot,
     592             :                                          TupleTableSlot *outslot);
     593             : extern bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
     594             :                                      TupleTableSlot *searchslot, TupleTableSlot *outslot);
     595             : 
     596             : extern void ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot);
     597             : extern void ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
     598             :                                      TupleTableSlot *searchslot, TupleTableSlot *slot);
     599             : extern void ExecSimpleRelationDelete(EState *estate, EPQState *epqstate,
     600             :                                      TupleTableSlot *searchslot);
     601             : extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);
     602             : 
     603             : extern void CheckSubscriptionRelkind(char relkind, const char *nspname,
     604             :                                      const char *relname);
     605             : 
     606             : #endif                          /* EXECUTOR_H  */

Generated by: LCOV version 1.13