PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

void ExecEndValuesScan ( ValuesScanState node)

Definition at line 289 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().

290 {
291  /*
292  * Free both exprcontexts
293  */
294  ExecFreeExprContext(&node->ss.ps);
295  node->ss.ps.ps_ExprContext = node->rowcontext;
296  ExecFreeExprContext(&node->ss.ps);
297 
298  /*
299  * clean out the tuple table
300  */
303 }
ExprContext * ps_ExprContext
Definition: execnodes.h:881
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1101
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:521
ScanState ss
Definition: execnodes.h:1446
PlanState ps
Definition: execnodes.h:1098
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:880
ExprContext * rowcontext
Definition: execnodes.h:1447
ValuesScanState* ExecInitValuesScan ( ValuesScan node,
EState estate,
int  eflags 
)

Definition at line 203 of file nodeValuesscan.c.

References ValuesScanState::array_len, Assert, ValuesScanState::curr_idx, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecAssignScanProjectionInfo(), ExecAssignScanType(), ExecInitQual(), ExecInitResultTupleSlot(), ExecInitScanTupleSlot(), PlanState::ExecProcNode, ExecTypeFromExprList(), ExecValuesScan(), ValuesScanState::exprlists, i, innerPlan, lfirst, linitial, list_length(), makeNode, NULL, 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().

204 {
205  ValuesScanState *scanstate;
206  TupleDesc tupdesc;
207  ListCell *vtl;
208  int i;
209  PlanState *planstate;
210 
211  /*
212  * ValuesScan should not have any children.
213  */
214  Assert(outerPlan(node) == NULL);
215  Assert(innerPlan(node) == NULL);
216 
217  /*
218  * create new ScanState for node
219  */
220  scanstate = makeNode(ValuesScanState);
221  scanstate->ss.ps.plan = (Plan *) node;
222  scanstate->ss.ps.state = estate;
223  scanstate->ss.ps.ExecProcNode = ExecValuesScan;
224 
225  /*
226  * Miscellaneous initialization
227  */
228  planstate = &scanstate->ss.ps;
229 
230  /*
231  * Create expression contexts. We need two, one for per-sublist
232  * processing and one for execScan.c to use for quals and projections. We
233  * cheat a little by using ExecAssignExprContext() to build both.
234  */
235  ExecAssignExprContext(estate, planstate);
236  scanstate->rowcontext = planstate->ps_ExprContext;
237  ExecAssignExprContext(estate, planstate);
238 
239  /*
240  * tuple table initialization
241  */
242  ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
243  ExecInitScanTupleSlot(estate, &scanstate->ss);
244 
245  /*
246  * initialize child expressions
247  */
248  scanstate->ss.ps.qual =
249  ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
250 
251  /*
252  * get info about values list
253  */
254  tupdesc = ExecTypeFromExprList((List *) linitial(node->values_lists));
255 
256  ExecAssignScanType(&scanstate->ss, tupdesc);
257 
258  /*
259  * Other node-specific setup
260  */
261  scanstate->curr_idx = -1;
262  scanstate->array_len = list_length(node->values_lists);
263 
264  /* convert list of sublists into array of sublists for easy addressing */
265  scanstate->exprlists = (List **)
266  palloc(scanstate->array_len * sizeof(List *));
267  i = 0;
268  foreach(vtl, node->values_lists)
269  {
270  scanstate->exprlists[i++] = (List *) lfirst(vtl);
271  }
272 
273  /*
274  * Initialize result tuple type and projection info.
275  */
276  ExecAssignResultTypeFromTL(&scanstate->ss.ps);
277  ExecAssignScanProjectionInfo(&scanstate->ss);
278 
279  return scanstate;
280 }
List * qual
Definition: plannodes.h:145
Plan plan
Definition: plannodes.h:328
static TupleTableSlot * ExecValuesScan(PlanState *pstate)
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
ExprContext * ps_ExprContext
Definition: execnodes.h:881
List * values_lists
Definition: plannodes.h:519
EState * state
Definition: execnodes.h:849
Scan scan
Definition: plannodes.h:518
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:160
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:445
ScanState ss
Definition: execnodes.h:1446
PlanState ps
Definition: execnodes.h:1098
#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:853
ExprContext * rowcontext
Definition: execnodes.h:1447
Plan * plan
Definition: execnodes.h:847
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:676
#define lfirst(lc)
Definition: pg_list.h:106
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:423
static int list_length(const List *l)
Definition: pg_list.h:89
ExprState * qual
Definition: execnodes.h:865
TupleDesc ExecTypeFromExprList(List *exprList)
Definition: execTuples.c:947
void * palloc(Size size)
Definition: mcxt.c:849
int i
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:545
List ** exprlists
Definition: execnodes.h:1448
Definition: pg_list.h:45
void ExecReScanValuesScan ( ValuesScanState node)

Definition at line 312 of file nodeValuesscan.c.

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

Referenced by ExecReScan().

313 {
315 
316  ExecScanReScan(&node->ss);
317 
318  node->curr_idx = -1;
319 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
ScanState ss
Definition: execnodes.h:1446
PlanState ps
Definition: execnodes.h:1098
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:880
void ExecScanReScan(ScanState *node)
Definition: execScan.c:327