PostgreSQL Source Code  git master
execProcnode.c File Reference
#include "postgres.h"
#include "executor/executor.h"
#include "executor/nodeAgg.h"
#include "executor/nodeAppend.h"
#include "executor/nodeBitmapAnd.h"
#include "executor/nodeBitmapHeapscan.h"
#include "executor/nodeBitmapIndexscan.h"
#include "executor/nodeBitmapOr.h"
#include "executor/nodeCtescan.h"
#include "executor/nodeCustom.h"
#include "executor/nodeForeignscan.h"
#include "executor/nodeFunctionscan.h"
#include "executor/nodeGather.h"
#include "executor/nodeGatherMerge.h"
#include "executor/nodeGroup.h"
#include "executor/nodeHash.h"
#include "executor/nodeHashjoin.h"
#include "executor/nodeIncrementalSort.h"
#include "executor/nodeIndexonlyscan.h"
#include "executor/nodeIndexscan.h"
#include "executor/nodeLimit.h"
#include "executor/nodeLockRows.h"
#include "executor/nodeMaterial.h"
#include "executor/nodeMemoize.h"
#include "executor/nodeMergeAppend.h"
#include "executor/nodeMergejoin.h"
#include "executor/nodeModifyTable.h"
#include "executor/nodeNamedtuplestorescan.h"
#include "executor/nodeNestloop.h"
#include "executor/nodeProjectSet.h"
#include "executor/nodeRecursiveunion.h"
#include "executor/nodeResult.h"
#include "executor/nodeSamplescan.h"
#include "executor/nodeSeqscan.h"
#include "executor/nodeSetOp.h"
#include "executor/nodeSort.h"
#include "executor/nodeSubplan.h"
#include "executor/nodeSubqueryscan.h"
#include "executor/nodeTableFuncscan.h"
#include "executor/nodeTidrangescan.h"
#include "executor/nodeTidscan.h"
#include "executor/nodeUnique.h"
#include "executor/nodeValuesscan.h"
#include "executor/nodeWindowAgg.h"
#include "executor/nodeWorktablescan.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
Include dependency graph for execProcnode.c:

Go to the source code of this file.

Functions

static TupleTableSlotExecProcNodeFirst (PlanState *node)
 
static TupleTableSlotExecProcNodeInstr (PlanState *node)
 
PlanStateExecInitNode (Plan *node, EState *estate, int eflags)
 
void ExecSetExecProcNode (PlanState *node, ExecProcNodeMtd function)
 
NodeMultiExecProcNode (PlanState *node)
 
void ExecEndNode (PlanState *node)
 
bool ExecShutdownNode (PlanState *node)
 
void ExecSetTupleBound (int64 tuples_needed, PlanState *child_node)
 

Function Documentation

◆ ExecEndNode()

void ExecEndNode ( PlanState node)

Definition at line 556 of file execProcnode.c.

557 {
558  /*
559  * do nothing when we get to the end of a leaf on tree.
560  */
561  if (node == NULL)
562  return;
563 
564  /*
565  * Make sure there's enough stack available. Need to check here, in
566  * addition to ExecProcNode() (via ExecProcNodeFirst()), because it's not
567  * guaranteed that ExecProcNode() is reached for all nodes.
568  */
570 
571  if (node->chgParam != NULL)
572  {
573  bms_free(node->chgParam);
574  node->chgParam = NULL;
575  }
576 
577  switch (nodeTag(node))
578  {
579  /*
580  * control nodes
581  */
582  case T_ResultState:
583  ExecEndResult((ResultState *) node);
584  break;
585 
586  case T_ProjectSetState:
588  break;
589 
590  case T_ModifyTableState:
592  break;
593 
594  case T_AppendState:
595  ExecEndAppend((AppendState *) node);
596  break;
597 
598  case T_MergeAppendState:
600  break;
601 
604  break;
605 
606  case T_BitmapAndState:
608  break;
609 
610  case T_BitmapOrState:
611  ExecEndBitmapOr((BitmapOrState *) node);
612  break;
613 
614  /*
615  * scan nodes
616  */
617  case T_SeqScanState:
618  ExecEndSeqScan((SeqScanState *) node);
619  break;
620 
621  case T_SampleScanState:
623  break;
624 
625  case T_GatherState:
626  ExecEndGather((GatherState *) node);
627  break;
628 
629  case T_GatherMergeState:
631  break;
632 
633  case T_IndexScanState:
635  break;
636 
639  break;
640 
643  break;
644 
647  break;
648 
649  case T_TidScanState:
650  ExecEndTidScan((TidScanState *) node);
651  break;
652 
653  case T_TidRangeScanState:
655  break;
656 
657  case T_SubqueryScanState:
659  break;
660 
661  case T_FunctionScanState:
663  break;
664 
667  break;
668 
669  case T_ValuesScanState:
671  break;
672 
673  case T_CteScanState:
674  ExecEndCteScan((CteScanState *) node);
675  break;
676 
679  break;
680 
683  break;
684 
685  case T_ForeignScanState:
687  break;
688 
689  case T_CustomScanState:
691  break;
692 
693  /*
694  * join nodes
695  */
696  case T_NestLoopState:
697  ExecEndNestLoop((NestLoopState *) node);
698  break;
699 
700  case T_MergeJoinState:
702  break;
703 
704  case T_HashJoinState:
705  ExecEndHashJoin((HashJoinState *) node);
706  break;
707 
708  /*
709  * materialization nodes
710  */
711  case T_MaterialState:
712  ExecEndMaterial((MaterialState *) node);
713  break;
714 
715  case T_SortState:
716  ExecEndSort((SortState *) node);
717  break;
718 
721  break;
722 
723  case T_MemoizeState:
724  ExecEndMemoize((MemoizeState *) node);
725  break;
726 
727  case T_GroupState:
728  ExecEndGroup((GroupState *) node);
729  break;
730 
731  case T_AggState:
732  ExecEndAgg((AggState *) node);
733  break;
734 
735  case T_WindowAggState:
737  break;
738 
739  case T_UniqueState:
740  ExecEndUnique((UniqueState *) node);
741  break;
742 
743  case T_HashState:
744  ExecEndHash((HashState *) node);
745  break;
746 
747  case T_SetOpState:
748  ExecEndSetOp((SetOpState *) node);
749  break;
750 
751  case T_LockRowsState:
752  ExecEndLockRows((LockRowsState *) node);
753  break;
754 
755  case T_LimitState:
756  ExecEndLimit((LimitState *) node);
757  break;
758 
759  default:
760  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
761  break;
762  }
763 }
void bms_free(Bitmapset *a)
Definition: bitmapset.c:208
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
void ExecEndAgg(AggState *node)
Definition: nodeAgg.c:4271
void ExecEndAppend(AppendState *node)
Definition: nodeAppend.c:395
void ExecEndBitmapAnd(BitmapAndState *node)
void ExecEndBitmapHeapScan(BitmapHeapScanState *node)
void ExecEndBitmapIndexScan(BitmapIndexScanState *node)
void ExecEndBitmapOr(BitmapOrState *node)
Definition: nodeBitmapOr.c:196
void ExecEndCteScan(CteScanState *node)
Definition: nodeCtescan.c:288
void ExecEndCustomScan(CustomScanState *node)
Definition: nodeCustom.c:119
void ExecEndForeignScan(ForeignScanState *node)
void ExecEndFunctionScan(FunctionScanState *node)
void ExecEndGatherMerge(GatherMergeState *node)
void ExecEndGather(GatherState *node)
Definition: nodeGather.c:249
void ExecEndGroup(GroupState *node)
Definition: nodeGroup.c:227
void ExecEndHash(HashState *node)
Definition: nodeHash.c:407
void ExecEndHashJoin(HashJoinState *node)
Definition: nodeHashjoin.c:765
void ExecEndIncrementalSort(IncrementalSortState *node)
void ExecEndIndexOnlyScan(IndexOnlyScanState *node)
void ExecEndIndexScan(IndexScanState *node)
void ExecEndLimit(LimitState *node)
Definition: nodeLimit.c:535
void ExecEndLockRows(LockRowsState *node)
Definition: nodeLockRows.c:386
void ExecEndMaterial(MaterialState *node)
Definition: nodeMaterial.c:240
void ExecEndMemoize(MemoizeState *node)
Definition: nodeMemoize.c:1030
void ExecEndMergeAppend(MergeAppendState *node)
void ExecEndMergeJoin(MergeJoinState *node)
void ExecEndModifyTable(ModifyTableState *node)
void ExecEndNamedTuplestoreScan(NamedTuplestoreScanState *node)
void ExecEndNestLoop(NestLoopState *node)
Definition: nodeNestloop.c:362
void ExecEndProjectSet(ProjectSetState *node)
void ExecEndRecursiveUnion(RecursiveUnionState *node)
void ExecEndResult(ResultState *node)
Definition: nodeResult.c:241
void ExecEndSampleScan(SampleScanState *node)
void ExecEndSeqScan(SeqScanState *node)
Definition: nodeSeqscan.c:184
void ExecEndSetOp(SetOpState *node)
Definition: nodeSetOp.c:583
void ExecEndSort(SortState *node)
Definition: nodeSort.c:291
void ExecEndSubqueryScan(SubqueryScanState *node)
void ExecEndTableFuncScan(TableFuncScanState *node)
void ExecEndTidRangeScan(TidRangeScanState *node)
void ExecEndTidScan(TidScanState *node)
Definition: nodeTidscan.c:468
void ExecEndUnique(UniqueState *node)
Definition: nodeUnique.c:169
void ExecEndValuesScan(ValuesScanState *node)
void ExecEndWindowAgg(WindowAggState *node)
void ExecEndWorkTableScan(WorkTableScanState *node)
#define nodeTag(nodeptr)
Definition: nodes.h:543
@ T_HashJoinState
Definition: nodes.h:134
@ T_WorkTableScanState
Definition: nodes.h:128
@ T_MergeAppendState
Definition: nodes.h:109
@ T_IndexOnlyScanState
Definition: nodes.h:117
@ T_SeqScanState
Definition: nodes.h:114
@ T_ValuesScanState
Definition: nodes.h:125
@ T_CustomScanState
Definition: nodes.h:130
@ T_HashState
Definition: nodes.h:145
@ T_TidRangeScanState
Definition: nodes.h:121
@ T_GroupState
Definition: nodes.h:139
@ T_SampleScanState
Definition: nodes.h:115
@ T_SortState
Definition: nodes.h:137
@ T_IncrementalSortState
Definition: nodes.h:138
@ T_SubqueryScanState
Definition: nodes.h:122
@ T_CteScanState
Definition: nodes.h:126
@ T_ResultState
Definition: nodes.h:105
@ T_BitmapHeapScanState
Definition: nodes.h:119
@ T_RecursiveUnionState
Definition: nodes.h:110
@ T_MaterialState
Definition: nodes.h:135
@ T_AppendState
Definition: nodes.h:108
@ T_LockRowsState
Definition: nodes.h:147
@ T_NamedTuplestoreScanState
Definition: nodes.h:127
@ T_TidScanState
Definition: nodes.h:120
@ T_ModifyTableState
Definition: nodes.h:107
@ T_AggState
Definition: nodes.h:140
@ T_ProjectSetState
Definition: nodes.h:106
@ T_GatherState
Definition: nodes.h:143
@ T_BitmapOrState
Definition: nodes.h:112
@ T_FunctionScanState
Definition: nodes.h:123
@ T_SetOpState
Definition: nodes.h:146
@ T_UniqueState
Definition: nodes.h:142
@ T_MemoizeState
Definition: nodes.h:136
@ T_MergeJoinState
Definition: nodes.h:133
@ T_BitmapAndState
Definition: nodes.h:111
@ T_WindowAggState
Definition: nodes.h:141
@ T_NestLoopState
Definition: nodes.h:132
@ T_TableFuncScanState
Definition: nodes.h:124
@ T_BitmapIndexScanState
Definition: nodes.h:118
@ T_IndexScanState
Definition: nodes.h:116
@ T_GatherMergeState
Definition: nodes.h:144
@ T_ForeignScanState
Definition: nodes.h:129
@ T_LimitState
Definition: nodes.h:148
void check_stack_depth(void)
Definition: postgres.c:3470
Bitmapset * chgParam
Definition: execnodes.h:1003

References bms_free(), check_stack_depth(), PlanState::chgParam, elog, ERROR, ExecEndAgg(), ExecEndAppend(), ExecEndBitmapAnd(), ExecEndBitmapHeapScan(), ExecEndBitmapIndexScan(), ExecEndBitmapOr(), ExecEndCteScan(), ExecEndCustomScan(), ExecEndForeignScan(), ExecEndFunctionScan(), ExecEndGather(), ExecEndGatherMerge(), ExecEndGroup(), ExecEndHash(), ExecEndHashJoin(), ExecEndIncrementalSort(), ExecEndIndexOnlyScan(), ExecEndIndexScan(), ExecEndLimit(), ExecEndLockRows(), ExecEndMaterial(), ExecEndMemoize(), ExecEndMergeAppend(), ExecEndMergeJoin(), ExecEndModifyTable(), ExecEndNamedTuplestoreScan(), ExecEndNestLoop(), ExecEndProjectSet(), ExecEndRecursiveUnion(), ExecEndResult(), ExecEndSampleScan(), ExecEndSeqScan(), ExecEndSetOp(), ExecEndSort(), ExecEndSubqueryScan(), ExecEndTableFuncScan(), ExecEndTidRangeScan(), ExecEndTidScan(), ExecEndUnique(), ExecEndValuesScan(), ExecEndWindowAgg(), ExecEndWorkTableScan(), nodeTag, T_AggState, T_AppendState, T_BitmapAndState, T_BitmapHeapScanState, T_BitmapIndexScanState, T_BitmapOrState, T_CteScanState, T_CustomScanState, T_ForeignScanState, T_FunctionScanState, T_GatherMergeState, T_GatherState, T_GroupState, T_HashJoinState, T_HashState, T_IncrementalSortState, T_IndexOnlyScanState, T_IndexScanState, T_LimitState, T_LockRowsState, T_MaterialState, T_MemoizeState, T_MergeAppendState, T_MergeJoinState, T_ModifyTableState, T_NamedTuplestoreScanState, T_NestLoopState, T_ProjectSetState, T_RecursiveUnionState, T_ResultState, T_SampleScanState, T_SeqScanState, T_SetOpState, T_SortState, T_SubqueryScanState, T_TableFuncScanState, T_TidRangeScanState, T_TidScanState, T_UniqueState, T_ValuesScanState, T_WindowAggState, and T_WorkTableScanState.

Referenced by EvalPlanQualEnd(), ExecEndAgg(), ExecEndAppend(), ExecEndBitmapAnd(), ExecEndBitmapHeapScan(), ExecEndBitmapOr(), ExecEndForeignScan(), ExecEndGather(), ExecEndGatherMerge(), ExecEndGroup(), ExecEndHash(), ExecEndHashJoin(), ExecEndIncrementalSort(), ExecEndLimit(), ExecEndLockRows(), ExecEndMaterial(), ExecEndMemoize(), ExecEndMergeAppend(), ExecEndMergeJoin(), ExecEndModifyTable(), ExecEndNestLoop(), ExecEndPlan(), ExecEndProjectSet(), ExecEndRecursiveUnion(), ExecEndResult(), ExecEndSetOp(), ExecEndSort(), ExecEndSubqueryScan(), ExecEndUnique(), and ExecEndWindowAgg().

◆ ExecInitNode()

PlanState* ExecInitNode ( Plan node,
EState estate,
int  eflags 
)

Definition at line 141 of file execProcnode.c.

142 {
143  PlanState *result;
144  List *subps;
145  ListCell *l;
146 
147  /*
148  * do nothing when we get to the end of a leaf on tree.
149  */
150  if (node == NULL)
151  return NULL;
152 
153  /*
154  * Make sure there's enough stack available. Need to check here, in
155  * addition to ExecProcNode() (via ExecProcNodeFirst()), to ensure the
156  * stack isn't overrun while initializing the node tree.
157  */
159 
160  switch (nodeTag(node))
161  {
162  /*
163  * control nodes
164  */
165  case T_Result:
166  result = (PlanState *) ExecInitResult((Result *) node,
167  estate, eflags);
168  break;
169 
170  case T_ProjectSet:
171  result = (PlanState *) ExecInitProjectSet((ProjectSet *) node,
172  estate, eflags);
173  break;
174 
175  case T_ModifyTable:
176  result = (PlanState *) ExecInitModifyTable((ModifyTable *) node,
177  estate, eflags);
178  break;
179 
180  case T_Append:
181  result = (PlanState *) ExecInitAppend((Append *) node,
182  estate, eflags);
183  break;
184 
185  case T_MergeAppend:
186  result = (PlanState *) ExecInitMergeAppend((MergeAppend *) node,
187  estate, eflags);
188  break;
189 
190  case T_RecursiveUnion:
191  result = (PlanState *) ExecInitRecursiveUnion((RecursiveUnion *) node,
192  estate, eflags);
193  break;
194 
195  case T_BitmapAnd:
196  result = (PlanState *) ExecInitBitmapAnd((BitmapAnd *) node,
197  estate, eflags);
198  break;
199 
200  case T_BitmapOr:
201  result = (PlanState *) ExecInitBitmapOr((BitmapOr *) node,
202  estate, eflags);
203  break;
204 
205  /*
206  * scan nodes
207  */
208  case T_SeqScan:
209  result = (PlanState *) ExecInitSeqScan((SeqScan *) node,
210  estate, eflags);
211  break;
212 
213  case T_SampleScan:
214  result = (PlanState *) ExecInitSampleScan((SampleScan *) node,
215  estate, eflags);
216  break;
217 
218  case T_IndexScan:
219  result = (PlanState *) ExecInitIndexScan((IndexScan *) node,
220  estate, eflags);
221  break;
222 
223  case T_IndexOnlyScan:
224  result = (PlanState *) ExecInitIndexOnlyScan((IndexOnlyScan *) node,
225  estate, eflags);
226  break;
227 
228  case T_BitmapIndexScan:
229  result = (PlanState *) ExecInitBitmapIndexScan((BitmapIndexScan *) node,
230  estate, eflags);
231  break;
232 
233  case T_BitmapHeapScan:
234  result = (PlanState *) ExecInitBitmapHeapScan((BitmapHeapScan *) node,
235  estate, eflags);
236  break;
237 
238  case T_TidScan:
239  result = (PlanState *) ExecInitTidScan((TidScan *) node,
240  estate, eflags);
241  break;
242 
243  case T_TidRangeScan:
244  result = (PlanState *) ExecInitTidRangeScan((TidRangeScan *) node,
245  estate, eflags);
246  break;
247 
248  case T_SubqueryScan:
249  result = (PlanState *) ExecInitSubqueryScan((SubqueryScan *) node,
250  estate, eflags);
251  break;
252 
253  case T_FunctionScan:
254  result = (PlanState *) ExecInitFunctionScan((FunctionScan *) node,
255  estate, eflags);
256  break;
257 
258  case T_TableFuncScan:
259  result = (PlanState *) ExecInitTableFuncScan((TableFuncScan *) node,
260  estate, eflags);
261  break;
262 
263  case T_ValuesScan:
264  result = (PlanState *) ExecInitValuesScan((ValuesScan *) node,
265  estate, eflags);
266  break;
267 
268  case T_CteScan:
269  result = (PlanState *) ExecInitCteScan((CteScan *) node,
270  estate, eflags);
271  break;
272 
275  estate, eflags);
276  break;
277 
278  case T_WorkTableScan:
279  result = (PlanState *) ExecInitWorkTableScan((WorkTableScan *) node,
280  estate, eflags);
281  break;
282 
283  case T_ForeignScan:
284  result = (PlanState *) ExecInitForeignScan((ForeignScan *) node,
285  estate, eflags);
286  break;
287 
288  case T_CustomScan:
289  result = (PlanState *) ExecInitCustomScan((CustomScan *) node,
290  estate, eflags);
291  break;
292 
293  /*
294  * join nodes
295  */
296  case T_NestLoop:
297  result = (PlanState *) ExecInitNestLoop((NestLoop *) node,
298  estate, eflags);
299  break;
300 
301  case T_MergeJoin:
302  result = (PlanState *) ExecInitMergeJoin((MergeJoin *) node,
303  estate, eflags);
304  break;
305 
306  case T_HashJoin:
307  result = (PlanState *) ExecInitHashJoin((HashJoin *) node,
308  estate, eflags);
309  break;
310 
311  /*
312  * materialization nodes
313  */
314  case T_Material:
315  result = (PlanState *) ExecInitMaterial((Material *) node,
316  estate, eflags);
317  break;
318 
319  case T_Sort:
320  result = (PlanState *) ExecInitSort((Sort *) node,
321  estate, eflags);
322  break;
323 
324  case T_IncrementalSort:
325  result = (PlanState *) ExecInitIncrementalSort((IncrementalSort *) node,
326  estate, eflags);
327  break;
328 
329  case T_Memoize:
330  result = (PlanState *) ExecInitMemoize((Memoize *) node, estate,
331  eflags);
332  break;
333 
334  case T_Group:
335  result = (PlanState *) ExecInitGroup((Group *) node,
336  estate, eflags);
337  break;
338 
339  case T_Agg:
340  result = (PlanState *) ExecInitAgg((Agg *) node,
341  estate, eflags);
342  break;
343 
344  case T_WindowAgg:
345  result = (PlanState *) ExecInitWindowAgg((WindowAgg *) node,
346  estate, eflags);
347  break;
348 
349  case T_Unique:
350  result = (PlanState *) ExecInitUnique((Unique *) node,
351  estate, eflags);
352  break;
353 
354  case T_Gather:
355  result = (PlanState *) ExecInitGather((Gather *) node,
356  estate, eflags);
357  break;
358 
359  case T_GatherMerge:
360  result = (PlanState *) ExecInitGatherMerge((GatherMerge *) node,
361  estate, eflags);
362  break;
363 
364  case T_Hash:
365  result = (PlanState *) ExecInitHash((Hash *) node,
366  estate, eflags);
367  break;
368 
369  case T_SetOp:
370  result = (PlanState *) ExecInitSetOp((SetOp *) node,
371  estate, eflags);
372  break;
373 
374  case T_LockRows:
375  result = (PlanState *) ExecInitLockRows((LockRows *) node,
376  estate, eflags);
377  break;
378 
379  case T_Limit:
380  result = (PlanState *) ExecInitLimit((Limit *) node,
381  estate, eflags);
382  break;
383 
384  default:
385  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
386  result = NULL; /* keep compiler quiet */
387  break;
388  }
389 
390  ExecSetExecProcNode(result, result->ExecProcNode);
391 
392  /*
393  * Initialize any initPlans present in this node. The planner put them in
394  * a separate list for us.
395  */
396  subps = NIL;
397  foreach(l, node->initPlan)
398  {
399  SubPlan *subplan = (SubPlan *) lfirst(l);
400  SubPlanState *sstate;
401 
402  Assert(IsA(subplan, SubPlan));
403  sstate = ExecInitSubPlan(subplan, result);
404  subps = lappend(subps, sstate);
405  }
406  result->initPlan = subps;
407 
408  /* Set up instrumentation for this node if requested */
409  if (estate->es_instrument)
410  result->instrument = InstrAlloc(1, estate->es_instrument,
411  result->async_capable);
412 
413  return result;
414 }
void ExecSetExecProcNode(PlanState *node, ExecProcNodeMtd function)
Definition: execProcnode.c:424
Instrumentation * InstrAlloc(int n, int instrument_options, bool async_mode)
Definition: instrument.c:31
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
Definition: list.c:336
AggState * ExecInitAgg(Agg *node, EState *estate, int eflags)
Definition: nodeAgg.c:3155
AppendState * ExecInitAppend(Append *node, EState *estate, int eflags)
Definition: nodeAppend.c:109
BitmapAndState * ExecInitBitmapAnd(BitmapAnd *node, EState *estate, int eflags)
Definition: nodeBitmapAnd.c:55
BitmapHeapScanState * ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
BitmapIndexScanState * ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags)
BitmapOrState * ExecInitBitmapOr(BitmapOr *node, EState *estate, int eflags)
Definition: nodeBitmapOr.c:56
CteScanState * ExecInitCteScan(CteScan *node, EState *estate, int eflags)
Definition: nodeCtescan.c:175
CustomScanState * ExecInitCustomScan(CustomScan *cscan, EState *estate, int eflags)
Definition: nodeCustom.c:29
ForeignScanState * ExecInitForeignScan(ForeignScan *node, EState *estate, int eflags)
FunctionScanState * ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags)
GatherMergeState * ExecInitGatherMerge(GatherMerge *node, EState *estate, int eflags)
GatherState * ExecInitGather(Gather *node, EState *estate, int eflags)
Definition: nodeGather.c:58
GroupState * ExecInitGroup(Group *node, EState *estate, int eflags)
Definition: nodeGroup.c:162
HashState * ExecInitHash(Hash *node, EState *estate, int eflags)
Definition: nodeHash.c:354
HashJoinState * ExecInitHashJoin(HashJoin *node, EState *estate, int eflags)
Definition: nodeHashjoin.c:617
IncrementalSortState * ExecInitIncrementalSort(IncrementalSort *node, EState *estate, int eflags)
IndexOnlyScanState * ExecInitIndexOnlyScan(IndexOnlyScan *node, EState *estate, int eflags)
IndexScanState * ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
LimitState * ExecInitLimit(Limit *node, EState *estate, int eflags)
Definition: nodeLimit.c:448
LockRowsState * ExecInitLockRows(LockRows *node, EState *estate, int eflags)
Definition: nodeLockRows.c:292
MaterialState * ExecInitMaterial(Material *node, EState *estate, int eflags)
Definition: nodeMaterial.c:164
MemoizeState * ExecInitMemoize(Memoize *node, EState *estate, int eflags)
Definition: nodeMemoize.c:905
MergeAppendState * ExecInitMergeAppend(MergeAppend *node, EState *estate, int eflags)
MergeJoinState * ExecInitMergeJoin(MergeJoin *node, EState *estate, int eflags)
ModifyTableState * ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
NamedTuplestoreScanState * ExecInitNamedTuplestoreScan(NamedTuplestoreScan *node, EState *estate, int eflags)
NestLoopState * ExecInitNestLoop(NestLoop *node, EState *estate, int eflags)
Definition: nodeNestloop.c:263
ProjectSetState * ExecInitProjectSet(ProjectSet *node, EState *estate, int eflags)
RecursiveUnionState * ExecInitRecursiveUnion(RecursiveUnion *node, EState *estate, int eflags)
ResultState * ExecInitResult(Result *node, EState *estate, int eflags)
Definition: nodeResult.c:181
SampleScanState * ExecInitSampleScan(SampleScan *node, EState *estate, int eflags)
SeqScanState * ExecInitSeqScan(SeqScan *node, EState *estate, int eflags)
Definition: nodeSeqscan.c:123
SetOpState * ExecInitSetOp(SetOp *node, EState *estate, int eflags)
Definition: nodeSetOp.c:481
SortState * ExecInitSort(Sort *node, EState *estate, int eflags)
Definition: nodeSort.c:214
SubPlanState * ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
Definition: nodeSubplan.c:789
SubqueryScanState * ExecInitSubqueryScan(SubqueryScan *node, EState *estate, int eflags)
TableFuncScanState * ExecInitTableFuncScan(TableFuncScan *node, EState *estate, int eflags)
TidRangeScanState * ExecInitTidRangeScan(TidRangeScan *node, EState *estate, int eflags)
TidScanState * ExecInitTidScan(TidScan *node, EState *estate, int eflags)
Definition: nodeTidscan.c:498
UniqueState * ExecInitUnique(Unique *node, EState *estate, int eflags)
Definition: nodeUnique.c:115
ValuesScanState * ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags)
WindowAggState * ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
WorkTableScanState * ExecInitWorkTableScan(WorkTableScan *node, EState *estate, int eflags)
#define IsA(nodeptr, _type_)
Definition: nodes.h:589
@ T_Unique
Definition: nodes.h:83
@ T_NamedTuplestoreScan
Definition: nodes.h:68
@ T_TidRangeScan
Definition: nodes.h:62
@ T_TableFuncScan
Definition: nodes.h:66
@ T_FunctionScan
Definition: nodes.h:64
@ T_BitmapOr
Definition: nodes.h:53
@ T_Material
Definition: nodes.h:76
@ T_IndexOnlyScan
Definition: nodes.h:58
@ T_Append
Definition: nodes.h:49
@ T_Gather
Definition: nodes.h:84
@ T_BitmapIndexScan
Definition: nodes.h:59
@ T_RecursiveUnion
Definition: nodes.h:51
@ T_LockRows
Definition: nodes.h:88
@ T_Hash
Definition: nodes.h:86
@ T_TidScan
Definition: nodes.h:61
@ T_Limit
Definition: nodes.h:89
@ T_Memoize
Definition: nodes.h:77
@ T_Sort
Definition: nodes.h:78
@ T_SeqScan
Definition: nodes.h:55
@ T_WindowAgg
Definition: nodes.h:82
@ T_ProjectSet
Definition: nodes.h:47
@ T_MergeJoin
Definition: nodes.h:74
@ T_SampleScan
Definition: nodes.h:56
@ T_ValuesScan
Definition: nodes.h:65
@ T_BitmapAnd
Definition: nodes.h:52
@ T_MergeAppend
Definition: nodes.h:50
@ T_Agg
Definition: nodes.h:81
@ T_CteScan
Definition: nodes.h:67
@ T_NestLoop
Definition: nodes.h:73
@ T_IncrementalSort
Definition: nodes.h:79
@ T_CustomScan
Definition: nodes.h:71
@ T_Group
Definition: nodes.h:80
@ T_ModifyTable
Definition: nodes.h:48
@ T_GatherMerge
Definition: nodes.h:85
@ T_SubqueryScan
Definition: nodes.h:63
@ T_SetOp
Definition: nodes.h:87
@ T_Result
Definition: nodes.h:46
@ T_IndexScan
Definition: nodes.h:57
@ T_BitmapHeapScan
Definition: nodes.h:60
@ T_WorkTableScan
Definition: nodes.h:69
@ T_ForeignScan
Definition: nodes.h:70
@ T_HashJoin
Definition: nodes.h:75
#define lfirst(lc)
Definition: pg_list.h:169
#define NIL
Definition: pg_list.h:65
Definition: plannodes.h:879
Definition: pg_list.h:51
Instrumentation * instrument
Definition: execnodes.h:981
List * initPlan
Definition: execnodes.h:996
bool async_capable
Definition: execnodes.h:1013
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:977
List * initPlan
Definition: plannodes.h:145

References Assert(), PlanState::async_capable, check_stack_depth(), elog, ERROR, EState::es_instrument, ExecInitAgg(), ExecInitAppend(), ExecInitBitmapAnd(), ExecInitBitmapHeapScan(), ExecInitBitmapIndexScan(), ExecInitBitmapOr(), ExecInitCteScan(), ExecInitCustomScan(), ExecInitForeignScan(), ExecInitFunctionScan(), ExecInitGather(), ExecInitGatherMerge(), ExecInitGroup(), ExecInitHash(), ExecInitHashJoin(), ExecInitIncrementalSort(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecInitLimit(), ExecInitLockRows(), ExecInitMaterial(), ExecInitMemoize(), ExecInitMergeAppend(), ExecInitMergeJoin(), ExecInitModifyTable(), ExecInitNamedTuplestoreScan(), ExecInitNestLoop(), ExecInitProjectSet(), ExecInitRecursiveUnion(), ExecInitResult(), ExecInitSampleScan(), ExecInitSeqScan(), ExecInitSetOp(), ExecInitSort(), ExecInitSubPlan(), ExecInitSubqueryScan(), ExecInitTableFuncScan(), ExecInitTidRangeScan(), ExecInitTidScan(), ExecInitUnique(), ExecInitValuesScan(), ExecInitWindowAgg(), ExecInitWorkTableScan(), PlanState::ExecProcNode, ExecSetExecProcNode(), PlanState::initPlan, Plan::initPlan, InstrAlloc(), PlanState::instrument, IsA, lappend(), lfirst, NIL, nodeTag, T_Agg, T_Append, T_BitmapAnd, T_BitmapHeapScan, T_BitmapIndexScan, T_BitmapOr, T_CteScan, T_CustomScan, T_ForeignScan, T_FunctionScan, T_Gather, T_GatherMerge, T_Group, T_Hash, T_HashJoin, T_IncrementalSort, T_IndexOnlyScan, T_IndexScan, T_Limit, T_LockRows, T_Material, T_Memoize, T_MergeAppend, T_MergeJoin, T_ModifyTable, T_NamedTuplestoreScan, T_NestLoop, T_ProjectSet, T_RecursiveUnion, T_Result, T_SampleScan, T_SeqScan, T_SetOp, T_Sort, T_SubqueryScan, T_TableFuncScan, T_TidRangeScan, T_TidScan, T_Unique, T_ValuesScan, T_WindowAgg, and T_WorkTableScan.

Referenced by EvalPlanQualStart(), ExecInitAgg(), ExecInitAppend(), ExecInitBitmapAnd(), ExecInitBitmapHeapScan(), ExecInitBitmapOr(), ExecInitForeignScan(), ExecInitGather(), ExecInitGatherMerge(), ExecInitGroup(), ExecInitHash(), ExecInitHashJoin(), ExecInitIncrementalSort(), ExecInitLimit(), ExecInitLockRows(), ExecInitMaterial(), ExecInitMemoize(), ExecInitMergeAppend(), ExecInitMergeJoin(), ExecInitModifyTable(), ExecInitNestLoop(), ExecInitProjectSet(), ExecInitRecursiveUnion(), ExecInitResult(), ExecInitSetOp(), ExecInitSort(), ExecInitSubqueryScan(), ExecInitUnique(), ExecInitWindowAgg(), and InitPlan().

◆ ExecProcNodeFirst()

static TupleTableSlot * ExecProcNodeFirst ( PlanState node)
static

Definition at line 442 of file execProcnode.c.

443 {
444  /*
445  * Perform stack depth check during the first execution of the node. We
446  * only do so the first time round because it turns out to not be cheap on
447  * some common architectures (eg. x86). This relies on the assumption
448  * that ExecProcNode calls for a given plan node will always be made at
449  * roughly the same stack depth.
450  */
452 
453  /*
454  * If instrumentation is required, change the wrapper to one that just
455  * does instrumentation. Otherwise we can dispense with all wrappers and
456  * have ExecProcNode() directly call the relevant function from now on.
457  */
458  if (node->instrument)
460  else
461  node->ExecProcNode = node->ExecProcNodeReal;
462 
463  return node->ExecProcNode(node);
464 }
static TupleTableSlot * ExecProcNodeInstr(PlanState *node)
Definition: execProcnode.c:473
ExecProcNodeMtd ExecProcNodeReal
Definition: execnodes.h:978

References check_stack_depth(), PlanState::ExecProcNode, ExecProcNodeInstr(), PlanState::ExecProcNodeReal, and PlanState::instrument.

Referenced by ExecSetExecProcNode().

◆ ExecProcNodeInstr()

static TupleTableSlot * ExecProcNodeInstr ( PlanState node)
static

Definition at line 473 of file execProcnode.c.

474 {
475  TupleTableSlot *result;
476 
477  InstrStartNode(node->instrument);
478 
479  result = node->ExecProcNodeReal(node);
480 
481  InstrStopNode(node->instrument, TupIsNull(result) ? 0.0 : 1.0);
482 
483  return result;
484 }
void InstrStartNode(Instrumentation *instr)
Definition: instrument.c:68
void InstrStopNode(Instrumentation *instr, double nTuples)
Definition: instrument.c:84
#define TupIsNull(slot)
Definition: tuptable.h:292

References PlanState::ExecProcNodeReal, InstrStartNode(), InstrStopNode(), PlanState::instrument, and TupIsNull.

Referenced by ExecProcNodeFirst().

◆ ExecSetExecProcNode()

void ExecSetExecProcNode ( PlanState node,
ExecProcNodeMtd  function 
)

Definition at line 424 of file execProcnode.c.

425 {
426  /*
427  * Add a wrapper around the ExecProcNode callback that checks stack depth
428  * during the first execution and maybe adds an instrumentation wrapper.
429  * When the callback is changed after execution has already begun that
430  * means we'll superfluously execute ExecProcNodeFirst, but that seems ok.
431  */
432  node->ExecProcNodeReal = function;
434 }
static TupleTableSlot * ExecProcNodeFirst(PlanState *node)
Definition: execProcnode.c:442

References PlanState::ExecProcNode, ExecProcNodeFirst(), and PlanState::ExecProcNodeReal.

Referenced by ExecHashJoinInitializeDSM(), ExecHashJoinInitializeWorker(), and ExecInitNode().

◆ ExecSetTupleBound()

void ExecSetTupleBound ( int64  tuples_needed,
PlanState child_node 
)

Definition at line 842 of file execProcnode.c.

843 {
844  /*
845  * Since this function recurses, in principle we should check stack depth
846  * here. In practice, it's probably pointless since the earlier node
847  * initialization tree traversal would surely have consumed more stack.
848  */
849 
850  if (IsA(child_node, SortState))
851  {
852  /*
853  * If it is a Sort node, notify it that it can use bounded sort.
854  *
855  * Note: it is the responsibility of nodeSort.c to react properly to
856  * changes of these parameters. If we ever redesign this, it'd be a
857  * good idea to integrate this signaling with the parameter-change
858  * mechanism.
859  */
860  SortState *sortState = (SortState *) child_node;
861 
862  if (tuples_needed < 0)
863  {
864  /* make sure flag gets reset if needed upon rescan */
865  sortState->bounded = false;
866  }
867  else
868  {
869  sortState->bounded = true;
870  sortState->bound = tuples_needed;
871  }
872  }
873  else if (IsA(child_node, IncrementalSortState))
874  {
875  /*
876  * If it is an IncrementalSort node, notify it that it can use bounded
877  * sort.
878  *
879  * Note: it is the responsibility of nodeIncrementalSort.c to react
880  * properly to changes of these parameters. If we ever redesign this,
881  * it'd be a good idea to integrate this signaling with the
882  * parameter-change mechanism.
883  */
884  IncrementalSortState *sortState = (IncrementalSortState *) child_node;
885 
886  if (tuples_needed < 0)
887  {
888  /* make sure flag gets reset if needed upon rescan */
889  sortState->bounded = false;
890  }
891  else
892  {
893  sortState->bounded = true;
894  sortState->bound = tuples_needed;
895  }
896  }
897  else if (IsA(child_node, AppendState))
898  {
899  /*
900  * If it is an Append, we can apply the bound to any nodes that are
901  * children of the Append, since the Append surely need read no more
902  * than that many tuples from any one input.
903  */
904  AppendState *aState = (AppendState *) child_node;
905  int i;
906 
907  for (i = 0; i < aState->as_nplans; i++)
908  ExecSetTupleBound(tuples_needed, aState->appendplans[i]);
909  }
910  else if (IsA(child_node, MergeAppendState))
911  {
912  /*
913  * If it is a MergeAppend, we can apply the bound to any nodes that
914  * are children of the MergeAppend, since the MergeAppend surely need
915  * read no more than that many tuples from any one input.
916  */
917  MergeAppendState *maState = (MergeAppendState *) child_node;
918  int i;
919 
920  for (i = 0; i < maState->ms_nplans; i++)
921  ExecSetTupleBound(tuples_needed, maState->mergeplans[i]);
922  }
923  else if (IsA(child_node, ResultState))
924  {
925  /*
926  * Similarly, for a projecting Result, we can apply the bound to its
927  * child node.
928  *
929  * If Result supported qual checking, we'd have to punt on seeing a
930  * qual. Note that having a resconstantqual is not a showstopper: if
931  * that condition succeeds it affects nothing, while if it fails, no
932  * rows will be demanded from the Result child anyway.
933  */
934  if (outerPlanState(child_node))
935  ExecSetTupleBound(tuples_needed, outerPlanState(child_node));
936  }
937  else if (IsA(child_node, SubqueryScanState))
938  {
939  /*
940  * We can also descend through SubqueryScan, but only if it has no
941  * qual (otherwise it might discard rows).
942  */
943  SubqueryScanState *subqueryState = (SubqueryScanState *) child_node;
944 
945  if (subqueryState->ss.ps.qual == NULL)
946  ExecSetTupleBound(tuples_needed, subqueryState->subplan);
947  }
948  else if (IsA(child_node, GatherState))
949  {
950  /*
951  * A Gather node can propagate the bound to its workers. As with
952  * MergeAppend, no one worker could possibly need to return more
953  * tuples than the Gather itself needs to.
954  *
955  * Note: As with Sort, the Gather node is responsible for reacting
956  * properly to changes to this parameter.
957  */
958  GatherState *gstate = (GatherState *) child_node;
959 
960  gstate->tuples_needed = tuples_needed;
961 
962  /* Also pass down the bound to our own copy of the child plan */
963  ExecSetTupleBound(tuples_needed, outerPlanState(child_node));
964  }
965  else if (IsA(child_node, GatherMergeState))
966  {
967  /* Same comments as for Gather */
968  GatherMergeState *gstate = (GatherMergeState *) child_node;
969 
970  gstate->tuples_needed = tuples_needed;
971 
972  ExecSetTupleBound(tuples_needed, outerPlanState(child_node));
973  }
974 
975  /*
976  * In principle we could descend through any plan node type that is
977  * certain not to discard or combine input rows; but on seeing a node that
978  * can do that, we can't propagate the bound any further. For the moment
979  * it's unclear that any other cases are worth checking here.
980  */
981 }
void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node)
Definition: execProcnode.c:842
#define outerPlanState(node)
Definition: execnodes.h:1067
int i
Definition: isn.c:73
PlanState ** appendplans
Definition: execnodes.h:1259
int64 tuples_needed
Definition: execnodes.h:2473
PlanState ** mergeplans
Definition: execnodes.h:1302
ExprState * qual
Definition: execnodes.h:992
PlanState ps
Definition: execnodes.h:1382
bool bounded
Definition: execnodes.h:2156
int64 bound
Definition: execnodes.h:2157
PlanState * subplan
Definition: execnodes.h:1707

References AppendState::appendplans, AppendState::as_nplans, SortState::bound, IncrementalSortState::bound, SortState::bounded, IncrementalSortState::bounded, i, IsA, MergeAppendState::mergeplans, MergeAppendState::ms_nplans, outerPlanState, ScanState::ps, PlanState::qual, SubqueryScanState::ss, SubqueryScanState::subplan, GatherState::tuples_needed, and GatherMergeState::tuples_needed.

Referenced by ParallelQueryMain(), and recompute_limits().

◆ ExecShutdownNode()

bool ExecShutdownNode ( PlanState node)

Definition at line 772 of file execProcnode.c.

773 {
774  if (node == NULL)
775  return false;
776 
778 
779  /*
780  * Treat the node as running while we shut it down, but only if it's run
781  * at least once already. We don't expect much CPU consumption during
782  * node shutdown, but in the case of Gather or Gather Merge, we may shut
783  * down workers at this stage. If so, their buffer usage will get
784  * propagated into pgBufferUsage at this point, and we want to make sure
785  * that it gets associated with the Gather node. We skip this if the node
786  * has never been executed, so as to avoid incorrectly making it appear
787  * that it has.
788  */
789  if (node->instrument && node->instrument->running)
790  InstrStartNode(node->instrument);
791 
793 
794  switch (nodeTag(node))
795  {
796  case T_GatherState:
798  break;
799  case T_ForeignScanState:
801  break;
802  case T_CustomScanState:
804  break;
805  case T_GatherMergeState:
807  break;
808  case T_HashState:
809  ExecShutdownHash((HashState *) node);
810  break;
811  case T_HashJoinState:
813  break;
814  default:
815  break;
816  }
817 
818  /* Stop the node if we started it above, reporting 0 tuples. */
819  if (node->instrument && node->instrument->running)
820  InstrStopNode(node->instrument, 0);
821 
822  return false;
823 }
bool ExecShutdownNode(PlanState *node)
Definition: execProcnode.c:772
void ExecShutdownCustomScan(CustomScanState *node)
Definition: nodeCustom.c:222
void ExecShutdownForeignScan(ForeignScanState *node)
bool planstate_tree_walker(PlanState *planstate, bool(*walker)(), void *context)
Definition: nodeFuncs.c:4035
void ExecShutdownGatherMerge(GatherMergeState *node)
void ExecShutdownGather(GatherState *node)
Definition: nodeGather.c:419
void ExecShutdownHash(HashState *node)
Definition: nodeHash.c:2661
void ExecShutdownHashJoin(HashJoinState *node)

References check_stack_depth(), ExecShutdownCustomScan(), ExecShutdownForeignScan(), ExecShutdownGather(), ExecShutdownGatherMerge(), ExecShutdownHash(), ExecShutdownHashJoin(), InstrStartNode(), InstrStopNode(), PlanState::instrument, nodeTag, planstate_tree_walker(), Instrumentation::running, T_CustomScanState, T_ForeignScanState, T_GatherMergeState, T_GatherState, T_HashJoinState, and T_HashState.

Referenced by ExecutePlan().

◆ MultiExecProcNode()

Node* MultiExecProcNode ( PlanState node)

Definition at line 501 of file execProcnode.c.

502 {
503  Node *result;
504 
506 
508 
509  if (node->chgParam != NULL) /* something changed */
510  ExecReScan(node); /* let ReScan handle this */
511 
512  switch (nodeTag(node))
513  {
514  /*
515  * Only node types that actually support multiexec will be listed
516  */
517 
518  case T_HashState:
519  result = MultiExecHash((HashState *) node);
520  break;
521 
524  break;
525 
526  case T_BitmapAndState:
527  result = MultiExecBitmapAnd((BitmapAndState *) node);
528  break;
529 
530  case T_BitmapOrState:
531  result = MultiExecBitmapOr((BitmapOrState *) node);
532  break;
533 
534  default:
535  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
536  result = NULL;
537  break;
538  }
539 
540  return result;
541 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:78
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:120
Node * MultiExecBitmapAnd(BitmapAndState *node)
Node * MultiExecBitmapIndexScan(BitmapIndexScanState *node)
Node * MultiExecBitmapOr(BitmapOrState *node)
Definition: nodeBitmapOr.c:111
Node * MultiExecHash(HashState *node)
Definition: nodeHash.c:106
Definition: nodes.h:539

References CHECK_FOR_INTERRUPTS, check_stack_depth(), PlanState::chgParam, elog, ERROR, ExecReScan(), MultiExecBitmapAnd(), MultiExecBitmapIndexScan(), MultiExecBitmapOr(), MultiExecHash(), nodeTag, T_BitmapAndState, T_BitmapIndexScanState, T_BitmapOrState, and T_HashState.

Referenced by BitmapHeapNext(), ExecHashJoinImpl(), MultiExecBitmapAnd(), and MultiExecBitmapOr().