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:658
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1075
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1477
PlanState ps
Definition: execnodes.h:1474
Tuplestorestate * tupstore
Definition: execnodes.h:1888
void tuplestore_end(Tuplestorestate *state)
Definition: tuplestore.c:453
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:432

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:323
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:214
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:128
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:271
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1812
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1756
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:85
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:488
#define EXEC_FLAG_MARK
Definition: executor.h:69
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:127
int i
Definition: isn.c:73
Assert(fmt[strlen(fmt) - 1] !='\n')
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:2856
MemoryContext CurrentMemoryContext
Definition: mcxt.c:135
void * palloc(Size size)
Definition: mcxt.c:1226
#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:176
#define innerPlan(node)
Definition: plannodes.h:182
#define outerPlan(node)
Definition: plannodes.h:183
unsigned int Oid
Definition: postgres_ext.h:31
Definition: fmgr.h:57
ExprState * qual
Definition: execnodes.h:1058
Plan * plan
Definition: execnodes.h:1037
EState * state
Definition: execnodes.h:1039
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1043
MemoryContext perTableCxt
Definition: execnodes.h:1887
Bitmapset * notnulls
Definition: execnodes.h:1881
const struct TableFuncRoutine * routine
Definition: execnodes.h:1883
ExprState * rowexpr
Definition: execnodes.h:1876
FmgrInfo * in_functions
Definition: execnodes.h:1884
ExprState * docexpr
Definition: execnodes.h:1875
TableFunc * tablefunc
Definition: plannodes.h:631
Node * docexpr
Definition: primnodes.h:103
Node * rowexpr
Definition: primnodes.h:105
List * colexprs
Definition: primnodes.h:115
TupleDesc BuildDescFromLists(List *names, List *types, List *typmods, List *collations)
Definition: tupdesc.c:894
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
const TableFuncRoutine XmlTableRoutine
Definition: xml.c:213

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), BuildDescFromLists(), TableFuncScanState::coldefexprs, TableFuncScanState::colexprs, TableFunc::colexprs, 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, TableFuncScanState::ns_names, TableFuncScanState::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:298
Bitmapset * chgParam
Definition: execnodes.h:1069
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().