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

Go to the source code of this file.

Functions

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 156 of file nodeSubqueryscan.c.

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

Referenced by ExecEndNode().

157 {
158  /*
159  * Free the exprcontext
160  */
161  ExecFreeExprContext(&node->ss.ps);
162 
163  /*
164  * clean out the upper tuple table
165  */
168 
169  /*
170  * close down subquery
171  */
172  ExecEndNode(node->subplan);
173 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:538
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1195
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:566
PlanState ps
Definition: execnodes.h:1192
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:946
PlanState * subplan
Definition: execnodes.h:1494

◆ ExecInitSubqueryScan()

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

Definition at line 97 of file nodeSubqueryscan.c.

References Assert, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecGetResultType(), ExecInitNode(), ExecInitQual(), ExecInitResultTupleSlotTL(), ExecInitScanTupleSlot(), PlanState::ExecProcNode, ExecSubqueryScan(), innerPlan, makeNode, outerPlan, Scan::plan, PlanState::plan, ScanState::ps, Plan::qual, PlanState::qual, SubqueryScan::scan, SubqueryScanState::ss, PlanState::state, SubqueryScan::subplan, and SubqueryScanState::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 subquery
125  */
126  subquerystate->subplan = ExecInitNode(node->subplan, estate, eflags);
127 
128  /*
129  * Initialize scan slot and type (needed by ExecInitResultTupleSlotTL)
130  */
131  ExecInitScanTupleSlot(estate, &subquerystate->ss,
132  ExecGetResultType(subquerystate->subplan));
133 
134  /*
135  * Initialize result slot, type and projection.
136  */
137  ExecInitResultTupleSlotTL(estate, &subquerystate->ss.ps);
138  ExecAssignScanProjectionInfo(&subquerystate->ss);
139 
140  /*
141  * initialize child expressions
142  */
143  subquerystate->ss.ps.qual =
144  ExecInitQual(node->scan.plan.qual, (PlanState *) subquerystate);
145 
146  return subquerystate;
147 }
List * qual
Definition: plannodes.h:147
Plan plan
Definition: plannodes.h:342
static TupleTableSlot * ExecSubqueryScan(PlanState *pstate)
EState * state
Definition: execnodes.h:914
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:205
PlanState ps
Definition: execnodes.h:1192
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:235
#define innerPlan(node)
Definition: plannodes.h:175
PlanState * subplan
Definition: execnodes.h:1494
#define outerPlan(node)
Definition: plannodes.h:176
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:918
void ExecInitResultTupleSlotTL(EState *estate, PlanState *planstate)
Definition: execTuples.c:890
Plan * plan
Definition: execnodes.h:912
#define makeNode(_type_)
Definition: nodes.h:565
#define Assert(condition)
Definition: c.h:699
#define EXEC_FLAG_MARK
Definition: executor.h:61
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:428
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:438
ExprState * qual
Definition: execnodes.h:930
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc)
Definition: execTuples.c:915
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139
Plan * subplan
Definition: plannodes.h:512

◆ ExecReScanSubqueryScan()

void ExecReScanSubqueryScan ( SubqueryScanState node)

Definition at line 182 of file nodeSubqueryscan.c.

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

Referenced by ExecReScan().

183 {
184  ExecScanReScan(&node->ss);
185 
186  /*
187  * ExecReScan doesn't know about my subplan, so I have to do
188  * changed-parameter signaling myself. This is just as well, because the
189  * subplan has its own memory context in which its chgParam state lives.
190  */
191  if (node->ss.ps.chgParam != NULL)
193 
194  /*
195  * if chgParam of subnode is not null then plan will be re-scanned by
196  * first ExecProcNode.
197  */
198  if (node->subplan->chgParam == NULL)
199  ExecReScan(node->subplan);
200 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
PlanState ps
Definition: execnodes.h:1192
PlanState * subplan
Definition: execnodes.h:1494
Bitmapset * chgParam
Definition: execnodes.h:941
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
Definition: execUtils.c:711
void ExecScanReScan(ScanState *node)
Definition: execScan.c:262