summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorunknown <timour@mysql.com>2005-09-21 09:49:19 +0300
committerunknown <timour@mysql.com>2005-09-21 09:49:19 +0300
commit8e7217e43bed6db3bffd97a39b85c65e1a72579a (patch)
treedb20d5fda8d7bf84477295d248851e18371614eb /sql/item_sum.cc
parente6f860aad0fd3f831dc6db9ecb94fbf71f3b9ed9 (diff)
downloadmariadb-git-8e7217e43bed6db3bffd97a39b85c65e1a72579a.tar.gz
Fix for BUG#12882 - min/max inconsistent on empty table.
The problem was in that the MIN/MAX optimization in opt_sum_query was replacing MIN/MAX functions with their constant argument without taking into account that a query has no result rows. mysql-test/r/func_group.result: Test for BUG#12882. mysql-test/t/func_group.test: Test for BUG#12882. sql/item_sum.cc: If it is known that a query has no result rows, do not call add() via the call to Item_sum::no_rows_in_result() which calls reset(). Instead directly call clear() so that the MIN and MAX functions produce NULL when there are no result rows. sql/opt_sum.cc: * Do not apply MIN/MAX optimization when the operand of MIN/MAX is a constant if it can't be determined whether the query has any result rows. The reason is that if the query has result rows, then the result of MIN/MAX is its constant argument, but if the query result is empty, then the result of MIN/MAX must be NULL irrespective of its argument. * The patch also simplifies a bit the branch that hadles COUNT().
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 6ae782db557..43468adea1a 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -552,8 +552,8 @@ void Item_sum_hybrid::cleanup()
void Item_sum_hybrid::no_rows_in_result()
{
- Item_sum::no_rows_in_result();
was_values= FALSE;
+ clear();
}