summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2013-11-21 11:21:53 +0400
committerSergey Petrunya <psergey@askmonty.org>2013-11-21 11:21:53 +0400
commit89ea0fc0346504602d5ed0c7b83c2a4db36dc959 (patch)
treeca06df8e1175dc21fc43bc9b58a4c6fc58801424 /sql/opt_subselect.cc
parentc7355b19828c37d8efb9f1d4b5010544aa110bd4 (diff)
parentc4defdc8d971cdcc186de549bae9ac4351c7aade (diff)
downloadmariadb-git-89ea0fc0346504602d5ed0c7b83c2a4db36dc959.tar.gz
Merge
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc19
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 &