PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

void ExecEndGather ( GatherState node)

Definition at line 234 of file nodeGather.c.

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

Referenced by ExecEndNode().

235 {
236  ExecEndNode(outerPlanState(node)); /* let children clean up first */
237  ExecShutdownGather(node);
238  ExecFreeExprContext(&node->ps);
240 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:523
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:521
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:880
#define outerPlanState(node)
Definition: execnodes.h:893
PlanState ps
Definition: execnodes.h:1927
void ExecShutdownGather(GatherState *node)
Definition: nodeGather.c:394
GatherState* ExecInitGather ( Gather node,
EState estate,
int  eflags 
)

Definition at line 57 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, Gather::plan, PlanState::plan, GatherState::ps, Plan::qual, Gather::single_copy, PlanState::state, Plan::targetlist, and GatherState::tuples_needed.

Referenced by ExecInitNode().

58 {
59  GatherState *gatherstate;
60  Plan *outerNode;
61  bool hasoid;
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 = !node->single_copy;
77  gatherstate->tuples_needed = -1;
78 
79  /*
80  * Miscellaneous initialization
81  *
82  * create expression context for node
83  */
84  ExecAssignExprContext(estate, &gatherstate->ps);
85 
86  /*
87  * Gather doesn't support checking a qual (it's always more efficient to
88  * do it in the child node).
89  */
90  Assert(!node->plan.qual);
91 
92  /*
93  * tuple table initialization
94  */
95  gatherstate->funnel_slot = ExecInitExtraTupleSlot(estate);
96  ExecInitResultTupleSlot(estate, &gatherstate->ps);
97 
98  /*
99  * now initialize outer plan
100  */
101  outerNode = outerPlan(node);
102  outerPlanState(gatherstate) = ExecInitNode(outerNode, estate, eflags);
103 
104  /*
105  * Initialize result tuple type and projection info.
106  */
107  ExecAssignResultTypeFromTL(&gatherstate->ps);
108  ExecAssignProjectionInfo(&gatherstate->ps, NULL);
109 
110  /*
111  * Initialize funnel slot to same tuple descriptor as outer plan.
112  */
113  if (!ExecContextForcesOids(&gatherstate->ps, &hasoid))
114  hasoid = false;
115  tupDesc = ExecTypeFromTL(outerNode->targetlist, hasoid);
116  ExecSetSlotDescriptor(gatherstate->funnel_slot, tupDesc);
117 
118  return gatherstate;
119 }
List * qual
Definition: plannodes.h:145
static TupleTableSlot * ExecGather(PlanState *pstate)
Definition: nodeGather.c:129
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate)
Definition: execTuples.c:852
bool need_to_scan_locally
Definition: execnodes.h:1929
EState * state
Definition: execnodes.h:849
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:445
bool initialized
Definition: execnodes.h:1928
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:893
#define innerPlan(node)
Definition: plannodes.h:173
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
Definition: execUtils.c:492
PlanState ps
Definition: execnodes.h:1927
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
Definition: execTuples.c:888
#define outerPlan(node)
Definition: plannodes.h:174
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:853
void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc)
Definition: execTuples.c:247
TupleTableSlot * funnel_slot
Definition: execnodes.h:1932
Plan * plan
Definition: execnodes.h:847
#define makeNode(_type_)
Definition: nodes.h:557
#define Assert(condition)
Definition: c.h:664
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:423
List * targetlist
Definition: plannodes.h:144
bool ExecContextForcesOids(PlanState *planstate, bool *hasoids)
Definition: execMain.c:1515
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139
int64 tuples_needed
Definition: execnodes.h:1930
void ExecReScanGather ( GatherState node)

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

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

Definition at line 394 of file nodeGather.c.

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

Referenced by ExecEndGather(), and ExecShutdownNode().

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