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 238 of file nodeGather.c.

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

Referenced by ExecEndNode().

239 {
240  ExecEndNode(outerPlanState(node)); /* let children clean up first */
241  ExecShutdownGather(node);
242  ExecFreeExprContext(&node->ps);
244 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:523
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:523
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:882
#define outerPlanState(node)
Definition: execnodes.h:895
PlanState ps
Definition: execnodes.h:1937
void ExecShutdownGather(GatherState *node)
Definition: nodeGather.c:398

◆ ExecInitGather()

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

Definition at line 58 of file nodeGather.c.

References Assert, ExecAssignExprContext(), ExecAssignProjectionInfo(), ExecAssignResultTypeFromTL(), ExecContextForcesOids(), ExecGather(), ExecInitExtraTupleSlot(), ExecInitNode(), ExecInitResultTupleSlot(), PlanState::ExecProcNode, ExecSetSlotDescriptor(), ExecTypeFromTL(), GatherState::funnel_slot, GatherState::initialized, innerPlan, makeNode, GatherState::need_to_scan_locally, outerPlan, outerPlanState, parallel_leader_participation, Gather::plan, PlanState::plan, GatherState::ps, Plan::qual, Gather::single_copy, PlanState::state, Plan::targetlist, and GatherState::tuples_needed.

Referenced by ExecInitNode().

59 {
60  GatherState *gatherstate;
61  Plan *outerNode;
62  bool hasoid;
63  TupleDesc tupDesc;
64 
65  /* Gather node doesn't have innerPlan node. */
66  Assert(innerPlan(node) == NULL);
67 
68  /*
69  * create state structure
70  */
71  gatherstate = makeNode(GatherState);
72  gatherstate->ps.plan = (Plan *) node;
73  gatherstate->ps.state = estate;
74  gatherstate->ps.ExecProcNode = ExecGather;
75 
76  gatherstate->initialized = false;
77  gatherstate->need_to_scan_locally =
79  gatherstate->tuples_needed = -1;
80 
81  /*
82  * Miscellaneous initialization
83  *
84  * create expression context for node
85  */
86  ExecAssignExprContext(estate, &gatherstate->ps);
87 
88  /*
89  * Gather doesn't support checking a qual (it's always more efficient to
90  * do it in the child node).
91  */
92  Assert(!node->plan.qual);
93 
94  /*
95  * tuple table initialization
96  */
97  gatherstate->funnel_slot = ExecInitExtraTupleSlot(estate);
98  ExecInitResultTupleSlot(estate, &gatherstate->ps);
99 
100  /*
101  * now initialize outer plan
102  */
103  outerNode = outerPlan(node);
104  outerPlanState(gatherstate) = ExecInitNode(outerNode, estate, eflags);
105 
106  /*
107  * Initialize result tuple type and projection info.
108  */
109  ExecAssignResultTypeFromTL(&gatherstate->ps);
110  ExecAssignProjectionInfo(&gatherstate->ps, NULL);
111 
112  /*
113  * Initialize funnel slot to same tuple descriptor as outer plan.
114  */
115  if (!ExecContextForcesOids(&gatherstate->ps, &hasoid))
116  hasoid = false;
117  tupDesc = ExecTypeFromTL(outerNode->targetlist, hasoid);
118  ExecSetSlotDescriptor(gatherstate->funnel_slot, tupDesc);
119 
120  return gatherstate;
121 }
List * qual
Definition: plannodes.h:145
static TupleTableSlot * ExecGather(PlanState *pstate)
Definition: nodeGather.c:131
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate)
Definition: execTuples.c:852
bool need_to_scan_locally
Definition: execnodes.h:1939
EState * state
Definition: execnodes.h:851
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:447
bool initialized
Definition: execnodes.h:1938
Plan plan
Definition: plannodes.h:839
bool single_copy
Definition: plannodes.h:842
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
#define outerPlanState(node)
Definition: execnodes.h:895
#define innerPlan(node)
Definition: plannodes.h:173
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
Definition: execUtils.c:494
PlanState ps
Definition: execnodes.h:1937
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
Definition: execTuples.c:888
#define outerPlan(node)
Definition: plannodes.h:174
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:855
void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc)
Definition: execTuples.c:247
TupleTableSlot * funnel_slot
Definition: execnodes.h:1942
Plan * plan
Definition: execnodes.h:849
bool parallel_leader_participation
Definition: planner.c:64
#define makeNode(_type_)
Definition: nodes.h:558
#define Assert(condition)
Definition: c.h:670
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:425
List * targetlist
Definition: plannodes.h:144
bool ExecContextForcesOids(PlanState *planstate, bool *hasoids)
Definition: execMain.c:1513
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139
int64 tuples_needed
Definition: execnodes.h:1940

◆ ExecReScanGather()

void ExecReScanGather ( GatherState node)

Definition at line 422 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().

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

◆ ExecShutdownGather()

void ExecShutdownGather ( GatherState node)

Definition at line 398 of file nodeGather.c.

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

Referenced by ExecEndGather(), and ExecShutdownNode().

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