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 300 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().

301 {
302  /*
303  * Free both exprcontexts
304  */
305  ExecFreeExprContext(&node->ss.ps);
306  node->ss.ps.ps_ExprContext = node->rowcontext;
307  ExecFreeExprContext(&node->ss.ps);
308 
309  /*
310  * clean out the tuple table
311  */
314 }
ExprContext * ps_ExprContext
Definition: execnodes.h:892
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1117
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:603
ScanState ss
Definition: execnodes.h:1470
PlanState ps
Definition: execnodes.h:1114
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:891
ExprContext * rowcontext
Definition: execnodes.h:1471

◆ ExecInitValuesScan()

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

Definition at line 214 of file nodeValuesscan.c.

References Assert, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecAssignScanProjectionInfo(), ExecAssignScanType(), ExecInitQual(), ExecInitResultTupleSlot(), 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().

215 {
216  ValuesScanState *scanstate;
217  TupleDesc tupdesc;
218  ListCell *vtl;
219  int i;
220  PlanState *planstate;
221 
222  /*
223  * ValuesScan should not have any children.
224  */
225  Assert(outerPlan(node) == NULL);
226  Assert(innerPlan(node) == NULL);
227 
228  /*
229  * create new ScanState for node
230  */
231  scanstate = makeNode(ValuesScanState);
232  scanstate->ss.ps.plan = (Plan *) node;
233  scanstate->ss.ps.state = estate;
234  scanstate->ss.ps.ExecProcNode = ExecValuesScan;
235 
236  /*
237  * Miscellaneous initialization
238  */
239  planstate = &scanstate->ss.ps;
240 
241  /*
242  * Create expression contexts. We need two, one for per-sublist
243  * processing and one for execScan.c to use for quals and projections. We
244  * cheat a little by using ExecAssignExprContext() to build both.
245  */
246  ExecAssignExprContext(estate, planstate);
247  scanstate->rowcontext = planstate->ps_ExprContext;
248  ExecAssignExprContext(estate, planstate);
249 
250  /*
251  * tuple table initialization
252  */
253  ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
254  ExecInitScanTupleSlot(estate, &scanstate->ss);
255 
256  /*
257  * initialize child expressions
258  */
259  scanstate->ss.ps.qual =
260  ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
261 
262  /*
263  * get info about values list
264  */
265  tupdesc = ExecTypeFromExprList((List *) linitial(node->values_lists));
266 
267  ExecAssignScanType(&scanstate->ss, tupdesc);
268 
269  /*
270  * Other node-specific setup
271  */
272  scanstate->curr_idx = -1;
273  scanstate->array_len = list_length(node->values_lists);
274 
275  /* convert list of sublists into array of sublists for easy addressing */
276  scanstate->exprlists = (List **)
277  palloc(scanstate->array_len * sizeof(List *));
278  i = 0;
279  foreach(vtl, node->values_lists)
280  {
281  scanstate->exprlists[i++] = (List *) lfirst(vtl);
282  }
283 
284  /*
285  * Initialize result tuple type and projection info.
286  */
287  ExecAssignResultTypeFromTL(&scanstate->ss.ps);
288  ExecAssignScanProjectionInfo(&scanstate->ss);
289 
290  return scanstate;
291 }
List * qual
Definition: plannodes.h:145
Plan plan
Definition: plannodes.h:329
static TupleTableSlot * ExecValuesScan(PlanState *pstate)
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
ExprContext * ps_ExprContext
Definition: execnodes.h:892
List * values_lists
Definition: plannodes.h:520
EState * state
Definition: execnodes.h:860
Scan scan
Definition: plannodes.h:519
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:204
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:448
ScanState ss
Definition: execnodes.h:1470
PlanState ps
Definition: execnodes.h:1114
#define linitial(l)
Definition: pg_list.h:111
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:235
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
#define innerPlan(node)
Definition: plannodes.h:173
#define outerPlan(node)
Definition: plannodes.h:174
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:864
ExprContext * rowcontext
Definition: execnodes.h:1471
Plan * plan
Definition: execnodes.h:858
#define makeNode(_type_)
Definition: nodes.h:560
#define Assert(condition)
Definition: c.h:680
#define lfirst(lc)
Definition: pg_list.h:106
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:426
static int list_length(const List *l)
Definition: pg_list.h:89
ExprState * qual
Definition: execnodes.h:876
TupleDesc ExecTypeFromExprList(List *exprList)
Definition: execTuples.c:947
void * palloc(Size size)
Definition: mcxt.c:835
int i
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:627
List ** exprlists
Definition: execnodes.h:1472
Definition: pg_list.h:45

◆ ExecReScanValuesScan()

void ExecReScanValuesScan ( ValuesScanState node)

Definition at line 323 of file nodeValuesscan.c.

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

Referenced by ExecReScan().

324 {
326 
327  ExecScanReScan(&node->ss);
328 
329  node->curr_idx = -1;
330 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
ScanState ss
Definition: execnodes.h:1470
PlanState ps
Definition: execnodes.h:1114
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:891
void ExecScanReScan(ScanState *node)
Definition: execScan.c:262