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 220 of file nodeTableFuncscan.c.

221 {
222  /*
223  * Release tuplestore resources
224  */
225  if (node->tupstore != NULL)
226  tuplestore_end(node->tupstore);
227  node->tupstore = NULL;
228 }
Tuplestorestate * tupstore
Definition: execnodes.h:1971
void tuplestore_end(Tuplestorestate *state)
Definition: tuplestore.c:453

References tuplestore_end(), and TableFuncScanState::tupstore.

Referenced by ExecEndNode().

◆ ExecInitTableFuncScan()

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

Definition at line 111 of file nodeTableFuncscan.c.

112 {
113  TableFuncScanState *scanstate;
114  TableFunc *tf = node->tablefunc;
115  TupleDesc tupdesc;
116  int i;
117 
118  /* check for unsupported flags */
119  Assert(!(eflags & EXEC_FLAG_MARK));
120 
121  /*
122  * TableFuncscan should not have any children.
123  */
124  Assert(outerPlan(node) == NULL);
125  Assert(innerPlan(node) == NULL);
126 
127  /*
128  * create new ScanState for node
129  */
130  scanstate = makeNode(TableFuncScanState);
131  scanstate->ss.ps.plan = (Plan *) node;
132  scanstate->ss.ps.state = estate;
133  scanstate->ss.ps.ExecProcNode = ExecTableFuncScan;
134 
135  /*
136  * Miscellaneous initialization
137  *
138  * create expression context for node
139  */
140  ExecAssignExprContext(estate, &scanstate->ss.ps);
141 
142  /*
143  * initialize source tuple type
144  */
145  tupdesc = BuildDescFromLists(tf->colnames,
146  tf->coltypes,
147  tf->coltypmods,
148  tf->colcollations);
149  /* and the corresponding scan slot */
150  ExecInitScanTupleSlot(estate, &scanstate->ss, tupdesc,
152 
153  /*
154  * Initialize result type and projection.
155  */
156  ExecInitResultTypeTL(&scanstate->ss.ps);
157  ExecAssignScanProjectionInfo(&scanstate->ss);
158 
159  /*
160  * initialize child expressions
161  */
162  scanstate->ss.ps.qual =
163  ExecInitQual(node->scan.plan.qual, &scanstate->ss.ps);
164 
165  /* Only XMLTABLE and JSON_TABLE are supported currently */
166  scanstate->routine =
168 
169  scanstate->perTableCxt =
171  "TableFunc per value context",
173  scanstate->opaque = NULL; /* initialized at runtime */
174 
175  scanstate->ns_names = tf->ns_names;
176 
177  scanstate->ns_uris =
178  ExecInitExprList(tf->ns_uris, (PlanState *) scanstate);
179  scanstate->docexpr =
180  ExecInitExpr((Expr *) tf->docexpr, (PlanState *) scanstate);
181  scanstate->rowexpr =
182  ExecInitExpr((Expr *) tf->rowexpr, (PlanState *) scanstate);
183  scanstate->colexprs =
184  ExecInitExprList(tf->colexprs, (PlanState *) scanstate);
185  scanstate->coldefexprs =
186  ExecInitExprList(tf->coldefexprs, (PlanState *) scanstate);
187  scanstate->colvalexprs =
188  ExecInitExprList(tf->colvalexprs, (PlanState *) scanstate);
189  scanstate->passingvalexprs =
190  ExecInitExprList(tf->passingvalexprs, (PlanState *) scanstate);
191 
192  scanstate->notnulls = tf->notnulls;
193 
194  /* these are allocated now and initialized later */
195  scanstate->in_functions = palloc(sizeof(FmgrInfo) * tupdesc->natts);
196  scanstate->typioparams = palloc(sizeof(Oid) * tupdesc->natts);
197 
198  /*
199  * Fill in the necessary fmgr infos.
200  */
201  for (i = 0; i < tupdesc->natts; i++)
202  {
203  Oid in_funcid;
204 
205  getTypeInputInfo(TupleDescAttr(tupdesc, i)->atttypid,
206  &in_funcid, &scanstate->typioparams[i]);
207  fmgr_info(in_funcid, &scanstate->in_functions[i]);
208  }
209 
210  return scanstate;
211 }
#define Assert(condition)
Definition: c.h:858
List * ExecInitExprList(List *nodes, PlanState *parent)
Definition: execExpr.c:326
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:220
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:134
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:270
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1898
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1842
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:86
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:483
#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
const TableFuncRoutine JsonbTableRoutine
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:2874
MemoryContext CurrentMemoryContext
Definition: mcxt.c:143
void * palloc(Size size)
Definition: mcxt.c:1316
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
static TupleTableSlot * ExecTableFuncScan(PlanState *pstate)
#define makeNode(_type_)
Definition: nodes.h:155
#define innerPlan(node)
Definition: plannodes.h:181
#define outerPlan(node)
Definition: plannodes.h:182
unsigned int Oid
Definition: postgres_ext.h:31
@ TFT_XMLTABLE
Definition: primnodes.h:99
Definition: fmgr.h:57
ExprState * qual
Definition: execnodes.h:1139
Plan * plan
Definition: execnodes.h:1118
EState * state
Definition: execnodes.h:1120
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1124
PlanState ps
Definition: execnodes.h:1565
MemoryContext perTableCxt
Definition: execnodes.h:1970
Bitmapset * notnulls
Definition: execnodes.h:1964
const struct TableFuncRoutine * routine
Definition: execnodes.h:1966
ExprState * rowexpr
Definition: execnodes.h:1957
FmgrInfo * in_functions
Definition: execnodes.h:1967
List * passingvalexprs
Definition: execnodes.h:1961
ExprState * docexpr
Definition: execnodes.h:1956
TableFunc * tablefunc
Definition: plannodes.h:633
Node * docexpr
Definition: primnodes.h:119
Node * rowexpr
Definition: primnodes.h:121
List * colexprs
Definition: primnodes.h:131
TableFuncType functype
Definition: primnodes.h:113
TupleDesc BuildDescFromLists(const List *names, const List *types, const List *typmods, const List *collations)
Definition: tupdesc.c:858
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
const TableFuncRoutine XmlTableRoutine
Definition: xml.c:223

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

Referenced by ExecInitNode().

◆ ExecReScanTableFuncScan()

void ExecReScanTableFuncScan ( TableFuncScanState node)

Definition at line 237 of file nodeTableFuncscan.c.

238 {
239  Bitmapset *chgparam = node->ss.ps.chgParam;
240 
241  if (node->ss.ps.ps_ResultTupleSlot)
243  ExecScanReScan(&node->ss);
244 
245  /*
246  * Recompute when parameters are changed.
247  */
248  if (chgparam)
249  {
250  if (node->tupstore != NULL)
251  {
252  tuplestore_end(node->tupstore);
253  node->tupstore = NULL;
254  }
255  }
256 
257  if (node->tupstore != NULL)
259 }
void ExecScanReScan(ScanState *node)
Definition: execScan.c:297
Bitmapset * chgParam
Definition: execnodes.h:1150
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1156
void tuplestore_rescan(Tuplestorestate *state)
Definition: tuplestore.c:1233
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:454

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

Referenced by ExecReScan().