diff options
author | Igor Babaev <igor@askmonty.org> | 2017-05-17 14:29:13 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2017-05-17 14:29:13 -0700 |
commit | 7e9716310261bce124585cbffd85f3402390ec9d (patch) | |
tree | 34a2d56c8c7b67e070590dad1a272c2ffa71890d /sql/opt_subselect.cc | |
parent | 934b8312817d4e8e0387fae0bd9cca3ffafbc7de (diff) | |
download | mariadb-git-7e9716310261bce124585cbffd85f3402390ec9d.tar.gz |
Fixed the bug mdev-12817/mdev-12820.
This patch is a correction of the patch for bug mdev-12670.
With the current code handling semi-joins the following must
be taken into account.
Conversion of an IN subquery predicate into semi-join
has to be blocked if the predicate occurs:
(a) in the ON expression of an outer join
(b) in the ON expression of an inner join embedded directly
or indirectly in the inner nest of an outer join.
The patch for mdev-12670 blocked conversion to semi-joins only
in the case (a), but not in the case (b). This patch blocks
the conversion in both cases.
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 645afa6744a..84e06fda852 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -1103,7 +1103,26 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) do { embedded= embedding; - if (test(embedded->outer_join)) + bool block_conversion_to_sj= false; + if (embedded->on_expr) + { + /* + Conversion of an IN subquery predicate into semi-join + is blocked now if the predicate occurs: + - in the ON expression of an outer join + - in the ON expression of an inner join embedded directly + or indirectly in the inner nest of an outer join + */ + for (TABLE_LIST *tl= embedded; tl; tl= tl->embedding) + { + if (tl->outer_join) + { + block_conversion_to_sj= true; + break; + } + } + } + if (block_conversion_to_sj) { Item *cond= embedded->on_expr; if (!cond) |