diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/optimizer/path/joinrels.c | 14 | ||||
-rw-r--r-- | src/backend/optimizer/util/relnode.c | 18 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index 2feab2184f4..a3f94be1d64 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -1640,13 +1640,15 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, child_rel1->relids, child_rel2->relids); - /* Build correct join relids for child join */ - child_joinrelids = bms_union(child_rel1->relids, child_rel2->relids); - child_joinrelids = add_outer_joins_to_relids(root, child_joinrelids, - child_sjinfo, NULL); - /* Find the AppendRelInfo structures */ - appinfos = find_appinfos_by_relids(root, child_joinrelids, &nappinfos); + appinfos = find_appinfos_by_relids(root, + bms_union(child_rel1->relids, + child_rel2->relids), + &nappinfos); + + /* Build correct join relids for child join */ + child_joinrelids = adjust_child_relids(joinrel->relids, + nappinfos, appinfos); /* * Construct restrictions applicable to the child join from those diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index 15e3910b79a..76dad17e336 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -871,10 +871,19 @@ build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel, /* The parent joinrel should have consider_partitionwise_join set. */ Assert(parent_joinrel->consider_partitionwise_join); + /* + * Find the AppendRelInfo structures for the child baserels. We'll need + * these for computing the child join's relid set, and later for mapping + * Vars to the child rel. + */ + appinfos = find_appinfos_by_relids(root, + bms_union(outer_rel->relids, + inner_rel->relids), + &nappinfos); + joinrel->reloptkind = RELOPT_OTHER_JOINREL; - joinrel->relids = bms_union(outer_rel->relids, inner_rel->relids); - joinrel->relids = add_outer_joins_to_relids(root, joinrel->relids, sjinfo, - NULL); + joinrel->relids = adjust_child_relids(parent_joinrel->relids, + nappinfos, appinfos); joinrel->rows = 0; /* cheap startup cost is interesting iff not all tuples to be retrieved */ joinrel->consider_startup = (root->tuple_fraction > 0); @@ -935,9 +944,6 @@ build_child_join_rel(PlannerInfo *root, RelOptInfo *outer_rel, /* Compute information relevant to foreign relations. */ set_foreign_rel_properties(joinrel, outer_rel, inner_rel); - /* Compute information needed for mapping Vars to the child rel */ - appinfos = find_appinfos_by_relids(root, joinrel->relids, &nappinfos); - /* Set up reltarget struct */ build_child_join_reltarget(root, parent_joinrel, joinrel, nappinfos, appinfos); |