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

245 {
246  ExecEndNode(outerPlanState(node)); /* let children clean up first */
247  ExecShutdownGather(node);
248 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:557
#define outerPlanState(node)
Definition: execnodes.h:1214
void ExecShutdownGather(GatherState *node)
Definition: nodeGather.c:411

References ExecEndNode(), ExecShutdownGather(), and outerPlanState.

Referenced by ExecEndNode().

◆ ExecInitGather()

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

Definition at line 53 of file nodeGather.c.

54 {
55  GatherState *gatherstate;
56  Plan *outerNode;
57  TupleDesc tupDesc;
58 
59  /* Gather node doesn't have innerPlan node. */
60  Assert(innerPlan(node) == NULL);
61 
62  /*
63  * create state structure
64  */
65  gatherstate = makeNode(GatherState);
66  gatherstate->ps.plan = (Plan *) node;
67  gatherstate->ps.state = estate;
68  gatherstate->ps.ExecProcNode = ExecGather;
69 
70  gatherstate->initialized = false;
71  gatherstate->need_to_scan_locally =
73  gatherstate->tuples_needed = -1;
74 
75  /*
76  * Miscellaneous initialization
77  *
78  * create expression context for node
79  */
80  ExecAssignExprContext(estate, &gatherstate->ps);
81 
82  /*
83  * now initialize outer plan
84  */
85  outerNode = outerPlan(node);
86  outerPlanState(gatherstate) = ExecInitNode(outerNode, estate, eflags);
87  tupDesc = ExecGetResultType(outerPlanState(gatherstate));
88 
89  /*
90  * Leader may access ExecProcNode result directly (if
91  * need_to_scan_locally), or from workers via tuple queue. So we can't
92  * trivially rely on the slot type being fixed for expressions evaluated
93  * within this node.
94  */
95  gatherstate->ps.outeropsset = true;
96  gatherstate->ps.outeropsfixed = false;
97 
98  /*
99  * Initialize result type and projection.
100  */
101  ExecInitResultTypeTL(&gatherstate->ps);
102  ExecConditionalAssignProjectionInfo(&gatherstate->ps, tupDesc, OUTER_VAR);
103 
104  /*
105  * Without projections result slot type is not trivially known, see
106  * comment above.
107  */
108  if (gatherstate->ps.ps_ProjInfo == NULL)
109  {
110  gatherstate->ps.resultopsset = true;
111  gatherstate->ps.resultopsfixed = false;
112  }
113 
114  /*
115  * Initialize funnel slot to same tuple descriptor as outer plan.
116  */
117  gatherstate->funnel_slot = ExecInitExtraTupleSlot(estate, tupDesc,
119 
120  /*
121  * Gather doesn't support checking a qual (it's always more efficient to
122  * do it in the child node).
123  */
124  Assert(!node->plan.qual);
125 
126  return gatherstate;
127 }
#define Assert(condition)
Definition: c.h:858
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:142
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1842
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1918
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:86
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:493
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:483
void ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc, int varno)
Definition: execUtils.c:558
static TupleTableSlot * ExecGather(PlanState *pstate)
Definition: nodeGather.c:137
#define makeNode(_type_)
Definition: nodes.h:155
bool parallel_leader_participation
Definition: planner.c:68
#define innerPlan(node)
Definition: plannodes.h:181
#define outerPlan(node)
Definition: plannodes.h:182
#define OUTER_VAR
Definition: primnodes.h:237
bool initialized
Definition: execnodes.h:2670
TupleTableSlot * funnel_slot
Definition: execnodes.h:2674
PlanState ps
Definition: execnodes.h:2669
int64 tuples_needed
Definition: execnodes.h:2672
bool need_to_scan_locally
Definition: execnodes.h:2671
bool single_copy
Definition: plannodes.h:1145
Plan plan
Definition: plannodes.h:1142
bool outeropsset
Definition: execnodes.h:1201
bool resultopsset
Definition: execnodes.h:1203
Plan * plan
Definition: execnodes.h:1118
bool outeropsfixed
Definition: execnodes.h:1197
EState * state
Definition: execnodes.h:1120
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:1158
bool resultopsfixed
Definition: execnodes.h:1199
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1124
List * qual
Definition: plannodes.h:153

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

Referenced by ExecInitNode().

◆ ExecReScanGather()

void ExecReScanGather ( GatherState node)

Definition at line 435 of file nodeGather.c.

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

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

Referenced by ExecReScan().

◆ ExecShutdownGather()

void ExecShutdownGather ( GatherState node)

Definition at line 411 of file nodeGather.c.

412 {
414 
415  /* Now destroy the parallel context. */
416  if (node->pei != NULL)
417  {
418  ExecParallelCleanup(node->pei);
419  node->pei = NULL;
420  }
421 }
void ExecParallelCleanup(ParallelExecutorInfo *pei)
struct ParallelExecutorInfo * pei
Definition: execnodes.h:2675

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

Referenced by ExecEndGather(), and ExecShutdownNode_walker().