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  */
315  if (node->ss.ps.ps_ResultTupleSlot)
318 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
ExprContext * ps_ExprContext
Definition: execnodes.h:978
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1333
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:614
ScanState ss
Definition: execnodes.h:1689
PlanState ps
Definition: execnodes.h:1330
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:977
ExprContext * rowcontext
Definition: execnodes.h:1690

◆ ExecInitValuesScan()

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

Definition at line 224 of file nodeValuesscan.c.

References Assert, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecInitQual(), ExecInitResultTypeTL(), 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, TTSOpsVirtual, 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, &TTSOpsVirtual);
265 
266  /*
267  * Initialize result type and projection.
268  */
269  ExecInitResultTypeTL(&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:141
Plan plan
Definition: plannodes.h:340
static TupleTableSlot * ExecValuesScan(PlanState *pstate)
ExprContext * ps_ExprContext
Definition: execnodes.h:978
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:83
List * values_lists
Definition: plannodes.h:532
EState * state
Definition: execnodes.h:941
Scan scan
Definition: plannodes.h:531
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:207
ScanState ss
Definition: execnodes.h:1689
PlanState ps
Definition: execnodes.h:1330
#define linitial(l)
Definition: pg_list.h:195
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:272
#define innerPlan(node)
Definition: plannodes.h:169
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1781
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1725
#define outerPlan(node)
Definition: plannodes.h:170
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:945
ExprContext * rowcontext
Definition: execnodes.h:1690
Plan * plan
Definition: execnodes.h:939
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:739
#define lfirst(lc)
Definition: pg_list.h:190
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:444
static int list_length(const List *l)
Definition: pg_list.h:169
ExprState * qual
Definition: execnodes.h:960
TupleDesc ExecTypeFromExprList(List *exprList)
Definition: execTuples.c:1967
void * palloc(Size size)
Definition: mcxt.c:949
int i
List ** exprlists
Definition: execnodes.h:1691
Definition: pg_list.h:50

◆ ExecReScanValuesScan()

void ExecReScanValuesScan ( ValuesScanState node)

Definition at line 327 of file nodeValuesscan.c.

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

Referenced by ExecReScan().

328 {
329  if (node->ss.ps.ps_ResultTupleSlot)
331 
332  ExecScanReScan(&node->ss);
333 
334  node->curr_idx = -1;
335 }
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:425
ScanState ss
Definition: execnodes.h:1689
PlanState ps
Definition: execnodes.h:1330
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:977
void ExecScanReScan(ScanState *node)
Definition: execScan.c:299