diff options
author | Igor Babaev <igor@askmonty.org> | 2011-12-27 13:19:13 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2011-12-27 13:19:13 -0800 |
commit | c9259f166bfcc757338c957f806e3d18637da17a (patch) | |
tree | 7c3044dd7ef5ec0e4fe5e6d7716e63193e4bd47f /sql/opt_sum.cc | |
parent | a22ab047e58d4acc62035012252d805e744d4fba (diff) | |
download | mariadb-git-c9259f166bfcc757338c957f806e3d18637da17a.tar.gz |
Fixed LP bug #904345.
The MIN/MAX optimizer code from the function opt_sum_query erroneously
did not take into account conjunctive conditions that did not depend on
any table, yet were not identified as constant items. These could be
items containing rand() or PS/SP parameters. These items are supposed
to be evaluated at the execution phase. That's why if such conditions
can be extracted from the WHERE condition the MIN/MAX optimization is
not applied as currently it is always done at the optimization phase.
(In 5.3 expensive subqueries are also evaluated only at the execution
phase. So, if a constant condition with such subquery can be extracted
from the WHERE clause the MIN/MAX optimization should not be applied
in 5.3.)
IF an IN/ALL/SOME predicate with a constant left part is transformed
into an EXISTS subquery the resulting subquery should not be considered
uncacheable if the right part of the predicate is not uncacheable.
Backported the function dbug_print_item() from 5.3. The function is used
only for debugging.
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r-- | sql/opt_sum.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index f8a81eac380..27a848cb0ec 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -608,7 +608,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, if (!cond) DBUG_RETURN(TRUE); Field *field= field_part->field; - if (!(cond->used_tables() & field->table->map)) + if (!(cond->used_tables() & field->table->map) && + test(cond->used_tables() & ~PSEUDO_TABLE_BITS)) { /* Condition doesn't restrict the used table */ DBUG_RETURN(TRUE); |