diff options
author | unknown <timour@askmonty.org> | 2012-06-05 17:25:10 +0300 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2012-06-05 17:25:10 +0300 |
commit | f1ab00891ad050711557c6cdc62b17fff896aed9 (patch) | |
tree | 31e8c967b17eece8c13679d9828ce7a822c7c616 /sql/opt_subselect.cc | |
parent | 265d5aaa2e240288fff98e7c129cf441728152f8 (diff) | |
download | mariadb-git-f1ab00891ad050711557c6cdc62b17fff896aed9.tar.gz |
Fixed bug lp:1000649
Analysis:
When the method JOIN::choose_subquery_plan() decided to apply
the IN-TO-EXISTS strategy, it set the unit and select_lex
uncacheable flag to UNCACHEABLE_DEPENDENT_INJECTED unconditionally.
As result, even if IN-TO-EXISTS injected non-correlated predicates,
the subquery was still treated as correlated.
Solution:
Set the subquery as correlated only if the injected predicate(s) depend
on the outer query.
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r-- | sql/opt_subselect.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 967981bcc9d..0273c947ef6 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -5438,11 +5438,17 @@ bool JOIN::choose_subquery_plan(table_map join_tables) if (in_subs->inject_in_to_exists_cond(this)) return TRUE; /* - It is IN->EXISTS transformation so we should mark subquery as - dependent + If the injected predicate is correlated the IN->EXISTS transformation + make the subquery dependent. */ - in_subs->unit->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED; - select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED; + if ((in_to_exists_where && + in_to_exists_where->used_tables() & OUTER_REF_TABLE_BIT) || + (in_to_exists_having && + in_to_exists_having->used_tables() & OUTER_REF_TABLE_BIT)) + { + in_subs->unit->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED; + select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED; + } select_limit= 1; } else |