diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2013-11-21 11:21:53 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2013-11-21 11:21:53 +0400 |
commit | 89ea0fc0346504602d5ed0c7b83c2a4db36dc959 (patch) | |
tree | ca06df8e1175dc21fc43bc9b58a4c6fc58801424 /sql/opt_subselect.cc | |
parent | c7355b19828c37d8efb9f1d4b5010544aa110bd4 (diff) | |
parent | c4defdc8d971cdcc186de549bae9ac4351c7aade (diff) | |
download | mariadb-git-89ea0fc0346504602d5ed0c7b83c2a4db36dc959.tar.gz |
Merge
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 47771a10ae7..ec56994f16a 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -1921,11 +1921,25 @@ int pull_out_semijoin_tables(JOIN *join) } } - table_map pulled_tables= 0; + table_map dep_tables= 0; if (have_join_nest_children) goto skip; + /* + Calculate set of tables within this semi-join nest that have + other dependent tables + */ + child_li.rewind(); + while ((tbl= child_li++)) + { + TABLE *const table= tbl->table; + if (table && + (table->reginfo.join_tab->dependent & + sj_nest->nested_join->used_tables)) + dep_tables|= table->reginfo.join_tab->dependent; + } + /* Action #1: Mark the constant tables to be pulled out */ child_li.rewind(); while ((tbl= child_li++)) @@ -1976,7 +1990,8 @@ int pull_out_semijoin_tables(JOIN *join) child_li.rewind(); while ((tbl= child_li++)) { - if (tbl->table && !(pulled_tables & tbl->table->map)) + if (tbl->table && !(pulled_tables & tbl->table->map) && + !(dep_tables & tbl->table->map)) { if (find_eq_ref_candidate(tbl->table, sj_nest->nested_join->used_tables & |