MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecInitTableFunction

Function ExecInitTableFunction

src/backend/executor/nodeTableFunction.c:248–451  ·  view source on GitHub ↗

* ExecInitTableFunction - Setup the table function executor */

Source from the content-addressed store, hash-verified

246 * ExecInitTableFunction - Setup the table function executor
247 */
248TableFunctionState *
249ExecInitTableFunction(TableFunctionScan *node, EState *estate, int eflags)
250{
251 TableFunctionState *scanstate;
252 PlanState *subplan;
253 Oid funcrettype;
254 TypeFuncClass functypclass;
255 RangeTblFunction *rtfunc;
256 FuncExpr *func;
257 ExprContext *econtext;
258 TupleDesc inputdesc = NULL;
259 TupleDesc resultdesc = NULL;
260 ListCell *lc;
261 List *argstates;
262
263 /* Inner plan is not used, outer plan must be present */
264 Assert(innerPlan(node) == NULL);
265 Assert(outerPlan(node) != NULL);
266
267 /* Forward scan only */
268 Assert(!(eflags & (EXEC_FLAG_MARK | EXEC_FLAG_BACKWARD)));
269
270 /*
271 * Create state structure.
272 */
273 scanstate = makeNode(TableFunctionState);
274 scanstate->ss.ps.plan = (Plan *)node;
275 scanstate->ss.ps.state = estate;
276 scanstate->ss.ps.ExecProcNode = ExecTableFunction;
277 scanstate->inputscan = palloc0(sizeof(AnyTableData));
278 scanstate->is_firstcall = true;
279
280 /* Create expression context for the node. */
281 ExecAssignExprContext(estate, &scanstate->ss.ps);
282 econtext = scanstate->ss.ps.ps_ExprContext;
283
284 /* Initialize child nodes */
285 outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate, eflags);
286 subplan = outerPlanState(scanstate);
287 inputdesc = CreateTupleDescCopy(ExecGetResultType(subplan));
288
289 /*
290 * The funcexpr must be a function call. This check is to verify that
291 * the planner didn't try to perform constant folding or other inlining
292 * on a function invoked as a table function.
293 */
294 rtfunc = node->function;
295 if (!rtfunc->funcexpr || !IsA(rtfunc->funcexpr, FuncExpr))
296 {
297 /* should not be possible */
298 elog(ERROR, "table function expression is not a function expression");
299 }
300 func = (FuncExpr *) rtfunc->funcexpr;
301 functypclass = get_expr_result_type((Node*) func, &funcrettype, &resultdesc);
302
303 switch (functypclass)
304 {
305 case TYPEFUNC_COMPOSITE:

Callers 1

ExecInitNodeFunction · 0.85

Calls 15

ExecAssignExprContextFunction · 0.85
ExecInitNodeFunction · 0.85
CreateTupleDescCopyFunction · 0.85
ExecGetResultTypeFunction · 0.85
get_expr_result_typeFunction · 0.85
BuildDescFromListsFunction · 0.85
CreateTemplateTupleDescFunction · 0.85
TupleDescInitEntryFunction · 0.85
exprCollationFunction · 0.85
BlessTupleDescFunction · 0.85
ExecInitScanTupleSlotFunction · 0.85

Tested by

no test coverage detected