summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorunknown <sanja@montyprogram.com>2012-05-11 11:40:23 +0300
committerunknown <sanja@montyprogram.com>2012-05-11 11:40:23 +0300
commite10fecc02f57980ddc27bafb9d1f620e8533f4a3 (patch)
tree393865dac63fb0c44cd7c6d166c97a4617b1a313 /sql/opt_sum.cc
parentfe0a0bdb143696c54206cd5f908dac94996aab42 (diff)
parentf2cbc014d98a927ed7038f55a25c3d288de10f51 (diff)
downloadmariadb-git-e10fecc02f57980ddc27bafb9d1f620e8533f4a3.tar.gz
Merge 5.2->5.3
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 9e097af1e6e..b6aca56f047 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -416,7 +416,7 @@ int opt_sum_query(THD *thd,
}
removed_tables|= table->map;
}
- else if (!expr->const_item() || !is_exact_count)
+ else if (!expr->const_item() || !is_exact_count || conds)
{
/*
The optimization is not applicable in both cases:
@@ -426,6 +426,8 @@ int opt_sum_query(THD *thd,
NULL if the query does not return any rows. Thus, if we are not
able to determine if the query returns any rows, we can't apply
the optimization and replace MIN/MAX with a constant.
+ (c) there is a WHERE clause. The WHERE conditions may result in
+ an empty result, but the clause cannot be taken into account here.
*/
const_result= 0;
break;