diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-05-20 00:59:40 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-05-20 00:59:40 +0200 |
commit | 725e47bfb524f4b1d29076c8777056bedd5f00ea (patch) | |
tree | 2f59c5b075cf421db908b8f9a70760042c27a9b7 /sql/opt_subselect.cc | |
parent | eb30230359309de8972d771cbf282097b1175a09 (diff) | |
parent | 7d57ba6e28f8dd5f6ab48b0b99d110c2363b576d (diff) | |
download | mariadb-git-725e47bfb524f4b1d29076c8777056bedd5f00ea.tar.gz |
Merge branch '5.5' into 10.0mariadb-10.0.31
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 46199c06a59..03204a627ed 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 (MY_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) @@ -1142,6 +1161,16 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) in_subq->block_conversion_to_sj(); } } + + if (join->select_options & SELECT_STRAIGHT_JOIN) + { + /* Block conversion to semijoins for all candidates */ + li.rewind(); + while ((in_subq= li++)) + { + in_subq->block_conversion_to_sj(); + } + } li.rewind(); /* First, convert child join's subqueries. We proceed bottom-up here */ |