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