Skip to content

Commit bda97e4

Browse files
committed
Avoid compiler warning in non-assert builds.
After 3c90dcd, try_partitionwise_join's child_joinrelids variable is read only in an Assert, provoking a compiler warning in non-assert builds. Rearrange code to avoid the warning and eliminate unnecessary work in the non-assert case. Per CI testing (via Jeff Davis and Bharath Rupireddy) Discussion: https://postgr.es/m/ef0de9713e605451f1b60b30648c5ee900b2394c.camel@j-davis.com
1 parent 702d003 commit bda97e4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/backend/optimizer/path/joinrels.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,6 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
15431543
SpecialJoinInfo *child_sjinfo;
15441544
List *child_restrictlist;
15451545
RelOptInfo *child_joinrel;
1546-
Relids child_joinrelids;
15471546
AppendRelInfo **appinfos;
15481547
int nappinfos;
15491548

@@ -1646,10 +1645,6 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
16461645
child_rel2->relids),
16471646
&nappinfos);
16481647

1649-
/* Build correct join relids for child join */
1650-
child_joinrelids = adjust_child_relids(joinrel->relids,
1651-
nappinfos, appinfos);
1652-
16531648
/*
16541649
* Construct restrictions applicable to the child join from those
16551650
* applicable to the parent join.
@@ -1658,8 +1653,8 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
16581653
(List *) adjust_appendrel_attrs(root,
16591654
(Node *) parent_restrictlist,
16601655
nappinfos, appinfos);
1661-
pfree(appinfos);
16621656

1657+
/* Find or construct the child join's RelOptInfo */
16631658
child_joinrel = joinrel->part_rels[cnt_parts];
16641659
if (!child_joinrel)
16651660
{
@@ -1672,11 +1667,17 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
16721667
child_joinrel->relids);
16731668
}
16741669

1675-
Assert(bms_equal(child_joinrel->relids, child_joinrelids));
1670+
/* Assert we got the right one */
1671+
Assert(bms_equal(child_joinrel->relids,
1672+
adjust_child_relids(joinrel->relids,
1673+
nappinfos, appinfos)));
16761674

1675+
/* And make paths for the child join */
16771676
populate_joinrel_with_paths(root, child_rel1, child_rel2,
16781677
child_joinrel, child_sjinfo,
16791678
child_restrictlist);
1679+
1680+
pfree(appinfos);
16801681
}
16811682
}
16821683

0 commit comments

Comments
 (0)