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

Function fetch_upper_rel

src/backend/optimizer/util/relnode.c:1646–1686  ·  view source on GitHub ↗

* fetch_upper_rel * Build a RelOptInfo describing some post-scan/join query processing, * or return a pre-existing one if somebody already built it. * * An "upper" relation is identified by an UpperRelationKind and a Relids set. * The meaning of the Relids set is not specified here, and very likely will * vary for different relation kinds. * * Most of the fields in an upper-level RelOptI

Source from the content-addressed store, hash-verified

1644 * care about fields that are of interest to add_path() and set_cheapest().
1645 */
1646RelOptInfo *
1647fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
1648{
1649 RelOptInfo *upperrel;
1650 ListCell *lc;
1651
1652 /*
1653 * For the moment, our indexing data structure is just a List for each
1654 * relation kind. If we ever get so many of one kind that this stops
1655 * working well, we can improve it. No code outside this function should
1656 * assume anything about how to find a particular upperrel.
1657 */
1658
1659 /* If we already made this upperrel for the query, return it */
1660 foreach(lc, root->upper_rels[kind])
1661 {
1662 upperrel = (RelOptInfo *) lfirst(lc);
1663
1664 if (bms_equal(upperrel->relids, relids))
1665 return upperrel;
1666 }
1667
1668 upperrel = makeNode(RelOptInfo);
1669 upperrel->reloptkind = RELOPT_UPPER_REL;
1670 upperrel->relids = bms_copy(relids);
1671
1672 /* cheap startup cost is interesting iff not all tuples to be retrieved */
1673 upperrel->consider_startup = (root->tuple_fraction > 0);
1674 upperrel->consider_param_startup = false;
1675 upperrel->consider_parallel = false; /* might get changed later */
1676 upperrel->reltarget = create_empty_pathtarget();
1677 upperrel->pathlist = NIL;
1678 upperrel->cheapest_startup_path = NULL;
1679 upperrel->cheapest_total_path = NULL;
1680 upperrel->cheapest_unique_path = NULL;
1681 upperrel->cheapest_parameterized_paths = NIL;
1682
1683 root->upper_rels[kind] = lappend(root->upper_rels[kind], upperrel);
1684
1685 return upperrel;
1686}
1687
1688
1689/*

Callers 15

make_subplanFunction · 0.85
SS_process_ctesFunction · 0.85
add_rtes_to_flat_rtableFunction · 0.85
create_ctescan_planFunction · 0.85
standard_plannerFunction · 0.85
subquery_plannerFunction · 0.85
grouping_plannerFunction · 0.85
make_grouping_relFunction · 0.85
create_window_pathsFunction · 0.85

Calls 5

bms_equalFunction · 0.85
bms_copyFunction · 0.85
create_empty_pathtargetFunction · 0.85
lappendFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected