PostgreSQL Source Code  git master
executor.h
Go to the documentation of this file.
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);
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);
74 
75 /* Hook for plugins to get control in ExecutorFinish() */
76 typedef void (*ExecutorFinish_hook_type) (QueryDesc *queryDesc);
78 
79 /* Hook for plugins to get control in ExecutorEnd() */
80 typedef void (*ExecutorEnd_hook_type) (QueryDesc *queryDesc);
82 
83 /* Hook for plugins to get control in ExecCheckRTPerms() */
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  */
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);
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);
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);
141  TupleTableSlot *slot,
142  bool *isnew, uint32 *hash);
143 extern uint32 TupleHashTableHash(TupleHashTable hashtable,
144  TupleTableSlot *slot);
146  TupleTableSlot *slot,
147  bool *isnew, uint32 hash);
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);
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 *
241 {
242  if (node->chgParam != NULL) /* something changed? */
243  ExecReScan(node); /* let ReScan handle this */
244 
245  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);
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
291  ExprContext *econtext,
292  bool *isNull)
293 {
294  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
306  ExprContext *econtext,
307  bool *isNull)
308 {
309  Datum retDatum;
310  MemoryContext oldContext;
311 
312  oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
313  retDatum = state->evalfunc(state, econtext, isNull);
314  MemoryContextSwitchTo(oldContext);
315  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 *
334 {
335  ExprContext *econtext = projInfo->pi_exprContext;
336  ExprState *state = &projInfo->pi_state;
337  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  ExecClearTuple(slot);
345 
346  /* Run the expression, discarding scalar result from the last column. */
347  (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  slot->tts_flags &= ~TTS_FLAG_EMPTY;
354  slot->tts_nvalid = slot->tts_tupleDescriptor->natts;
355 
356  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
371 {
372  Datum ret;
373  bool isnull;
374 
375  /* short-circuit (here and in ExecInitQual) for empty restriction list */
376  if (state == NULL)
377  return true;
378 
379  /* verify that expression was compiled using ExecInitQual */
380  Assert(state->flags & EEO_FLAG_IS_QUAL);
381 
382  ret = ExecEvalExprSwitchContext(state, econtext, &isnull);
383 
384  /* EEOP_QUAL should never return NULL */
385  Assert(!isnull);
386 
387  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
398 {
399  bool ret = ExecQual(state, econtext);
400 
401  /* inline ResetExprContext, to avoid ordering issue in this file */
403  return ret;
404 }
405 #endif
406 
407 extern bool ExecCheck(ExprState *state, ExprContext *context);
408 
409 /*
410  * prototypes from functions in execSRF.c
411  */
413  ExprContext *econtext, PlanState *parent);
415  ExprContext *econtext,
416  MemoryContext argContext,
417  TupleDesc expectedDesc,
418  bool randomAccess);
420  ExprContext *econtext, PlanState *parent);
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);
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);
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 {
466 
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);
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 
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 *
544 {
545  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,
554  Datum arg);
555 extern void UnregisterExprContextCallback(ExprContext *econtext,
557  Datum arg);
558 
559 extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
560  bool *isNull);
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);
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 */
bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid)
Definition: execUtils.c:712
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:734
TupleHashTable BuildTupleHashTable(PlanState *parent, TupleDesc inputDesc, int numCols, AttrNumber *keyColIdx, const Oid *eqfuncoids, FmgrInfo *hashfunctions, Oid *collations, long nbuckets, Size additionalsize, MemoryContext tablecxt, MemoryContext tempcxt, bool use_variable_hash_iv)
Definition: execGrouping.c:253
TupleTableSlot * ExecInitNullTupleSlot(EState *estate, TupleDesc tupType, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1817
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:495
LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo)
Definition: execMain.c:2302
void(* ExecutorRun_hook_type)(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
Definition: executor.h:69
Definition: fmgr.h:56
bool ExecCheckIndexConstraints(TupleTableSlot *slot, EState *estate, ItemPointer conflictTid, List *arbiterIndexes)
Definition: execIndexing.c:482
void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
Definition: execMain.c:2017
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
Definition: execExpr.c:353
#define TTS_FLAG_EMPTY
Definition: tuptable.h:96
bool ExecSupportsBackwardScan(Plan *node)
Definition: execAmi.c:499
LockTupleMode
Definition: lockoptions.h:49
ResultRelInfo * ExecGetTriggerResultRel(EState *estate, Oid relid)
Definition: execMain.c:1352
JunkFilter * ExecInitJunkFilter(List *targetList, TupleTableSlot *slot)
Definition: execJunk.c:60
ExprContext * CreateExprContext(EState *estate)
Definition: execUtils.c:306
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:305
TupleTableSlot * ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1167
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
Definition: execMain.c:2328
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:209
void CheckSubscriptionRelkind(char relkind, const char *nspname, const char *relname)
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
Definition: execMain.c:2351
TupleTableSlot * EvalPlanQualSlot(EPQState *epqstate, Relation relation, Index rti)
Definition: execMain.c:2530
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
ExprState * ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
Definition: execExpr.c:160
void ExecScanReScan(ScanState *node)
Definition: execScan.c:299
void ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc, Index varno)
Definition: execUtils.c:560
AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter, const char *attrName)
Definition: execJunk.c:208
void standard_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
Definition: execMain.c:312
Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno, bool *isNull)
Definition: execUtils.c:1065
MemoryContext ecxt_per_tuple_memory
Definition: execnodes.h:234
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1725
void UnregisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:930
void standard_ExecutorFinish(QueryDesc *queryDesc)
Definition: execMain.c:411
void ExecCloseIndices(ResultRelInfo *resultRelInfo)
Definition: execIndexing.c:226
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
TupleHashEntry FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, ExprState *eqcomp, FmgrInfo *hashfunctions)
Definition: execGrouping.c:391
Node * MultiExecProcNode(PlanState *node)
Definition: execProcnode.c:488
Definition: nodes.h:528
int ExecCleanTargetListLength(List *targetlist)
Definition: execUtils.c:1126
void ExecRestrPos(PlanState *node)
Definition: execAmi.c:367
int executor_errposition(EState *estate, int location)
Definition: execUtils.c:877
void(* ExecutorFinish_hook_type)(QueryDesc *queryDesc)
Definition: executor.h:76
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:272
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:137
void ExecSimpleRelationDelete(EState *estate, EPQState *epqstate, TupleTableSlot *searchslot)
TupleTableSlot * EvalPlanQual(EPQState *epqstate, Relation relation, Index rti, TupleTableSlot *testslot)
Definition: execMain.c:2421
bool(* ExecutorCheckPerms_hook_type)(List *, bool)
Definition: executor.h:84
TupleTableSlot * slot
Definition: executor.h:463
bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid, LockTupleMode lockmode, TupleTableSlot *searchslot, TupleTableSlot *outslot)
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
Definition: execIndexing.c:151
TupleTableSlot * resultslot
Definition: execnodes.h:80
List * es_range_table
Definition: execnodes.h:507
bool ExecCheck(ExprState *state, ExprContext *context)
Definition: execExpr.c:599
NameData relname
Definition: pg_class.h:38
unsigned int Oid
Definition: postgres_ext.h:31
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:655
static bool ExecQual(ExprState *state, ExprContext *econtext)
Definition: executor.h:370
NodeTag
Definition: nodes.h:26
JunkFilter * ExecInitJunkFilterConversion(List *targetList, TupleDesc cleanTupType, TupleTableSlot *slot)
Definition: execJunk.c:135
struct TupOutputState TupOutputState
void standard_ExecutorEnd(QueryDesc *queryDesc)
Definition: execMain.c:471
TupleTableSlot *(* ExecProcNodeMtd)(struct PlanState *pstate)
Definition: execnodes.h:919
#define PGDLLIMPORT
Definition: c.h:1257
Datum ExecMakeFunctionResultSet(SetExprState *fcache, ExprContext *econtext, MemoryContext argContext, bool *isNull, ExprDoneCond *isDone)
Definition: execSRF.c:487
void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList)
Definition: execTuples.c:2006
bool ExecShutdownNode(PlanState *node)
Definition: execProcnode.c:751
Definition: type.h:89
void ExecCleanUpTriggerState(EState *estate)
Definition: execMain.c:1435
bool ExecCheckRTPerms(List *rangeTable, bool ereport_on_violation)
Definition: execMain.c:571
void standard_ExecutorStart(QueryDesc *queryDesc, int eflags)
Definition: execMain.c:152
bool ExecSupportsMarkRestore(struct Path *pathnode)
Definition: execAmi.c:409
TupleDesc ExecTypeFromExprList(List *exprList)
Definition: execTuples.c:1967
uint16 tts_flags
Definition: tuptable.h:119
TupleTableSlot * ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1145
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
Definition: execMain.c:2513
void ExecutorRewind(QueryDesc *queryDesc)
Definition: execMain.c:528
NameData attname
Definition: pg_attribute.h:40
PGDLLIMPORT ExecutorEnd_hook_type ExecutorEnd_hook
Definition: execMain.c:73
static void * list_nth(const List *list, int n)
Definition: pg_list.h:266
bool ExecMaterializesOutput(NodeTag plantype)
Definition: execAmi.c:623
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:158
TupleTableSlot * ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo)
Definition: execUtils.c:1189
TupleDesc ExecCleanTypeFromTL(List *targetList)
Definition: execTuples.c:1920
void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
Definition: execMain.c:1886
RelOptInfo * parent
Definition: pathnodes.h:1145
void ExecInitRangeTable(EState *estate, List *rangeTable)
Definition: execUtils.c:765
void EvalPlanQualInit(EPQState *epqstate, EState *parentestate, Plan *subplan, List *auxrowmarks, int epqParam)
Definition: execMain.c:2475
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:675
ExprStateEvalFunc evalfunc
Definition: execnodes.h:91
PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook
Definition: execMain.c:70
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:290
ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)
Definition: execGrouping.c:59
#define EEO_FLAG_IS_QUAL
Definition: execnodes.h:59
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
Definition: execUtils.c:843
bool execCurrentOf(CurrentOfExpr *cexpr, ExprContext *econtext, Oid table_oid, ItemPointer current_tid)
Definition: execCurrent.c:44
ScanDirection
Definition: sdir.h:22
#define DatumGetBool(X)
Definition: postgres.h:393
List * ExecInsertIndexTuples(TupleTableSlot *slot, EState *estate, bool noDupErr, bool *specConflict, List *arbiterIndexes)
Definition: execIndexing.c:273
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
Definition: execUtils.c:540
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1801
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
Definition: executor.h:543
unsigned int uint32
Definition: c.h:374
TupleTableSlot * EvalPlanQualNext(EPQState *epqstate)
Definition: execMain.c:2667
void EvalPlanQualBegin(EPQState *epqstate)
Definition: execMain.c:2683
void end_tup_output(TupOutputState *tstate)
Definition: execTuples.c:2314
ExprState * ExecPrepareCheck(List *qual, EState *estate)
Definition: execExpr.c:543
ExprState * ExecInitCheck(List *qual, PlanState *parent)
Definition: execExpr.c:298
WCOKind
Definition: parsenodes.h:1179
List * ExecPrepareExprList(List *nodes, EState *estate)
Definition: execExpr.c:566
TupOutputState * begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2236
void ResetTupleHashTable(TupleHashTable hashtable)
Definition: execGrouping.c:283
Bitmapset * chgParam
Definition: execnodes.h:964
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
void ExecutorFinish(QueryDesc *queryDesc)
Definition: execMain.c:402
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:431
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1769
ExprContext * CreateStandaloneExprContext(void)
Definition: execUtils.c:357
ExprDoneCond
Definition: execnodes.h:272
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:124
void ExecSimpleRelationInsert(EState *estate, TupleTableSlot *slot)
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot)
Definition: execMain.c:2558
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
Definition: executor.h:397
AttrNumber ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName)
Definition: execJunk.c:220
TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash)
Definition: execGrouping.c:359
PGDLLIMPORT ExecutorFinish_hook_type ExecutorFinish_hook
Definition: execMain.c:72
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:938
PGDLLIMPORT ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook
Definition: execMain.c:76
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:123
uintptr_t Datum
Definition: postgres.h:367
void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation)
Definition: execMain.c:1076
void FreeExprContext(ExprContext *econtext, bool isCommit)
Definition: execUtils.c:416
TupleTableSlot * ExecFilterJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
Definition: execJunk.c:261
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:543
static TupleTableSlot * ExecProcNode(PlanState *node)
Definition: executor.h:240
unsigned int Index
Definition: c.h:482
void InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, Relation partition_root, int instrument_options)
Definition: execMain.c:1277
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
Definition: execUtils.c:504
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
Definition: execExpr.c:492
Relation ExecGetRangeTableRelation(EState *estate, Index rti)
Definition: execUtils.c:795
ExprContext * CreateWorkExprContext(EState *estate)
Definition: execUtils.c:321
EState * CreateExecutorState(void)
Definition: execUtils.c:89
void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function)
Definition: execProcnode.c:411
void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
Definition: execMain.c:1817
SetExprState * ExecInitTableFunctionResult(Expr *expr, ExprContext *econtext, PlanState *parent)
Definition: execSRF.c:56
void ReScanExprContext(ExprContext *econtext)
Definition: execUtils.c:443
TupleDesc ExecTypeFromTL(List *targetList)
Definition: execTuples.c:1908
int ExecTargetListLength(List *targetlist)
Definition: execUtils.c:1116
Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
Definition: execJunk.c:247
void(* ExecutorEnd_hook_type)(QueryDesc *queryDesc)
Definition: executor.h:80
TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 *hash)
Definition: execGrouping.c:304
void ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
Definition: execMain.c:301
#define Assert(condition)
Definition: c.h:745
void RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
Definition: execUtils.c:904
Definition: regguts.h:298
ExprState * ExecPrepareQual(List *qual, EState *estate)
Definition: execExpr.c:520
void(* ExprContextCallbackFunction)(Datum arg)
Definition: execnodes.h:188
size_t Size
Definition: c.h:473
void ExecCreateScanSlotFromOuterPlan(EState *estate, ScanState *scanstate, const TupleTableSlotOps *tts_ops)
Definition: execUtils.c:687
void CheckCmdReplicaIdentity(Relation rel, CmdType cmd)
bool ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool emitError)
Definition: execMain.c:1764
void ExecAssignScanProjectionInfoWithVarno(ScanState *node, Index varno)
Definition: execScan.c:285
List * ExecInitExprList(List *nodes, PlanState *parent)
Definition: execExpr.c:318
void ExecMarkPos(PlanState *node)
Definition: execAmi.c:318
void do_text_output_multiline(TupOutputState *tstate, const char *txt)
Definition: execTuples.c:2284
SetExprState * ExecInitFunctionResultSet(Expr *expr, ExprContext *econtext, PlanState *parent)
Definition: execSRF.c:434
static Datum values[MAXATTR]
Definition: bootstrap.c:165
void EvalPlanQualEnd(EPQState *epqstate)
Definition: execMain.c:2921
bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode, TupleTableSlot *searchslot, TupleTableSlot *outslot)
void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull)
Definition: execTuples.c:2256
ExprContext * MakePerTupleExprContext(EState *estate)
Definition: execUtils.c:458
void(* ExecutorStart_hook_type)(QueryDesc *queryDesc, int eflags)
Definition: executor.h:65
void execTuplesHashPrepare(int numCols, const Oid *eqOperators, Oid **eqFuncOids, FmgrInfo **hashFunctions)
Definition: execGrouping.c:96
Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)
Definition: execUtils.c:1002
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139
ExprState * ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc, const TupleTableSlotOps *lops, const TupleTableSlotOps *rops, int numCols, const AttrNumber *keyColIdx, const Oid *eqfunctions, const Oid *collations, PlanState *parent)
Definition: execExpr.c:3333
void ExecutorEnd(QueryDesc *queryDesc)
Definition: execMain.c:462
uint8 flags
Definition: execnodes.h:65
void check_exclusion_constraint(Relation heap, Relation index, IndexInfo *indexInfo, ItemPointer tupleid, Datum *values, bool *isnull, EState *estate, bool newIndex)
Definition: execIndexing.c:866
ExprState pi_state
Definition: execnodes.h:333
void * arg
void ExecInitResultSlot(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1749
TupleHashTable BuildTupleHashTableExt(PlanState *parent, TupleDesc inputDesc, int numCols, AttrNumber *keyColIdx, const Oid *eqfuncoids, FmgrInfo *hashfunctions, Oid *collations, long nbuckets, Size additionalsize, MemoryContext metacxt, MemoryContext tablecxt, MemoryContext tempcxt, bool use_variable_hash_iv)
Definition: execGrouping.c:154
AttrNumber tts_nvalid
Definition: tuptable.h:121
DestReceiver * dest
Definition: executor.h:464
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupleDesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1781
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:430
Tuplestorestate * ExecMakeTableFunctionResult(SetExprState *setexpr, ExprContext *econtext, MemoryContext argContext, TupleDesc expectedDesc, bool randomAccess)
Definition: execSRF.c:101
ExprContext * pi_exprContext
Definition: execnodes.h:335
Definition: pg_list.h:50
static unsigned hash(unsigned *uv, int n)
Definition: rege_dfa.c:541
void ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate, TupleTableSlot *searchslot, TupleTableSlot *slot)
int16 AttrNumber
Definition: attnum.h:21
ExprState * ExecBuildAggTrans(AggState *aggstate, struct AggStatePerPhaseData *phase, bool doSort, bool doHash, bool nullcheck)
CmdType
Definition: nodes.h:671
PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook
Definition: execMain.c:71
void ExecutorStart(QueryDesc *queryDesc, int eflags)
Definition: execMain.c:143
static TupleTableSlot * ExecProject(ProjectionInfo *projInfo)
Definition: executor.h:333
void FreeExecutorState(EState *estate)
Definition: execUtils.c:191
uint32 TupleHashTableHash(TupleHashTable hashtable, TupleTableSlot *slot)
Definition: execGrouping.c:336
unsigned char bool
Definition: c.h:324
void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node)
Definition: execProcnode.c:821