summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/allpaths.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2018-02-05 17:31:57 -0500
committerRobert Haas <rhaas@postgresql.org>2018-02-05 17:31:57 -0500
commitf069c91a5793ff6b7884120de748b2005ee7756f (patch)
tree2b5125e6ba39362e8eafa0f34e6b3f023432f801 /src/backend/optimizer/path/allpaths.c
parent1eb5d43beed9d8cdc61377867f0a53eb2cfba0c4 (diff)
Fix possible crash in partition-wise join.
The previous code assumed that we'd always succeed in creating child-joins for a joinrel for which partition-wise join was considered, but that's not guaranteed, at least in the case where dummy rels are involved. Ashutosh Bapat, with some wordsmithing by me. Discussion: http://postgr.es/m/CAFjFpRf8=uyMYYfeTBjWDMs1tR5t--FgOe2vKZPULxxdYQ4RNw@mail.gmail.com
Diffstat (limited to 'src/backend/optimizer/path/allpaths.c')
-rw-r--r--src/backend/optimizer/path/allpaths.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 5bff90e1bca..6e842f93d0f 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -3425,20 +3425,8 @@ generate_partition_wise_join_paths(PlannerInfo *root, RelOptInfo *rel)
if (!IS_JOIN_REL(rel))
return;
- /*
- * If we've already proven this join is empty, we needn't consider any
- * more paths for it.
- */
- if (IS_DUMMY_REL(rel))
- return;
-
- /*
- * We've nothing to do if the relation is not partitioned. An outer join
- * relation which had an empty inner relation in every pair will have the
- * rest of the partitioning properties set except the child-join
- * RelOptInfos. See try_partition_wise_join() for more details.
- */
- if (rel->nparts <= 0 || rel->part_rels == NULL)
+ /* We've nothing to do if the relation is not partitioned. */
+ if (!IS_PARTITIONED_REL(rel))
return;
/* Guard against stack overflow due to overly deep partition hierarchy. */
@@ -3452,6 +3440,8 @@ generate_partition_wise_join_paths(PlannerInfo *root, RelOptInfo *rel)
{
RelOptInfo *child_rel = part_rels[cnt_parts];
+ Assert(child_rel != NULL);
+
/* Add partition-wise join paths for partitioned child-joins. */
generate_partition_wise_join_paths(root, child_rel);