PostgreSQL Source Code  git master
nodeSubqueryscan.c File Reference
Include dependency graph for nodeSubqueryscan.c:

Go to the source code of this file.

Functions

static TupleTableSlotSubqueryNext (SubqueryScanState *node)
 
static bool SubqueryRecheck (SubqueryScanState *node, TupleTableSlot *slot)
 
static TupleTableSlotExecSubqueryScan (PlanState *pstate)
 
SubqueryScanStateExecInitSubqueryScan (SubqueryScan *node, EState *estate, int eflags)
 
void ExecEndSubqueryScan (SubqueryScanState *node)
 
void ExecReScanSubqueryScan (SubqueryScanState *node)
 

Function Documentation

◆ ExecEndSubqueryScan()

void ExecEndSubqueryScan ( SubqueryScanState node)

Definition at line 162 of file nodeSubqueryscan.c.

References ExecClearTuple(), ExecEndNode(), ExecFreeExprContext(), ScanState::ps, PlanState::ps_ResultTupleSlot, SubqueryScanState::ss, ScanState::ss_ScanTupleSlot, and SubqueryScanState::subplan.

Referenced by ExecEndNode().

163 {
164  /*
165  * Free the exprcontext
166  */
167  ExecFreeExprContext(&node->ss.ps);
168 
169  /*
170  * clean out the upper tuple table
171  */
174 
175  /*
176  * close down subquery
177  */
178  ExecEndNode(node->subplan);
179 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:523
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1106
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:523
PlanState ps
Definition: execnodes.h:1103
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:882
PlanState * subplan
Definition: execnodes.h:1407

◆ ExecInitSubqueryScan()

SubqueryScanState* ExecInitSubqueryScan ( SubqueryScan node,
EState estate,
int  eflags 
)

Definition at line 97 of file nodeSubqueryscan.c.

References Assert, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecAssignScanProjectionInfo(), ExecAssignScanType(), ExecGetResultType(), ExecInitNode(), ExecInitQual(), ExecInitResultTupleSlot(), ExecInitScanTupleSlot(), PlanState::ExecProcNode, ExecSubqueryScan(), innerPlan, makeNode, outerPlan, Scan::plan, PlanState::plan, ScanState::ps, Plan::qual, PlanState::qual, SubqueryScan::scan, SubqueryScanState::ss, PlanState::state, and SubqueryScan::subplan.

Referenced by ExecInitNode().

98 {
99  SubqueryScanState *subquerystate;
100 
101  /* check for unsupported flags */
102  Assert(!(eflags & EXEC_FLAG_MARK));
103 
104  /* SubqueryScan should not have any "normal" children */
105  Assert(outerPlan(node) == NULL);
106  Assert(innerPlan(node) == NULL);
107 
108  /*
109  * create state structure
110  */
111  subquerystate = makeNode(SubqueryScanState);
112  subquerystate->ss.ps.plan = (Plan *) node;
113  subquerystate->ss.ps.state = estate;
114  subquerystate->ss.ps.ExecProcNode = ExecSubqueryScan;
115 
116  /*
117  * Miscellaneous initialization
118  *
119  * create expression context for node
120  */
121  ExecAssignExprContext(estate, &subquerystate->ss.ps);
122 
123  /*
124  * initialize child expressions
125  */
126  subquerystate->ss.ps.qual =
127  ExecInitQual(node->scan.plan.qual, (PlanState *) subquerystate);
128 
129  /*
130  * tuple table initialization
131  */
132  ExecInitResultTupleSlot(estate, &subquerystate->ss.ps);
133  ExecInitScanTupleSlot(estate, &subquerystate->ss);
134 
135  /*
136  * initialize subquery
137  */
138  subquerystate->subplan = ExecInitNode(node->subplan, estate, eflags);
139 
140  /*
141  * Initialize scan tuple type (needed by ExecAssignScanProjectionInfo)
142  */
143  ExecAssignScanType(&subquerystate->ss,
144  ExecGetResultType(subquerystate->subplan));
145 
146  /*
147  * Initialize result tuple type and projection info.
148  */
149  ExecAssignResultTypeFromTL(&subquerystate->ss.ps);
150  ExecAssignScanProjectionInfo(&subquerystate->ss);
151 
152  return subquerystate;
153 }
List * qual
Definition: plannodes.h:145
Plan plan
Definition: plannodes.h:328
static TupleTableSlot * ExecSubqueryScan(PlanState *pstate)
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
EState * state
Definition: execnodes.h:851
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:160
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:447
PlanState ps
Definition: execnodes.h:1103
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:237
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
#define innerPlan(node)
Definition: plannodes.h:173
PlanState * subplan
Definition: execnodes.h:1407
#define outerPlan(node)
Definition: plannodes.h:174
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:855
Plan * plan
Definition: execnodes.h:849
#define makeNode(_type_)
Definition: nodes.h:558
#define Assert(condition)
Definition: c.h:670
#define EXEC_FLAG_MARK
Definition: executor.h:61
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:425
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:476
ExprState * qual
Definition: execnodes.h:867
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:547
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139
Plan * subplan
Definition: plannodes.h:498

◆ ExecReScanSubqueryScan()

void ExecReScanSubqueryScan ( SubqueryScanState node)

Definition at line 188 of file nodeSubqueryscan.c.

References PlanState::chgParam, ExecReScan(), ExecScanReScan(), ScanState::ps, SubqueryScanState::ss, SubqueryScanState::subplan, and UpdateChangedParamSet().

Referenced by ExecReScan().

189 {
190  ExecScanReScan(&node->ss);
191 
192  /*
193  * ExecReScan doesn't know about my subplan, so I have to do
194  * changed-parameter signaling myself. This is just as well, because the
195  * subplan has its own memory context in which its chgParam state lives.
196  */
197  if (node->ss.ps.chgParam != NULL)
199 
200  /*
201  * if chgParam of subnode is not null then plan will be re-scanned by
202  * first ExecProcNode.
203  */
204  if (node->subplan->chgParam == NULL)
205  ExecReScan(node->subplan);
206 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
PlanState ps
Definition: execnodes.h:1103
PlanState * subplan
Definition: execnodes.h:1407
Bitmapset * chgParam
Definition: execnodes.h:877
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
Definition: execUtils.c:678
void ExecScanReScan(ScanState *node)
Definition: execScan.c:329

◆ ExecSubqueryScan()

static TupleTableSlot* ExecSubqueryScan ( PlanState pstate)
static

Definition at line 83 of file nodeSubqueryscan.c.

References castNode, ExecScan(), SubqueryScanState::ss, SubqueryNext(), and SubqueryRecheck().

Referenced by ExecInitSubqueryScan().

84 {
86 
87  return ExecScan(&node->ss,
90 }
#define castNode(_type_, nodeptr)
Definition: nodes.h:579
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:123
static TupleTableSlot * SubqueryNext(SubqueryScanState *node)
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:401
static bool SubqueryRecheck(SubqueryScanState *node, TupleTableSlot *slot)
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:400

◆ SubqueryNext()

static TupleTableSlot * SubqueryNext ( SubqueryScanState node)
static

Definition at line 46 of file nodeSubqueryscan.c.

References ExecProcNode(), and SubqueryScanState::subplan.

Referenced by ExecSubqueryScan().

47 {
48  TupleTableSlot *slot;
49 
50  /*
51  * Get the next tuple from the sub-query.
52  */
53  slot = ExecProcNode(node->subplan);
54 
55  /*
56  * We just return the subplan's result slot, rather than expending extra
57  * cycles for ExecCopySlot(). (Our own ScanTupleSlot is used only for
58  * EvalPlanQual rechecks.)
59  */
60  return slot;
61 }
PlanState * subplan
Definition: execnodes.h:1407
static TupleTableSlot * ExecProcNode(PlanState *node)
Definition: executor.h:236

◆ SubqueryRecheck()

static bool SubqueryRecheck ( SubqueryScanState node,
TupleTableSlot slot 
)
static

Definition at line 67 of file nodeSubqueryscan.c.

Referenced by ExecSubqueryScan().

68 {
69  /* nothing to check */
70  return true;
71 }