Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/optimizer/path/joinpath.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c
index c2f211a60d1..f047ad9ba46 100644
--- a/src/backend/optimizer/path/joinpath.c
+++ b/src/backend/optimizer/path/joinpath.c
@@ -699,6 +699,17 @@ try_nestloop_path(PlannerInfo *root,
Relids outer_paramrels = PATH_REQ_OUTER(outer_path);
/*
+ * If we are forming an outer join at this join, it's nonsensical to use
+ * an input path that uses the outer join as part of its parameterization.
+ * (This can happen despite our join order restrictions, since those apply
+ * to what is in an input relation not what its parameters are.)
+ */
+ if (extra->sjinfo->ojrelid != 0 &&
+ (bms_is_member(extra->sjinfo->ojrelid, inner_paramrels) ||
+ bms_is_member(extra->sjinfo->ojrelid, outer_paramrels)))
+ return;
+
+ /*
* Paths are parameterized by top-level parents, so run parameterization
* tests on the parent relids.
*/
@@ -909,6 +920,17 @@ try_mergejoin_path(PlannerInfo *root,
}
/*
+ * If we are forming an outer join at this join, it's nonsensical to use
+ * an input path that uses the outer join as part of its parameterization.
+ * (This can happen despite our join order restrictions, since those apply
+ * to what is in an input relation not what its parameters are.)
+ */
+ if (extra->sjinfo->ojrelid != 0 &&
+ (bms_is_member(extra->sjinfo->ojrelid, PATH_REQ_OUTER(inner_path)) ||
+ bms_is_member(extra->sjinfo->ojrelid, PATH_REQ_OUTER(outer_path))))
+ return;
+
+ /*
* Check to see if proposed path is still parameterized, and reject if the
* parameterization wouldn't be sensible.
*/
@@ -1055,6 +1077,17 @@ try_hashjoin_path(PlannerInfo *root,
JoinCostWorkspace workspace;
/*
+ * If we are forming an outer join at this join, it's nonsensical to use
+ * an input path that uses the outer join as part of its parameterization.
+ * (This can happen despite our join order restrictions, since those apply
+ * to what is in an input relation not what its parameters are.)
+ */
+ if (extra->sjinfo->ojrelid != 0 &&
+ (bms_is_member(extra->sjinfo->ojrelid, PATH_REQ_OUTER(inner_path)) ||
+ bms_is_member(extra->sjinfo->ojrelid, PATH_REQ_OUTER(outer_path))))
+ return;
+
+ /*
* Check to see if proposed path is still parameterized, and reject if the
* parameterization wouldn't be sensible.
*/