* 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
| 1644 | * care about fields that are of interest to add_path() and set_cheapest(). |
| 1645 | */ |
| 1646 | RelOptInfo * |
| 1647 | fetch_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 | /* |
no test coverage detected