diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index f3e7018ed2..aa338e880c 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -3868,12 +3868,24 @@ generate_partitionwise_join_paths(PlannerInfo *root, RelOptInfo *rel) if (child_rel == NULL) continue; - /* Add partitionwise join paths for partitioned child-joins. */ + /* Make partitionwise join paths for this partitioned child-join. */ generate_partitionwise_join_paths(root, child_rel); + /* If we failed to make any path for this child, we must give up. */ + if (child_rel->pathlist == NIL) + { + /* + * Mark the parent joinrel as unpartitioned so that later + * functions treat it correctly. + */ + rel->nparts = 0; + return; + } + + /* Else, identify the cheapest path for it. */ set_cheapest(child_rel); - /* Dummy children will not be scanned, so ignore those. */ + /* Dummy children need not be scanned, so ignore those. */ if (IS_DUMMY_REL(child_rel)) continue;