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

322 {
323  /*
324  * Free the exprcontext
325  */
326  ExecFreeExprContext(&node->ps);
327 
328  /*
329  * clean out the tuple table
330  */
332 
333  /*
334  * shut down subplans
335  */
337 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:557
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:658
#define outerPlanState(node)
Definition: execnodes.h:1133
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1075
PlanState ps
Definition: execnodes.h:1255
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:432

References ExecClearTuple(), ExecEndNode(), ExecFreeExprContext(), outerPlanState, ProjectSetState::ps, and PlanState::ps_ResultTupleSlot.

Referenced by ExecEndNode().

◆ ExecInitProjectSet()

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

Definition at line 220 of file nodeProjectSet.c.

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

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

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

Referenced by ExecReScan().