aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-07-22 10:32:52 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2023-07-22 10:32:52 -0400
commit11237e5a46ca2221aca5c74bf43bb58eff8dcc3b (patch)
tree63b082ab167ecfc40b6f1d84839e10b2b54141c4 /src
parentf75595cd80d134d5a63929a90a0347ff9729b79a (diff)
downloadpostgresql-11237e5a46ca2221aca5c74bf43bb58eff8dcc3b.tar.gz
postgresql-11237e5a46ca2221aca5c74bf43bb58eff8dcc3b.zip
Avoid compiler warning in non-assert builds.
After 3c90dcd03, 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
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/path/joinrels.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c
index a3f94be1d64..015a0b3cbe0 100644
--- a/src/backend/optimizer/path/joinrels.c
+++ b/src/backend/optimizer/path/joinrels.c
@@ -1543,7 +1543,6 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
SpecialJoinInfo *child_sjinfo;
List *child_restrictlist;
RelOptInfo *child_joinrel;
- Relids child_joinrelids;
AppendRelInfo **appinfos;
int nappinfos;
@@ -1646,10 +1645,6 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
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
* applicable to the parent join.
@@ -1658,8 +1653,8 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
(List *) adjust_appendrel_attrs(root,
(Node *) parent_restrictlist,
nappinfos, appinfos);
- pfree(appinfos);
+ /* Find or construct the child join's RelOptInfo */
child_joinrel = joinrel->part_rels[cnt_parts];
if (!child_joinrel)
{
@@ -1672,11 +1667,17 @@ try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
child_joinrel->relids);
}
- Assert(bms_equal(child_joinrel->relids, child_joinrelids));
+ /* Assert we got the right one */
+ Assert(bms_equal(child_joinrel->relids,
+ adjust_child_relids(joinrel->relids,
+ nappinfos, appinfos)));
+ /* And make paths for the child join */
populate_joinrel_with_paths(root, child_rel1, child_rel2,
child_joinrel, child_sjinfo,
child_restrictlist);
+
+ pfree(appinfos);
}
}