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 326 of file nodeProjectSet.c.

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

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 = palloc_array(Node *, state->nelems);
271 state->elemdone = palloc_array(ExprDoneCond, state->nelems);
272
273 /*
274 * Build expressions to evaluate targetlist. We can't use
275 * ExecBuildProjectionInfo here, since that doesn't deal with SRFs.
276 * Instead compile each expression separately, using
277 * ExecInitFunctionResultSet where applicable.
278 */
279 off = 0;
280 foreach(lc, node->plan.targetlist)
281 {
282 TargetEntry *te = (TargetEntry *) lfirst(lc);
283 Expr *expr = te->expr;
284
285 if ((IsA(expr, FuncExpr) && ((FuncExpr *) expr)->funcretset) ||
286 (IsA(expr, OpExpr) && ((OpExpr *) expr)->opretset))
287 {
288 state->elems[off] = (Node *)
289 ExecInitFunctionResultSet(expr, state->ps.ps_ExprContext,
290 &state->ps);
291 }
292 else
293 {
295 state->elems[off] = (Node *) ExecInitExpr(expr, &state->ps);
296 }
297
298 off++;
299 }
300
301 /* We don't support any qual on ProjectSet nodes */
302 Assert(node->plan.qual == NIL);
303
304 /*
305 * Create a memory context that ExecMakeFunctionResultSet can use to
306 * evaluate function arguments in. We can't use the per-tuple context for
307 * this because it gets reset too often; but we don't want to leak
308 * evaluation results into the query-lifespan context either. We use one
309 * context for the arguments of all tSRFs, as they have roughly equivalent
310 * lifetimes.
311 */
313 "tSRF function arguments",
315
316 return state;
317}
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:1988
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
ExprDoneCond
Definition: execnodes.h:326
#define EXEC_FLAG_BACKWARD
Definition: executor.h:69
#define EXEC_FLAG_MARK
Definition: executor.h:70
#define palloc_array(type, count)
Definition: fe_memutils.h:76
Assert(PointerIsAligned(start, uint64))
MemoryContext CurrentMemoryContext
Definition: mcxt.c:160
#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:164
#define makeNode(_type_)
Definition: nodes.h:161
#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:260
#define outerPlan(node)
Definition: plannodes.h:261
Definition: nodes.h:135
List * qual
Definition: plannodes.h:231
List * targetlist
Definition: plannodes.h:229
Plan plan
Definition: plannodes.h:311
Expr * expr
Definition: primnodes.h:2239
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_array, ProjectSet::plan, Plan::qual, Plan::targetlist, and TTSOpsVirtual.

Referenced by ExecInitNode().

◆ ExecReScanProjectSet()

void ExecReScanProjectSet ( ProjectSetState node)

Definition at line 335 of file nodeProjectSet.c.

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

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

Referenced by ExecReScan().