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

Go to the source code of this file.

Functions

TableFuncScanStateExecInitTableFuncScan (TableFuncScan *node, EState *estate, int eflags)
 
void ExecEndTableFuncScan (TableFuncScanState *node)
 
void ExecReScanTableFuncScan (TableFuncScanState *node)
 

Function Documentation

◆ ExecEndTableFuncScan()

void ExecEndTableFuncScan ( TableFuncScanState node)

Definition at line 214 of file nodeTableFuncscan.c.

215 {
216  /*
217  * Free the exprcontext
218  */
219  ExecFreeExprContext(&node->ss.ps);
220 
221  /*
222  * clean out the tuple table
223  */
224  if (node->ss.ps.ps_ResultTupleSlot)
227 
228  /*
229  * Release tuplestore resources
230  */
231  if (node->tupstore != NULL)
232  tuplestore_end(node->tupstore);
233  node->tupstore = NULL;
234 }
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:651
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1062
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1452
PlanState ps
Definition: execnodes.h:1449
Tuplestorestate * tupstore
Definition: execnodes.h:1863
void tuplestore_end(Tuplestorestate *state)
Definition: tuplestore.c:453
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:433

References ExecClearTuple(), ExecFreeExprContext(), ScanState::ps, PlanState::ps_ResultTupleSlot, TableFuncScanState::ss, ScanState::ss_ScanTupleSlot, tuplestore_end(), and TableFuncScanState::tupstore.

Referenced by ExecEndNode().

◆ ExecInitTableFuncScan()

TableFuncScanState* ExecInitTableFuncScan ( TableFuncScan node,
EState estate,
int  eflags 
)

Definition at line 110 of file nodeTableFuncscan.c.

111 {
112  TableFuncScanState *scanstate;
113  TableFunc *tf = node->tablefunc;
114  TupleDesc tupdesc;
115  int i;
116 
117  /* check for unsupported flags */
118  Assert(!(eflags & EXEC_FLAG_MARK));
119 
120  /*
121  * TableFuncscan should not have any children.
122  */
123  Assert(outerPlan(node) == NULL);
124  Assert(innerPlan(node) == NULL);
125 
126  /*
127  * create new ScanState for node
128  */
129  scanstate = makeNode(TableFuncScanState);
130  scanstate->ss.ps.plan = (Plan *) node;
131  scanstate->ss.ps.state = estate;
132  scanstate->ss.ps.ExecProcNode = ExecTableFuncScan;
133 
134  /*
135  * Miscellaneous initialization
136  *
137  * create expression context for node
138  */
139  ExecAssignExprContext(estate, &scanstate->ss.ps);
140 
141  /*
142  * initialize source tuple type
143  */
144  tupdesc = BuildDescFromLists(tf->colnames,
145  tf->coltypes,
146  tf->coltypmods,
147  tf->colcollations);
148  /* and the corresponding scan slot */
149  ExecInitScanTupleSlot(estate, &scanstate->ss, tupdesc,
151 
152  /*
153  * Initialize result type and projection.
154  */
155  ExecInitResultTypeTL(&scanstate->ss.ps);
156  ExecAssignScanProjectionInfo(&scanstate->ss);
157 
158  /*
159  * initialize child expressions
160  */
161  scanstate->ss.ps.qual =
162  ExecInitQual(node->scan.plan.qual, &scanstate->ss.ps);
163 
164  /* Only XMLTABLE is supported currently */
165  scanstate->routine = &XmlTableRoutine;
166 
167  scanstate->perTableCxt =
169  "TableFunc per value context",
171  scanstate->opaque = NULL; /* initialized at runtime */
172 
173  scanstate->ns_names = tf->ns_names;
174 
175  scanstate->ns_uris =
176  ExecInitExprList(tf->ns_uris, (PlanState *) scanstate);
177  scanstate->docexpr =
178  ExecInitExpr((Expr *) tf->docexpr, (PlanState *) scanstate);
179  scanstate->rowexpr =
180  ExecInitExpr((Expr *) tf->rowexpr, (PlanState *) scanstate);
181  scanstate->colexprs =
182  ExecInitExprList(tf->colexprs, (PlanState *) scanstate);
183  scanstate->coldefexprs =
184  ExecInitExprList(tf->coldefexprs, (PlanState *) scanstate);
185 
186  scanstate->notnulls = tf->notnulls;
187 
188  /* these are allocated now and initialized later */
189  scanstate->in_functions = palloc(sizeof(FmgrInfo) * tupdesc->natts);
190  scanstate->typioparams = palloc(sizeof(Oid) * tupdesc->natts);
191 
192  /*
193  * Fill in the necessary fmgr infos.
194  */
195  for (i = 0; i < tupdesc->natts; i++)
196  {
197  Oid in_funcid;
198 
199  getTypeInputInfo(TupleDescAttr(tupdesc, i)->atttypid,
200  &in_funcid, &scanstate->typioparams[i]);
201  fmgr_info(in_funcid, &scanstate->in_functions[i]);
202  }
203 
204  return scanstate;
205 }
List * ExecInitExprList(List *nodes, PlanState *parent)
Definition: execExpr.c:319
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:210
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:124
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:272
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1811
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1755
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:85
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:481
#define EXEC_FLAG_MARK
Definition: executor.h:59
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:126
int i
Definition: isn.c:73
Assert(fmt[strlen(fmt) - 1] !='\n')
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:2832
MemoryContext CurrentMemoryContext
Definition: mcxt.c:124
void * palloc(Size size)
Definition: mcxt.c:1199
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:153
static TupleTableSlot * ExecTableFuncScan(PlanState *pstate)
#define makeNode(_type_)
Definition: nodes.h:159
#define innerPlan(node)
Definition: plannodes.h:179
#define outerPlan(node)
Definition: plannodes.h:180
unsigned int Oid
Definition: postgres_ext.h:31
Definition: fmgr.h:57
ExprState * qual
Definition: execnodes.h:1045
Plan * plan
Definition: execnodes.h:1024
EState * state
Definition: execnodes.h:1026
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1030
MemoryContext perTableCxt
Definition: execnodes.h:1862
Bitmapset * notnulls
Definition: execnodes.h:1856
const struct TableFuncRoutine * routine
Definition: execnodes.h:1858
ExprState * rowexpr
Definition: execnodes.h:1851
FmgrInfo * in_functions
Definition: execnodes.h:1859
ExprState * docexpr
Definition: execnodes.h:1850
TableFunc * tablefunc
Definition: plannodes.h:628
Bitmapset * notnulls
Definition: primnodes.h:111
List * coldefexprs
Definition: primnodes.h:110
Node * docexpr
Definition: primnodes.h:103
List * ns_names
Definition: primnodes.h:102
List * coltypmods
Definition: primnodes.h:107
List * ns_uris
Definition: primnodes.h:101
List * coltypes
Definition: primnodes.h:106
Node * rowexpr
Definition: primnodes.h:104
List * colnames
Definition: primnodes.h:105
List * colexprs
Definition: primnodes.h:109
List * colcollations
Definition: primnodes.h:108
TupleDesc BuildDescFromLists(List *names, List *types, List *typmods, List *collations)
Definition: tupdesc.c:886
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
const TableFuncRoutine XmlTableRoutine
Definition: xml.c:207

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), BuildDescFromLists(), TableFunc::colcollations, TableFuncScanState::coldefexprs, TableFunc::coldefexprs, TableFuncScanState::colexprs, TableFunc::colexprs, TableFunc::colnames, TableFunc::coltypes, TableFunc::coltypmods, CurrentMemoryContext, TableFuncScanState::docexpr, TableFunc::docexpr, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecInitExpr(), ExecInitExprList(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), PlanState::ExecProcNode, ExecTableFuncScan(), fmgr_info(), getTypeInputInfo(), i, TableFuncScanState::in_functions, innerPlan, makeNode, TupleDescData::natts, TableFuncScanState::notnulls, TableFunc::notnulls, TableFuncScanState::ns_names, TableFunc::ns_names, TableFuncScanState::ns_uris, TableFunc::ns_uris, TableFuncScanState::opaque, outerPlan, palloc(), TableFuncScanState::perTableCxt, PlanState::plan, ScanState::ps, PlanState::qual, TableFuncScanState::routine, TableFuncScanState::rowexpr, TableFunc::rowexpr, TableFuncScan::scan, TableFuncScanState::ss, PlanState::state, TableFuncScan::tablefunc, TTSOpsMinimalTuple, TupleDescAttr, TableFuncScanState::typioparams, and XmlTableRoutine.

Referenced by ExecInitNode().

◆ ExecReScanTableFuncScan()

void ExecReScanTableFuncScan ( TableFuncScanState node)

Definition at line 243 of file nodeTableFuncscan.c.

244 {
245  Bitmapset *chgparam = node->ss.ps.chgParam;
246 
247  if (node->ss.ps.ps_ResultTupleSlot)
249  ExecScanReScan(&node->ss);
250 
251  /*
252  * Recompute when parameters are changed.
253  */
254  if (chgparam)
255  {
256  if (node->tupstore != NULL)
257  {
258  tuplestore_end(node->tupstore);
259  node->tupstore = NULL;
260  }
261  }
262 
263  if (node->tupstore != NULL)
265 }
void ExecScanReScan(ScanState *node)
Definition: execScan.c:299
Bitmapset * chgParam
Definition: execnodes.h:1056
void tuplestore_rescan(Tuplestorestate *state)
Definition: tuplestore.c:1233

References PlanState::chgParam, ExecClearTuple(), ExecScanReScan(), ScanState::ps, PlanState::ps_ResultTupleSlot, TableFuncScanState::ss, tuplestore_end(), tuplestore_rescan(), and TableFuncScanState::tupstore.

Referenced by ExecReScan().