PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 168 of file nodeSubqueryscan.c.

169{
170 /*
171 * close down subquery
172 */
173 ExecEndNode(node->subplan);
174}
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:562
PlanState * subplan
Definition: execnodes.h:1948

References ExecEndNode(), and SubqueryScanState::subplan.

Referenced by ExecEndNode().

◆ ExecInitSubqueryScan()

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

Definition at line 97 of file nodeSubqueryscan.c.

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 ExecAssignScanProjectionInfo)
130 */
131 ExecInitScanTupleSlot(estate, &subquerystate->ss,
132 ExecGetResultType(subquerystate->subplan),
133 ExecGetResultSlotOps(subquerystate->subplan, NULL));
134
135 /*
136 * The slot used as the scantuple isn't the slot above (outside of EPQ),
137 * but the one from the node below.
138 */
139 subquerystate->ss.ps.scanopsset = true;
140 subquerystate->ss.ps.scanops = ExecGetResultSlotOps(subquerystate->subplan,
141 &subquerystate->ss.ps.scanopsfixed);
142 subquerystate->ss.ps.resultopsset = true;
143 subquerystate->ss.ps.resultops = subquerystate->ss.ps.scanops;
144 subquerystate->ss.ps.resultopsfixed = subquerystate->ss.ps.scanopsfixed;
145
146 /*
147 * Initialize result type and projection.
148 */
149 ExecInitResultTypeTL(&subquerystate->ss.ps);
150 ExecAssignScanProjectionInfo(&subquerystate->ss);
151
152 /*
153 * initialize child expressions
154 */
155 subquerystate->ss.ps.qual =
156 ExecInitQual(node->scan.plan.qual, (PlanState *) subquerystate);
157
158 return subquerystate;
159}
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:229
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:142
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:81
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2000
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1944
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:496
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:486
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
Definition: execUtils.c:505
#define EXEC_FLAG_MARK
Definition: executor.h:70
Assert(PointerIsAligned(start, uint64))
static TupleTableSlot * ExecSubqueryScan(PlanState *pstate)
#define makeNode(_type_)
Definition: nodes.h:161
#define innerPlan(node)
Definition: plannodes.h:240
#define outerPlan(node)
Definition: plannodes.h:241
const TupleTableSlotOps * resultops
Definition: execnodes.h:1236
bool resultopsset
Definition: execnodes.h:1244
ExprState * qual
Definition: execnodes.h:1180
const TupleTableSlotOps * scanops
Definition: execnodes.h:1233
Plan * plan
Definition: execnodes.h:1159
EState * state
Definition: execnodes.h:1161
bool scanopsset
Definition: execnodes.h:1241
bool scanopsfixed
Definition: execnodes.h:1237
bool resultopsfixed
Definition: execnodes.h:1240
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1165
PlanState ps
Definition: execnodes.h:1615
Plan * subplan
Definition: plannodes.h:715

References Assert(), EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecGetResultSlotOps(), ExecGetResultType(), ExecInitNode(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), PlanState::ExecProcNode, ExecSubqueryScan(), innerPlan, makeNode, outerPlan, PlanState::plan, ScanState::ps, PlanState::qual, PlanState::resultops, PlanState::resultopsfixed, PlanState::resultopsset, SubqueryScan::scan, PlanState::scanops, PlanState::scanopsfixed, PlanState::scanopsset, SubqueryScanState::ss, PlanState::state, SubqueryScanState::subplan, and SubqueryScan::subplan.

Referenced by ExecInitNode().

◆ ExecReScanSubqueryScan()

void ExecReScanSubqueryScan ( SubqueryScanState node)

Definition at line 183 of file nodeSubqueryscan.c.

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

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

Referenced by ExecReScan().