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

Go to the source code of this file.

Functions

ValuesScanStateExecInitValuesScan (ValuesScan *node, EState *estate, int eflags)
 
void ExecEndValuesScan (ValuesScanState *node)
 
void ExecReScanValuesScan (ValuesScanState *node)
 

Function Documentation

◆ ExecEndValuesScan()

void ExecEndValuesScan ( ValuesScanState node)

Definition at line 303 of file nodeValuesscan.c.

References ExecClearTuple(), ExecFreeExprContext(), ScanState::ps, PlanState::ps_ExprContext, PlanState::ps_ResultTupleSlot, ValuesScanState::rowcontext, ValuesScanState::ss, and ScanState::ss_ScanTupleSlot.

Referenced by ExecEndNode().

304 {
305  /*
306  * Free both exprcontexts
307  */
308  ExecFreeExprContext(&node->ss.ps);
309  node->ss.ps.ps_ExprContext = node->rowcontext;
310  ExecFreeExprContext(&node->ss.ps);
311 
312  /*
313  * clean out the tuple table
314  */
317 }
ExprContext * ps_ExprContext
Definition: execnodes.h:947
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1195
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:566
ScanState ss
Definition: execnodes.h:1546
PlanState ps
Definition: execnodes.h:1192
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:946
ExprContext * rowcontext
Definition: execnodes.h:1547

◆ ExecInitValuesScan()

ValuesScanState* ExecInitValuesScan ( ValuesScan node,
EState estate,
int  eflags 
)

Definition at line 224 of file nodeValuesscan.c.

References Assert, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecInitQual(), ExecInitResultTupleSlotTL(), ExecInitScanTupleSlot(), PlanState::ExecProcNode, ExecTypeFromExprList(), ExecValuesScan(), i, innerPlan, lfirst, linitial, list_length(), makeNode, outerPlan, palloc(), Scan::plan, PlanState::plan, ScanState::ps, PlanState::ps_ExprContext, Plan::qual, PlanState::qual, ValuesScanState::rowcontext, ValuesScan::scan, ValuesScanState::ss, PlanState::state, and ValuesScan::values_lists.

Referenced by ExecInitNode().

225 {
226  ValuesScanState *scanstate;
227  TupleDesc tupdesc;
228  ListCell *vtl;
229  int i;
230  PlanState *planstate;
231 
232  /*
233  * ValuesScan should not have any children.
234  */
235  Assert(outerPlan(node) == NULL);
236  Assert(innerPlan(node) == NULL);
237 
238  /*
239  * create new ScanState for node
240  */
241  scanstate = makeNode(ValuesScanState);
242  scanstate->ss.ps.plan = (Plan *) node;
243  scanstate->ss.ps.state = estate;
244  scanstate->ss.ps.ExecProcNode = ExecValuesScan;
245 
246  /*
247  * Miscellaneous initialization
248  */
249  planstate = &scanstate->ss.ps;
250 
251  /*
252  * Create expression contexts. We need two, one for per-sublist
253  * processing and one for execScan.c to use for quals and projections. We
254  * cheat a little by using ExecAssignExprContext() to build both.
255  */
256  ExecAssignExprContext(estate, planstate);
257  scanstate->rowcontext = planstate->ps_ExprContext;
258  ExecAssignExprContext(estate, planstate);
259 
260  /*
261  * Get info about values list, initialize scan slot with it.
262  */
263  tupdesc = ExecTypeFromExprList((List *) linitial(node->values_lists));
264  ExecInitScanTupleSlot(estate, &scanstate->ss, tupdesc);
265 
266  /*
267  * Initialize result slot, type and projection.
268  */
269  ExecInitResultTupleSlotTL(estate, &scanstate->ss.ps);
270  ExecAssignScanProjectionInfo(&scanstate->ss);
271 
272  /*
273  * initialize child expressions
274  */
275  scanstate->ss.ps.qual =
276  ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
277 
278  /*
279  * Other node-specific setup
280  */
281  scanstate->curr_idx = -1;
282  scanstate->array_len = list_length(node->values_lists);
283 
284  /* convert list of sublists into array of sublists for easy addressing */
285  scanstate->exprlists = (List **)
286  palloc(scanstate->array_len * sizeof(List *));
287  i = 0;
288  foreach(vtl, node->values_lists)
289  {
290  scanstate->exprlists[i++] = (List *) lfirst(vtl);
291  }
292 
293  return scanstate;
294 }
List * qual
Definition: plannodes.h:147
Plan plan
Definition: plannodes.h:342
static TupleTableSlot * ExecValuesScan(PlanState *pstate)
ExprContext * ps_ExprContext
Definition: execnodes.h:947
List * values_lists
Definition: plannodes.h:533
EState * state
Definition: execnodes.h:914
Scan scan
Definition: plannodes.h:532
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:205
ScanState ss
Definition: execnodes.h:1546
PlanState ps
Definition: execnodes.h:1192
#define linitial(l)
Definition: pg_list.h:111
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:235
#define innerPlan(node)
Definition: plannodes.h:175
#define outerPlan(node)
Definition: plannodes.h:176
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:918
ExprContext * rowcontext
Definition: execnodes.h:1547
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 lfirst(lc)
Definition: pg_list.h:106
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:428
static int list_length(const List *l)
Definition: pg_list.h:89
ExprState * qual
Definition: execnodes.h:930
TupleDesc ExecTypeFromExprList(List *exprList)
Definition: execTuples.c:1024
void * palloc(Size size)
Definition: mcxt.c:924
int i
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc)
Definition: execTuples.c:915
List ** exprlists
Definition: execnodes.h:1548
Definition: pg_list.h:45

◆ ExecReScanValuesScan()

void ExecReScanValuesScan ( ValuesScanState node)

Definition at line 326 of file nodeValuesscan.c.

References ValuesScanState::curr_idx, ExecClearTuple(), ExecScanReScan(), ScanState::ps, PlanState::ps_ResultTupleSlot, and ValuesScanState::ss.

Referenced by ExecReScan().

327 {
329 
330  ExecScanReScan(&node->ss);
331 
332  node->curr_idx = -1;
333 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
ScanState ss
Definition: execnodes.h:1546
PlanState ps
Definition: execnodes.h:1192
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:946
void ExecScanReScan(ScanState *node)
Definition: execScan.c:262