diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-12-16 13:02:21 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-12-16 13:02:21 +0100 |
commit | d28d3ba40dc8ebef87199a2567ec96e9c5d744e2 (patch) | |
tree | c6b9ab1d8193fa2a26c5e376d43e536abd3a47ce /sql/opt_subselect.cc | |
parent | ff485d2dc4d5adaf5eef0ccd03ce62adf3bd30b3 (diff) | |
parent | 6bf10fac445d73fb796d4863612c87bff5f28b66 (diff) | |
download | mariadb-git-d28d3ba40dc8ebef87199a2567ec96e9c5d744e2.tar.gz |
10.0-base merge
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index c156c1642e7..a9bff4b37bf 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -1311,7 +1311,6 @@ static bool replace_where_subcondition(JOIN *join, Item **expr, } else if (item->type() == Item::COND_ITEM) { - DBUG_ASSERT(!do_fix_fields || !(*expr)->fixed); replace_where_subcondition(join, li.ref(), old_cond, new_cond, do_fix_fields); @@ -1929,11 +1928,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++)) @@ -1984,7 +1997,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 & |