Skip to content

Commit 8d396a0

Browse files
committed
Remove duplicate code in planner.c.
I noticed while hacking on join UNION transforms that planner.c's function get_base_rel_indexes() just duplicates the functionality of get_relids_in_jointree(). It doesn't even have the excuse of being older code :-(. Drop it and use the latter function instead.
1 parent 0dfa89b commit 8d396a0

File tree

1 file changed

+1
-47
lines changed

1 file changed

+1
-47
lines changed

src/backend/optimizer/plan/planner.c

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,52 +2098,6 @@ is_dummy_plan(Plan *plan)
20982098
return false;
20992099
}
21002100

2101-
/*
2102-
* Create a bitmapset of the RT indexes of live base relations
2103-
*
2104-
* Helper for preprocess_rowmarks ... at this point in the proceedings,
2105-
* the only good way to distinguish baserels from appendrel children
2106-
* is to see what is in the join tree.
2107-
*/
2108-
static Bitmapset *
2109-
get_base_rel_indexes(Node *jtnode)
2110-
{
2111-
Bitmapset *result;
2112-
2113-
if (jtnode == NULL)
2114-
return NULL;
2115-
if (IsA(jtnode, RangeTblRef))
2116-
{
2117-
int varno = ((RangeTblRef *) jtnode)->rtindex;
2118-
2119-
result = bms_make_singleton(varno);
2120-
}
2121-
else if (IsA(jtnode, FromExpr))
2122-
{
2123-
FromExpr *f = (FromExpr *) jtnode;
2124-
ListCell *l;
2125-
2126-
result = NULL;
2127-
foreach(l, f->fromlist)
2128-
result = bms_join(result,
2129-
get_base_rel_indexes(lfirst(l)));
2130-
}
2131-
else if (IsA(jtnode, JoinExpr))
2132-
{
2133-
JoinExpr *j = (JoinExpr *) jtnode;
2134-
2135-
result = bms_join(get_base_rel_indexes(j->larg),
2136-
get_base_rel_indexes(j->rarg));
2137-
}
2138-
else
2139-
{
2140-
elog(ERROR, "unrecognized node type: %d",
2141-
(int) nodeTag(jtnode));
2142-
result = NULL; /* keep compiler quiet */
2143-
}
2144-
return result;
2145-
}
2146-
21472101
/*
21482102
* preprocess_rowmarks - set up PlanRowMarks if needed
21492103
*/
@@ -2183,7 +2137,7 @@ preprocess_rowmarks(PlannerInfo *root)
21832137
* make a bitmapset of all base rels and then remove the items we don't
21842138
* need or have FOR [KEY] UPDATE/SHARE marks for.
21852139
*/
2186-
rels = get_base_rel_indexes((Node *) parse->jointree);
2140+
rels = get_relids_in_jointree((Node *) parse->jointree, false);
21872141
if (parse->resultRelation)
21882142
rels = bms_del_member(rels, parse->resultRelation);
21892143

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy