summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorunknown <sanja@montyprogram.com>2012-05-07 13:26:34 +0300
committerunknown <sanja@montyprogram.com>2012-05-07 13:26:34 +0300
commit8065143637dd622b094e548ae373a28bbe78e028 (patch)
treeefb9a9e1b50aee07acb2f2909bfb266fc26ba7a4 /sql/opt_sum.cc
parent213476ef3e2649c928c65705c08176282afbb55b (diff)
downloadmariadb-git-8065143637dd622b094e548ae373a28bbe78e028.tar.gz
Fix for LP bug#993726
Optimization of aggregate functions detected constant under max() and evalueted it, but condition in the WHWRE clause (which is always FALSE) was not taken into account
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 92a286a3b1c..35986cf7fc0 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -403,7 +403,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:
@@ -413,6 +413,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;