* set_tablefunction_pathlist * Build the (single) access path for a table function RTE */
| 2774 | * Build the (single) access path for a table function RTE |
| 2775 | */ |
| 2776 | static void |
| 2777 | set_tablefunction_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) |
| 2778 | { |
| 2779 | PlannerConfig *config; |
| 2780 | RangeTblFunction *rtfunc; |
| 2781 | FuncExpr *fexpr; |
| 2782 | ListCell *arg; |
| 2783 | RelOptInfo *sub_final_rel; |
| 2784 | Relids required_outer; |
| 2785 | ListCell *lc; |
| 2786 | |
| 2787 | /* Cannot be a preplanned subquery from window_planner. */ |
| 2788 | Assert(!rte->subquery_root); |
| 2789 | |
| 2790 | Assert(list_length(rte->functions) == 1); |
| 2791 | rtfunc = (RangeTblFunction *) linitial(rte->functions); |
| 2792 | Assert(rtfunc->funcexpr && IsA(rtfunc->funcexpr, FuncExpr)); |
| 2793 | fexpr= (FuncExpr *) rtfunc->funcexpr; |
| 2794 | |
| 2795 | /* |
| 2796 | * We don't support pushing join clauses into the quals of a function |
| 2797 | * scan, but it could still have required parameterization due to LATERAL |
| 2798 | * refs in the function expression. |
| 2799 | */ |
| 2800 | required_outer = rel->lateral_relids; |
| 2801 | |
| 2802 | config = CopyPlannerConfig(root->config); |
| 2803 | config->honor_order_by = false; /* partial order is enough */ |
| 2804 | |
| 2805 | /* Plan input subquery */ |
| 2806 | rel->subroot = subquery_planner(root->glob, rte->subquery, root, |
| 2807 | false, |
| 2808 | 0.0, //tuple_fraction |
| 2809 | config); |
| 2810 | |
| 2811 | /* |
| 2812 | * It's possible that constraint exclusion proved the subquery empty. If |
| 2813 | * so, it's desirable to produce an unadorned dummy path so that we will |
| 2814 | * recognize appropriate optimizations at this query level. |
| 2815 | */ |
| 2816 | sub_final_rel = fetch_upper_rel(rel->subroot, UPPERREL_FINAL, NULL); |
| 2817 | |
| 2818 | /* |
| 2819 | * With the subquery planned we now need to clear the subquery from the |
| 2820 | * TableValueExpr nodes, otherwise preprocess_expression will trip over |
| 2821 | * it. |
| 2822 | */ |
| 2823 | foreach(arg, fexpr->args) |
| 2824 | { |
| 2825 | if (IsA(arg, TableValueExpr)) |
| 2826 | { |
| 2827 | TableValueExpr *tve = (TableValueExpr *) arg; |
| 2828 | |
| 2829 | tve->subquery = NULL; |
| 2830 | } |
| 2831 | } |
| 2832 | |
| 2833 | /* Mark rel with estimated output rows, width, etc */ |
no test coverage detected