summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-05-21 20:54:41 +0200
committerSergei Golubchik <sergii@pisem.net>2012-05-21 20:54:41 +0200
commit1185420da0964b2f06d9fd91bd02d067b0a359de (patch)
tree0b4162e316a18fa6ce3f56ee447454b4c73d1805 /sql/opt_sum.cc
parent431e042b5d76ed5fd219c39db798c9e7478731c8 (diff)
parent7f6f53a8df10c76f93848c8d06bc5af71051c525 (diff)
downloadmariadb-git-1185420da0964b2f06d9fd91bd02d067b0a359de.tar.gz
5.3 merge
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 430c201d3e6..cbec039b3e4 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -415,7 +415,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:
@@ -425,6 +425,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;