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

Function set_function_pathlist

src/backend/optimizer/path/allpaths.c:2707–2770  ·  view source on GitHub ↗

* set_function_pathlist * Build the (single) access path for a function RTE */

Source from the content-addressed store, hash-verified

2705 * Build the (single) access path for a function RTE
2706 */
2707static void
2708set_function_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
2709{
2710 Relids required_outer;
2711 List *pathkeys = NIL;
2712
2713 /*
2714 * We don't support pushing join clauses into the quals of a function
2715 * scan, but it could still have required parameterization due to LATERAL
2716 * refs in the function expression.
2717 */
2718 required_outer = rel->lateral_relids;
2719
2720 /*
2721 * The result is considered unordered unless ORDINALITY was used, in which
2722 * case it is ordered by the ordinal column (the last one). See if we
2723 * care, by checking for uses of that Var in equivalence classes.
2724 */
2725 if (rte->funcordinality)
2726 {
2727 AttrNumber ordattno = rel->max_attr;
2728 Var *var = NULL;
2729 ListCell *lc;
2730
2731 /*
2732 * Is there a Var for it in rel's targetlist? If not, the query did
2733 * not reference the ordinality column, or at least not in any way
2734 * that would be interesting for sorting.
2735 */
2736 foreach(lc, rel->reltarget->exprs)
2737 {
2738 Var *node = (Var *) lfirst(lc);
2739
2740 /* checking varno/varlevelsup is just paranoia */
2741 if (IsA(node, Var) &&
2742 node->varattno == ordattno &&
2743 node->varno == rel->relid &&
2744 node->varlevelsup == 0)
2745 {
2746 var = node;
2747 break;
2748 }
2749 }
2750
2751 /*
2752 * Try to build pathkeys for this Var with int8 sorting. We tell
2753 * build_expression_pathkey not to build any new equivalence class; if
2754 * the Var isn't already mentioned in some EC, it means that nothing
2755 * cares about the ordering.
2756 */
2757 if (var)
2758 pathkeys = build_expression_pathkey(root,
2759 (Expr *) var,
2760 NULL, /* below outer joins */
2761 Int8LessOperator,
2762 rel->relids,
2763 false);
2764 }

Callers 1

set_rel_pathlistFunction · 0.85

Calls 4

build_expression_pathkeyFunction · 0.85
add_pathFunction · 0.85
create_functionscan_pathFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected