PostgreSQL Source Code  git master
nodeGather.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeGather.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

GatherStateExecInitGather (Gather *node, EState *estate, int eflags)
 
void ExecEndGather (GatherState *node)
 
void ExecShutdownGather (GatherState *node)
 
void ExecReScanGather (GatherState *node)
 

Function Documentation

◆ ExecEndGather()

void ExecEndGather ( GatherState node)

Definition at line 229 of file nodeGather.c.

References ExecClearTuple(), ExecEndNode(), ExecFreeExprContext(), ExecShutdownGather(), outerPlanState, GatherState::ps, and PlanState::ps_ResultTupleSlot.

Referenced by ExecEndNode().

230 {
231  ExecEndNode(outerPlanState(node)); /* let children clean up first */
232  ExecShutdownGather(node);
233  ExecFreeExprContext(&node->ps);
235 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:538
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:566
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:946
#define outerPlanState(node)
Definition: execnodes.h:966
PlanState ps
Definition: execnodes.h:2053
void ExecShutdownGather(GatherState *node)
Definition: nodeGather.c:396

◆ ExecInitGather()

GatherState* ExecInitGather ( Gather node,
EState estate,
int  eflags 
)

Definition at line 58 of file nodeGather.c.

References Assert, ExecAssignExprContext(), ExecConditionalAssignProjectionInfo(), ExecGather(), ExecGetResultType(), ExecInitExtraTupleSlot(), ExecInitNode(), ExecInitResultTupleSlotTL(), PlanState::ExecProcNode, GatherState::funnel_slot, GatherState::initialized, innerPlan, makeNode, GatherState::need_to_scan_locally, OUTER_VAR, outerPlan, outerPlanState, parallel_leader_participation, Gather::plan, PlanState::plan, GatherState::ps, Plan::qual, Gather::single_copy, PlanState::state, and GatherState::tuples_needed.

Referenced by ExecInitNode().

59 {
60  GatherState *gatherstate;
61  Plan *outerNode;
62  TupleDesc tupDesc;
63 
64  /* Gather node doesn't have innerPlan node. */
65  Assert(innerPlan(node) == NULL);
66 
67  /*
68  * create state structure
69  */
70  gatherstate = makeNode(GatherState);
71  gatherstate->ps.plan = (Plan *) node;
72  gatherstate->ps.state = estate;
73  gatherstate->ps.ExecProcNode = ExecGather;
74 
75  gatherstate->initialized = false;
76  gatherstate->need_to_scan_locally =
78  gatherstate->tuples_needed = -1;
79 
80  /*
81  * Miscellaneous initialization
82  *
83  * create expression context for node
84  */
85  ExecAssignExprContext(estate, &gatherstate->ps);
86 
87  /*
88  * now initialize outer plan
89  */
90  outerNode = outerPlan(node);
91  outerPlanState(gatherstate) = ExecInitNode(outerNode, estate, eflags);
92  tupDesc = ExecGetResultType(outerPlanState(gatherstate));
93 
94  /*
95  * Initialize result slot, type and projection.
96  */
97  ExecInitResultTupleSlotTL(estate, &gatherstate->ps);
98  ExecConditionalAssignProjectionInfo(&gatherstate->ps, tupDesc, OUTER_VAR);
99 
100  /*
101  * Initialize funnel slot to same tuple descriptor as outer plan.
102  */
103  gatherstate->funnel_slot = ExecInitExtraTupleSlot(estate, tupDesc);
104 
105  /*
106  * Gather doesn't support checking a qual (it's always more efficient to
107  * do it in the child node).
108  */
109  Assert(!node->plan.qual);
110 
111  return gatherstate;
112 }
List * qual
Definition: plannodes.h:147
static TupleTableSlot * ExecGather(PlanState *pstate)
Definition: nodeGather.c:122
bool need_to_scan_locally
Definition: execnodes.h:2055
EState * state
Definition: execnodes.h:914
void ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc, Index varno)
Definition: execUtils.c:476
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc)
Definition: execTuples.c:931
bool initialized
Definition: execnodes.h:2054
Plan plan
Definition: plannodes.h:859
bool single_copy
Definition: plannodes.h:862
#define outerPlanState(node)
Definition: execnodes.h:966
#define innerPlan(node)
Definition: plannodes.h:175
PlanState ps
Definition: execnodes.h:2053
#define outerPlan(node)
Definition: plannodes.h:176
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:918
TupleTableSlot * funnel_slot
Definition: execnodes.h:2058
void ExecInitResultTupleSlotTL(EState *estate, PlanState *planstate)
Definition: execTuples.c:890
Plan * plan
Definition: execnodes.h:912
bool parallel_leader_participation
Definition: planner.c:65
#define makeNode(_type_)
Definition: nodes.h:565
#define Assert(condition)
Definition: c.h:699
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:428
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:438
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139
#define OUTER_VAR
Definition: primnodes.h:155
int64 tuples_needed
Definition: execnodes.h:2056

◆ ExecReScanGather()

void ExecReScanGather ( GatherState node)

Definition at line 420 of file nodeGather.c.

References bms_add_member(), ExecReScan(), ExecShutdownGatherWorkers(), GatherState::initialized, outerPlan, outerPlanState, PlanState::plan, GatherState::ps, and Gather::rescan_param.

Referenced by ExecReScan().

421 {
422  Gather *gather = (Gather *) node->ps.plan;
424 
425  /* Make sure any existing workers are gracefully shut down */
427 
428  /* Mark node so that shared state will be rebuilt at next call */
429  node->initialized = false;
430 
431  /*
432  * Set child node's chgParam to tell it that the next scan might deliver a
433  * different set of rows within the leader process. (The overall rowset
434  * shouldn't change, but the leader process's subset might; hence nodes
435  * between here and the parallel table scan node mustn't optimize on the
436  * assumption of an unchanging rowset.)
437  */
438  if (gather->rescan_param >= 0)
439  outerPlan->chgParam = bms_add_member(outerPlan->chgParam,
440  gather->rescan_param);
441 
442  /*
443  * If chgParam of subnode is not null then plan will be re-scanned by
444  * first ExecProcNode. Note: because this does nothing if we have a
445  * rescan_param, it's currently guaranteed that parallel-aware child nodes
446  * will not see a ReScan call until after they get a ReInitializeDSM call.
447  * That ordering might not be something to rely on, though. A good rule
448  * of thumb is that ReInitializeDSM should reset only shared state, ReScan
449  * should reset only local state, and anything that depends on both of
450  * those steps being finished must wait until the first ExecProcNode call.
451  */
452  if (outerPlan->chgParam == NULL)
454 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
bool initialized
Definition: execnodes.h:2054
static void ExecShutdownGatherWorkers(GatherState *node)
Definition: nodeGather.c:378
#define outerPlanState(node)
Definition: execnodes.h:966
PlanState ps
Definition: execnodes.h:2053
#define outerPlan(node)
Definition: plannodes.h:176
Plan * plan
Definition: execnodes.h:912
int rescan_param
Definition: plannodes.h:861
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:764

◆ ExecShutdownGather()

void ExecShutdownGather ( GatherState node)

Definition at line 396 of file nodeGather.c.

References ExecParallelCleanup(), ExecShutdownGatherWorkers(), and GatherState::pei.

Referenced by ExecEndGather(), and ExecShutdownNode().

397 {
399 
400  /* Now destroy the parallel context. */
401  if (node->pei != NULL)
402  {
403  ExecParallelCleanup(node->pei);
404  node->pei = NULL;
405  }
406 }
static void ExecShutdownGatherWorkers(GatherState *node)
Definition: nodeGather.c:378
struct ParallelExecutorInfo * pei
Definition: execnodes.h:2059
void ExecParallelCleanup(ParallelExecutorInfo *pei)