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

Go to the source code of this file.

Functions

ProjectSetStateExecInitProjectSet (ProjectSet *node, EState *estate, int eflags)
 
void ExecEndProjectSet (ProjectSetState *node)
 
void ExecReScanProjectSet (ProjectSetState *node)
 

Function Documentation

◆ ExecEndProjectSet()

void ExecEndProjectSet ( ProjectSetState node)

Definition at line 328 of file nodeProjectSet.c.

329{
330 /*
331 * shut down subplans
332 */
334}
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:562
#define outerPlanState(node)
Definition: execnodes.h:1246

References ExecEndNode(), and outerPlanState.

Referenced by ExecEndNode().

◆ ExecInitProjectSet()

ProjectSetState * ExecInitProjectSet ( ProjectSet node,
EState estate,
int  eflags 
)

Definition at line 227 of file nodeProjectSet.c.

228{
230 ListCell *lc;
231 int off;
232
233 /* check for unsupported flags */
235
236 /*
237 * create state structure
238 */
240 state->ps.plan = (Plan *) node;
241 state->ps.state = estate;
242 state->ps.ExecProcNode = ExecProjectSet;
243
244 state->pending_srf_tuples = false;
245
246 /*
247 * Miscellaneous initialization
248 *
249 * create expression context for node
250 */
251 ExecAssignExprContext(estate, &state->ps);
252
253 /*
254 * initialize child nodes
255 */
256 outerPlanState(state) = ExecInitNode(outerPlan(node), estate, eflags);
257
258 /*
259 * we don't use inner plan
260 */
261 Assert(innerPlan(node) == NULL);
262
263 /*
264 * tuple table and result type initialization
265 */
267
268 /* Create workspace for per-tlist-entry expr state & SRF-is-done state */
269 state->nelems = list_length(node->plan.targetlist);
270 state->elems = (Node **)
271 palloc(sizeof(Node *) * state->nelems);
272 state->elemdone = (ExprDoneCond *)
273 palloc(sizeof(ExprDoneCond) * state->nelems);
274
275 /*
276 * Build expressions to evaluate targetlist. We can't use
277 * ExecBuildProjectionInfo here, since that doesn't deal with SRFs.
278 * Instead compile each expression separately, using
279 * ExecInitFunctionResultSet where applicable.
280 */
281 off = 0;
282 foreach(lc, node->plan.targetlist)
283 {
284 TargetEntry *te = (TargetEntry *) lfirst(lc);
285 Expr *expr = te->expr;
286
287 if ((IsA(expr, FuncExpr) && ((FuncExpr *) expr)->funcretset) ||
288 (IsA(expr, OpExpr) && ((OpExpr *) expr)->opretset))
289 {
290 state->elems[off] = (Node *)
291 ExecInitFunctionResultSet(expr, state->ps.ps_ExprContext,
292 &state->ps);
293 }
294 else
295 {
297 state->elems[off] = (Node *) ExecInitExpr(expr, &state->ps);
298 }
299
300 off++;
301 }
302
303 /* We don't support any qual on ProjectSet nodes */
304 Assert(node->plan.qual == NIL);
305
306 /*
307 * Create a memory context that ExecMakeFunctionResultSet can use to
308 * evaluate function arguments in. We can't use the per-tuple context for
309 * this because it gets reset too often; but we don't want to leak
310 * evaluation results into the query-lifespan context either. We use one
311 * context for the arguments of all tSRFs, as they have roughly equivalent
312 * lifetimes.
313 */
315 "tSRF function arguments",
317
318 return state;
319}
#define Assert(condition)
Definition: c.h:815
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:143
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:142
SetExprState * ExecInitFunctionResultSet(Expr *expr, ExprContext *econtext, PlanState *parent)
Definition: execSRF.c:444
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:84
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1986
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:486
ExprDoneCond
Definition: execnodes.h:320
#define EXEC_FLAG_BACKWARD
Definition: executor.h:68
#define EXEC_FLAG_MARK
Definition: executor.h:69
void * palloc(Size size)
Definition: mcxt.c:1317
MemoryContext CurrentMemoryContext
Definition: mcxt.c:143
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
bool expression_returns_set(Node *clause)
Definition: nodeFuncs.c:763
static TupleTableSlot * ExecProjectSet(PlanState *pstate)
#define IsA(nodeptr, _type_)
Definition: nodes.h:158
#define makeNode(_type_)
Definition: nodes.h:155
#define lfirst(lc)
Definition: pg_list.h:172
static int list_length(const List *l)
Definition: pg_list.h:152
#define NIL
Definition: pg_list.h:68
#define innerPlan(node)
Definition: plannodes.h:230
#define outerPlan(node)
Definition: plannodes.h:231
Definition: nodes.h:129
List * qual
Definition: plannodes.h:201
List * targetlist
Definition: plannodes.h:199
Plan plan
Definition: plannodes.h:259
Expr * expr
Definition: primnodes.h:2219
Definition: regguts.h:323

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, CurrentMemoryContext, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecInitExpr(), ExecInitFunctionResultSet(), ExecInitNode(), ExecInitResultTupleSlotTL(), ExecProjectSet(), TargetEntry::expr, expression_returns_set(), innerPlan, IsA, lfirst, list_length(), makeNode, NIL, outerPlan, outerPlanState, palloc(), ProjectSet::plan, Plan::qual, Plan::targetlist, and TTSOpsVirtual.

Referenced by ExecInitNode().

◆ ExecReScanProjectSet()

void ExecReScanProjectSet ( ProjectSetState node)

Definition at line 337 of file nodeProjectSet.c.

338{
340
341 /* Forget any incompletely-evaluated SRFs */
342 node->pending_srf_tuples = false;
343
344 /*
345 * If chgParam of subnode is not null then plan will be re-scanned by
346 * first ExecProcNode.
347 */
348 if (outerPlan->chgParam == NULL)
350}
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
bool pending_srf_tuples
Definition: execnodes.h:1372

References ExecReScan(), outerPlan, outerPlanState, and ProjectSetState::pending_srf_tuples.

Referenced by ExecReScan().