LCOV - code coverage report
Current view: top level - src/include/executor - executor.h (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 31 31 100.0 %
Date: 2019-11-15 22:06:47 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-2019, 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 TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable,
     144             :                                          TupleTableSlot *slot,
     145             :                                          ExprState *eqcomp,
     146             :                                          FmgrInfo *hashfunctions);
     147             : extern void ResetTupleHashTable(TupleHashTable hashtable);
     148             : 
     149             : /*
     150             :  * prototypes from functions in execJunk.c
     151             :  */
     152             : extern JunkFilter *ExecInitJunkFilter(List *targetList,
     153             :                                       TupleTableSlot *slot);
     154             : extern JunkFilter *ExecInitJunkFilterConversion(List *targetList,
     155             :                                                 TupleDesc cleanTupType,
     156             :                                                 TupleTableSlot *slot);
     157             : extern AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter,
     158             :                                         const char *attrName);
     159             : extern AttrNumber ExecFindJunkAttributeInTlist(List *targetlist,
     160             :                                                const char *attrName);
     161             : extern Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno,
     162             :                                   bool *isNull);
     163             : extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter,
     164             :                                       TupleTableSlot *slot);
     165             : 
     166             : 
     167             : /*
     168             :  * prototypes from functions in execMain.c
     169             :  */
     170             : extern void ExecutorStart(QueryDesc *queryDesc, int eflags);
     171             : extern void standard_ExecutorStart(QueryDesc *queryDesc, int eflags);
     172             : extern void ExecutorRun(QueryDesc *queryDesc,
     173             :                         ScanDirection direction, uint64 count, bool execute_once);
     174             : extern void standard_ExecutorRun(QueryDesc *queryDesc,
     175             :                                  ScanDirection direction, uint64 count, bool execute_once);
     176             : extern void ExecutorFinish(QueryDesc *queryDesc);
     177             : extern void standard_ExecutorFinish(QueryDesc *queryDesc);
     178             : extern void ExecutorEnd(QueryDesc *queryDesc);
     179             : extern void standard_ExecutorEnd(QueryDesc *queryDesc);
     180             : extern void ExecutorRewind(QueryDesc *queryDesc);
     181             : extern bool ExecCheckRTPerms(List *rangeTable, bool ereport_on_violation);
     182             : extern void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation);
     183             : extern void InitResultRelInfo(ResultRelInfo *resultRelInfo,
     184             :                               Relation resultRelationDesc,
     185             :                               Index resultRelationIndex,
     186             :                               Relation partition_root,
     187             :                               int instrument_options);
     188             : extern ResultRelInfo *ExecGetTriggerResultRel(EState *estate, Oid relid);
     189             : extern void ExecCleanUpTriggerState(EState *estate);
     190             : extern void ExecConstraints(ResultRelInfo *resultRelInfo,
     191             :                             TupleTableSlot *slot, EState *estate);
     192             : extern bool ExecPartitionCheck(ResultRelInfo *resultRelInfo,
     193             :                                TupleTableSlot *slot, EState *estate, bool emitError);
     194             : extern void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
     195             :                                         TupleTableSlot *slot, EState *estate);
     196             : extern void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
     197             :                                  TupleTableSlot *slot, EState *estate);
     198             : extern LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo);
     199             : extern ExecRowMark *ExecFindRowMark(EState *estate, Index rti, bool missing_ok);
     200             : extern ExecAuxRowMark *ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist);
     201             : extern TupleTableSlot *EvalPlanQual(EPQState *epqstate, Relation relation,
     202             :                                     Index rti, TupleTableSlot *testslot);
     203             : extern void EvalPlanQualInit(EPQState *epqstate, EState *parentestate,
     204             :                              Plan *subplan, List *auxrowmarks, int epqParam);
     205             : extern void EvalPlanQualSetPlan(EPQState *epqstate,
     206             :                                 Plan *subplan, List *auxrowmarks);
     207             : extern TupleTableSlot *EvalPlanQualSlot(EPQState *epqstate,
     208             :                                         Relation relation, Index rti);
     209             : 
     210             : #define EvalPlanQualSetSlot(epqstate, slot)  ((epqstate)->origslot = (slot))
     211             : extern bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot);
     212             : extern TupleTableSlot *EvalPlanQualNext(EPQState *epqstate);
     213             : extern void EvalPlanQualBegin(EPQState *epqstate);
     214             : extern void EvalPlanQualEnd(EPQState *epqstate);
     215             : 
     216             : /*
     217             :  * functions in execProcnode.c
     218             :  */
     219             : extern PlanState *ExecInitNode(Plan *node, EState *estate, int eflags);
     220             : extern void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function);
     221             : extern Node *MultiExecProcNode(PlanState *node);
     222             : extern void ExecEndNode(PlanState *node);
     223             : extern bool ExecShutdownNode(PlanState *node);
     224             : extern void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node);
     225             : 
     226             : 
     227             : /* ----------------------------------------------------------------
     228             :  *      ExecProcNode
     229             :  *
     230             :  *      Execute the given node to return a(nother) tuple.
     231             :  * ----------------------------------------------------------------
     232             :  */
     233             : #ifndef FRONTEND
     234             : static inline TupleTableSlot *
     235    85905326 : ExecProcNode(PlanState *node)
     236             : {
     237    85905326 :     if (node->chgParam != NULL) /* something changed? */
     238     2563476 :         ExecReScan(node);       /* let ReScan handle this */
     239             : 
     240    85905326 :     return node->ExecProcNode(node);
     241             : }
     242             : #endif
     243             : 
     244             : /*
     245             :  * prototypes from functions in execExpr.c
     246             :  */
     247             : extern ExprState *ExecInitExpr(Expr *node, PlanState *parent);
     248             : extern ExprState *ExecInitExprWithParams(Expr *node, ParamListInfo ext_params);
     249             : extern ExprState *ExecInitQual(List *qual, PlanState *parent);
     250             : extern ExprState *ExecInitCheck(List *qual, PlanState *parent);
     251             : extern List *ExecInitExprList(List *nodes, PlanState *parent);
     252             : extern ExprState *ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase,
     253             :                                     bool doSort, bool doHash);
     254             : extern ExprState *ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
     255             :                                          const TupleTableSlotOps *lops, const TupleTableSlotOps *rops,
     256             :                                          int numCols,
     257             :                                          const AttrNumber *keyColIdx,
     258             :                                          const Oid *eqfunctions,
     259             :                                          const Oid *collations,
     260             :                                          PlanState *parent);
     261             : extern ProjectionInfo *ExecBuildProjectionInfo(List *targetList,
     262             :                                                ExprContext *econtext,
     263             :                                                TupleTableSlot *slot,
     264             :                                                PlanState *parent,
     265             :                                                TupleDesc inputDesc);
     266             : extern ExprState *ExecPrepareExpr(Expr *node, EState *estate);
     267             : extern ExprState *ExecPrepareQual(List *qual, EState *estate);
     268             : extern ExprState *ExecPrepareCheck(List *qual, EState *estate);
     269             : extern List *ExecPrepareExprList(List *nodes, EState *estate);
     270             : 
     271             : /*
     272             :  * ExecEvalExpr
     273             :  *
     274             :  * Evaluate expression identified by "state" in the execution context
     275             :  * given by "econtext".  *isNull is set to the is-null flag for the result,
     276             :  * and the Datum value is the function result.
     277             :  *
     278             :  * The caller should already have switched into the temporary memory
     279             :  * context econtext->ecxt_per_tuple_memory.  The convenience entry point
     280             :  * ExecEvalExprSwitchContext() is provided for callers who don't prefer to
     281             :  * do the switch in an outer loop.
     282             :  */
     283             : #ifndef FRONTEND
     284             : static inline Datum
     285    26652824 : ExecEvalExpr(ExprState *state,
     286             :              ExprContext *econtext,
     287             :              bool *isNull)
     288             : {
     289    26652824 :     return state->evalfunc(state, econtext, isNull);
     290             : }
     291             : #endif
     292             : 
     293             : /*
     294             :  * ExecEvalExprSwitchContext
     295             :  *
     296             :  * Same as ExecEvalExpr, but get into the right allocation context explicitly.
     297             :  */
     298             : #ifndef FRONTEND
     299             : static inline Datum
     300   113532562 : ExecEvalExprSwitchContext(ExprState *state,
     301             :                           ExprContext *econtext,
     302             :                           bool *isNull)
     303             : {
     304             :     Datum       retDatum;
     305             :     MemoryContext oldContext;
     306             : 
     307   113532562 :     oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
     308   113532562 :     retDatum = state->evalfunc(state, econtext, isNull);
     309   113522230 :     MemoryContextSwitchTo(oldContext);
     310   113522230 :     return retDatum;
     311             : }
     312             : #endif
     313             : 
     314             : /*
     315             :  * ExecProject
     316             :  *
     317             :  * Projects a tuple based on projection info and stores it in the slot passed
     318             :  * to ExecBuildProjectionInfo().
     319             :  *
     320             :  * Note: the result is always a virtual tuple; therefore it may reference
     321             :  * the contents of the exprContext's scan tuples and/or temporary results
     322             :  * constructed in the exprContext.  If the caller wishes the result to be
     323             :  * valid longer than that data will be valid, he must call ExecMaterializeSlot
     324             :  * on the result slot.
     325             :  */
     326             : #ifndef FRONTEND
     327             : static inline TupleTableSlot *
     328    44555112 : ExecProject(ProjectionInfo *projInfo)
     329             : {
     330    44555112 :     ExprContext *econtext = projInfo->pi_exprContext;
     331    44555112 :     ExprState  *state = &projInfo->pi_state;
     332    44555112 :     TupleTableSlot *slot = state->resultslot;
     333             :     bool        isnull;
     334             : 
     335             :     /*
     336             :      * Clear any former contents of the result slot.  This makes it safe for
     337             :      * us to use the slot's Datum/isnull arrays as workspace.
     338             :      */
     339    44555112 :     ExecClearTuple(slot);
     340             : 
     341             :     /* Run the expression, discarding scalar result from the last column. */
     342    44555112 :     (void) ExecEvalExprSwitchContext(state, econtext, &isnull);
     343             : 
     344             :     /*
     345             :      * Successfully formed a result row.  Mark the result slot as containing a
     346             :      * valid virtual tuple (inlined version of ExecStoreVirtualTuple()).
     347             :      */
     348    44546210 :     slot->tts_flags &= ~TTS_FLAG_EMPTY;
     349    44546210 :     slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
     350             : 
     351    44546210 :     return slot;
     352             : }
     353             : #endif
     354             : 
     355             : /*
     356             :  * ExecQual - evaluate a qual prepared with ExecInitQual (possibly via
     357             :  * ExecPrepareQual).  Returns true if qual is satisfied, else false.
     358             :  *
     359             :  * Note: ExecQual used to have a third argument "resultForNull".  The
     360             :  * behavior of this function now corresponds to resultForNull == false.
     361             :  * If you want the resultForNull == true behavior, see ExecCheck.
     362             :  */
     363             : #ifndef FRONTEND
     364             : static inline bool
     365    55799442 : ExecQual(ExprState *state, ExprContext *econtext)
     366             : {
     367             :     Datum       ret;
     368             :     bool        isnull;
     369             : 
     370             :     /* short-circuit (here and in ExecInitQual) for empty restriction list */
     371    55799442 :     if (state == NULL)
     372     4830054 :         return true;
     373             : 
     374             :     /* verify that expression was compiled using ExecInitQual */
     375             :     Assert(state->flags & EEO_FLAG_IS_QUAL);
     376             : 
     377    50969388 :     ret = ExecEvalExprSwitchContext(state, econtext, &isnull);
     378             : 
     379             :     /* EEOP_QUAL should never return NULL */
     380             :     Assert(!isnull);
     381             : 
     382    50969370 :     return DatumGetBool(ret);
     383             : }
     384             : #endif
     385             : 
     386             : /*
     387             :  * ExecQualAndReset() - evaluate qual with ExecQual() and reset expression
     388             :  * context.
     389             :  */
     390             : #ifndef FRONTEND
     391             : static inline bool
     392    11474410 : ExecQualAndReset(ExprState *state, ExprContext *econtext)
     393             : {
     394    11474410 :     bool        ret = ExecQual(state, econtext);
     395             : 
     396             :     /* inline ResetExprContext, to avoid ordering issue in this file */
     397    11474410 :     MemoryContextReset(econtext->ecxt_per_tuple_memory);
     398    11474410 :     return ret;
     399             : }
     400             : #endif
     401             : 
     402             : extern bool ExecCheck(ExprState *state, ExprContext *context);
     403             : 
     404             : /*
     405             :  * prototypes from functions in execSRF.c
     406             :  */
     407             : extern SetExprState *ExecInitTableFunctionResult(Expr *expr,
     408             :                                                  ExprContext *econtext, PlanState *parent);
     409             : extern Tuplestorestate *ExecMakeTableFunctionResult(SetExprState *setexpr,
     410             :                                                     ExprContext *econtext,
     411             :                                                     MemoryContext argContext,
     412             :                                                     TupleDesc expectedDesc,
     413             :                                                     bool randomAccess);
     414             : extern SetExprState *ExecInitFunctionResultSet(Expr *expr,
     415             :                                                ExprContext *econtext, PlanState *parent);
     416             : extern Datum ExecMakeFunctionResultSet(SetExprState *fcache,
     417             :                                        ExprContext *econtext,
     418             :                                        MemoryContext argContext,
     419             :                                        bool *isNull,
     420             :                                        ExprDoneCond *isDone);
     421             : 
     422             : /*
     423             :  * prototypes from functions in execScan.c
     424             :  */
     425             : typedef TupleTableSlot *(*ExecScanAccessMtd) (ScanState *node);
     426             : typedef bool (*ExecScanRecheckMtd) (ScanState *node, TupleTableSlot *slot);
     427             : 
     428             : extern TupleTableSlot *ExecScan(ScanState *node, ExecScanAccessMtd accessMtd,
     429             :                                 ExecScanRecheckMtd recheckMtd);
     430             : extern void ExecAssignScanProjectionInfo(ScanState *node);
     431             : extern void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno);
     432             : extern void ExecScanReScan(ScanState *node);
     433             : 
     434             : /*
     435             :  * prototypes from functions in execTuples.c
     436             :  */
     437             : extern void ExecInitResultTypeTL(PlanState *planstate);
     438             : extern void ExecInitResultSlot(PlanState *planstate,
     439             :                                const TupleTableSlotOps *tts_ops);
     440             : extern void ExecInitResultTupleSlotTL(PlanState *planstate,
     441             :                                       const TupleTableSlotOps *tts_ops);
     442             : extern void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate,
     443             :                                   TupleDesc tupleDesc,
     444             :                                   const TupleTableSlotOps *tts_ops);
     445             : extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate,
     446             :                                               TupleDesc tupledesc,
     447             :                                               const TupleTableSlotOps *tts_ops);
     448             : extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, TupleDesc tupType,
     449             :                                              const TupleTableSlotOps *tts_ops);
     450             : extern TupleDesc ExecTypeFromTL(List *targetList);
     451             : extern TupleDesc ExecCleanTypeFromTL(List *targetList);
     452             : extern TupleDesc ExecTypeFromExprList(List *exprList);
     453             : extern void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList);
     454             : extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
     455             : 
     456             : typedef struct TupOutputState
     457             : {
     458             :     TupleTableSlot *slot;
     459             :     DestReceiver *dest;
     460             : } TupOutputState;
     461             : 
     462             : extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest,
     463             :                                                 TupleDesc tupdesc,
     464             :                                                 const TupleTableSlotOps *tts_ops);
     465             : extern void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull);
     466             : extern void do_text_output_multiline(TupOutputState *tstate, const char *txt);
     467             : extern void end_tup_output(TupOutputState *tstate);
     468             : 
     469             : /*
     470             :  * Write a single line of text given as a C string.
     471             :  *
     472             :  * Should only be used with a single-TEXT-attribute tupdesc.
     473             :  */
     474             : #define do_text_output_oneline(tstate, str_to_emit) \
     475             :     do { \
     476             :         Datum   values_[1]; \
     477             :         bool    isnull_[1]; \
     478             :         values_[0] = PointerGetDatum(cstring_to_text(str_to_emit)); \
     479             :         isnull_[0] = false; \
     480             :         do_tup_output(tstate, values_, isnull_); \
     481             :         pfree(DatumGetPointer(values_[0])); \
     482             :     } while (0)
     483             : 
     484             : 
     485             : /*
     486             :  * prototypes from functions in execUtils.c
     487             :  */
     488             : extern EState *CreateExecutorState(void);
     489             : extern void FreeExecutorState(EState *estate);
     490             : extern ExprContext *CreateExprContext(EState *estate);
     491             : extern ExprContext *CreateStandaloneExprContext(void);
     492             : extern void FreeExprContext(ExprContext *econtext, bool isCommit);
     493             : extern void ReScanExprContext(ExprContext *econtext);
     494             : 
     495             : #define ResetExprContext(econtext) \
     496             :     MemoryContextReset((econtext)->ecxt_per_tuple_memory)
     497             : 
     498             : extern ExprContext *MakePerTupleExprContext(EState *estate);
     499             : 
     500             : /* Get an EState's per-output-tuple exprcontext, making it if first use */
     501             : #define GetPerTupleExprContext(estate) \
     502             :     ((estate)->es_per_tuple_exprcontext ? \
     503             :      (estate)->es_per_tuple_exprcontext : \
     504             :      MakePerTupleExprContext(estate))
     505             : 
     506             : #define GetPerTupleMemoryContext(estate) \
     507             :     (GetPerTupleExprContext(estate)->ecxt_per_tuple_memory)
     508             : 
     509             : /* Reset an EState's per-output-tuple exprcontext, if one's been created */
     510             : #define ResetPerTupleExprContext(estate) \
     511             :     do { \
     512             :         if ((estate)->es_per_tuple_exprcontext) \
     513             :             ResetExprContext((estate)->es_per_tuple_exprcontext); \
     514             :     } while (0)
     515             : 
     516             : extern void ExecAssignExprContext(EState *estate, PlanState *planstate);
     517             : extern TupleDesc ExecGetResultType(PlanState *planstate);
     518             : extern const TupleTableSlotOps *ExecGetResultSlotOps(PlanState *planstate,
     519             :                                                      bool *isfixed);
     520             : extern void ExecAssignProjectionInfo(PlanState *planstate,
     521             :                                      TupleDesc inputDesc);
     522             : extern void ExecConditionalAssignProjectionInfo(PlanState *planstate,
     523             :                                                 TupleDesc inputDesc, Index varno);
     524             : extern void ExecFreeExprContext(PlanState *planstate);
     525             : extern void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc);
     526             : extern void ExecCreateScanSlotFromOuterPlan(EState *estate,
     527             :                                             ScanState *scanstate,
     528             :                                             const TupleTableSlotOps *tts_ops);
     529             : 
     530             : extern bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid);
     531             : 
     532             : extern Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags);
     533             : 
     534             : extern void ExecInitRangeTable(EState *estate, List *rangeTable);
     535             : 
     536             : static inline RangeTblEntry *
     537      424946 : exec_rt_fetch(Index rti, EState *estate)
     538             : {
     539      424946 :     return (RangeTblEntry *) list_nth(estate->es_range_table, rti - 1);
     540             : }
     541             : 
     542             : extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
     543             : 
     544             : extern int  executor_errposition(EState *estate, int location);
     545             : 
     546             : extern void RegisterExprContextCallback(ExprContext *econtext,
     547             :                                         ExprContextCallbackFunction function,
     548             :                                         Datum arg);
     549             : extern void UnregisterExprContextCallback(ExprContext *econtext,
     550             :                                           ExprContextCallbackFunction function,
     551             :                                           Datum arg);
     552             : 
     553             : extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
     554             :                                 bool *isNull);
     555             : extern Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno,
     556             :                                bool *isNull);
     557             : 
     558             : extern int  ExecTargetListLength(List *targetlist);
     559             : extern int  ExecCleanTargetListLength(List *targetlist);
     560             : 
     561             : extern TupleTableSlot *ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo);
     562             : extern TupleTableSlot *ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo);
     563             : extern TupleTableSlot *ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo);
     564             : 
     565             : /*
     566             :  * prototypes from functions in execIndexing.c
     567             :  */
     568             : extern void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative);
     569             : extern void ExecCloseIndices(ResultRelInfo *resultRelInfo);
     570             : extern List *ExecInsertIndexTuples(TupleTableSlot *slot, EState *estate, bool noDupErr,
     571             :                                    bool *specConflict, List *arbiterIndexes);
     572             : extern bool ExecCheckIndexConstraints(TupleTableSlot *slot, EState *estate,
     573             :                                       ItemPointer conflictTid, List *arbiterIndexes);
     574             : extern void check_exclusion_constraint(Relation heap, Relation index,
     575             :                                        IndexInfo *indexInfo,
     576             :                                        ItemPointer tupleid,
     577             :                                        Datum *values, bool *isnull,
     578             :                                        EState *estate, bool newIndex);
     579             : 
     580             : /*
     581             :  * prototypes from functions in execReplication.c
     582             :  */
     583             : extern bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid,
     584             :                                          LockTupleMode lockmode,
     585             :                                          TupleTableSlot *searchslot,
     586             :                                          TupleTableSlot *outslot);
     587             : extern bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode,
     588             :                                      TupleTableSlot *searchslot, TupleTableSlot *outslot);
     589             : 
     590             : extern void ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot);
     591             : extern void ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate,
     592             :                                      TupleTableSlot *searchslot, TupleTableSlot *slot);
     593             : extern void ExecSimpleRelationDelete(EState *estate, EPQState *epqstate,
     594             :                                      TupleTableSlot *searchslot);
     595             : extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd);
     596             : 
     597             : extern void CheckSubscriptionRelkind(char relkind, const char *nspname,
     598             :                                      const char *relname);
     599             : 
     600             : #endif                          /* EXECUTOR_H  */

Generated by: LCOV version 1.13