* create_tablefunction_plan * Returns a TableFunction plan for the base relation scanned by 'best_path' * with restriction clauses 'scan_clauses' and targetlist 'tlist'. */
| 4538 | * with restriction clauses 'scan_clauses' and targetlist 'tlist'. |
| 4539 | */ |
| 4540 | static TableFunctionScan * |
| 4541 | create_tablefunction_plan(PlannerInfo *root, |
| 4542 | TableFunctionScanPath *best_path, |
| 4543 | List *tlist, |
| 4544 | List *scan_clauses) |
| 4545 | { |
| 4546 | TableFunctionScan *tablefunc; |
| 4547 | RelOptInfo *rel = best_path->path.parent; |
| 4548 | Plan *subplan; |
| 4549 | Index scan_relid = rel->relid; |
| 4550 | RangeTblEntry *rte; |
| 4551 | RangeTblFunction *rtf; |
| 4552 | |
| 4553 | /* it should be a function base rel... */ |
| 4554 | Assert(scan_relid > 0); |
| 4555 | rte = planner_rt_fetch(scan_relid, root); |
| 4556 | Assert(rel->rtekind == RTE_TABLEFUNCTION); |
| 4557 | Assert(list_length(rte->functions) == 1); |
| 4558 | rtf = linitial(rte->functions); |
| 4559 | |
| 4560 | /* |
| 4561 | * Recursively create Plan from Path for subquery. Since we are entering |
| 4562 | * a different planner context (subroot), recurse to create_plan not |
| 4563 | * create_plan_recurse. |
| 4564 | */ |
| 4565 | subplan = create_plan(rel->subroot, best_path->subpath, root->curSlice); |
| 4566 | |
| 4567 | /* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */ |
| 4568 | scan_clauses = extract_actual_clauses(scan_clauses, false); |
| 4569 | |
| 4570 | /* Replace any outer-relation variables with nestloop params */ |
| 4571 | if (best_path->path.param_info) { |
| 4572 | scan_clauses = (List *) |
| 4573 | replace_nestloop_params(root, (Node *) scan_clauses); |
| 4574 | process_subquery_nestloop_params(root, |
| 4575 | rel->subplan_params); |
| 4576 | } |
| 4577 | |
| 4578 | /* Create the TableFunctionScan plan */ |
| 4579 | tablefunc = make_tablefunction(tlist, scan_clauses, subplan, scan_relid, rtf); |
| 4580 | |
| 4581 | /* Cost is determined largely by the cost of the underlying subplan */ |
| 4582 | copy_generic_path_info(&tablefunc->scan.plan, &best_path->path); |
| 4583 | |
| 4584 | return tablefunc; |
| 4585 | } |
| 4586 | |
| 4587 | /* |
| 4588 | * create_tablefuncscan_plan |
no test coverage detected