diff options
author | Georgi Kodinov <kgeorge@mysql.com> | 2008-10-17 13:55:16 +0300 |
---|---|---|
committer | Georgi Kodinov <kgeorge@mysql.com> | 2008-10-17 13:55:16 +0300 |
commit | e7a6e86f78998e35e1912f377006a35db3705246 (patch) | |
tree | 6e18641ac6cca2fb89f3402f3b7e299c9ecbe1a9 /mysql-test/r | |
parent | 3ad228d7fba6fa2e5b98569f798583b8f8b90db9 (diff) | |
download | mariadb-git-e7a6e86f78998e35e1912f377006a35db3705246.tar.gz |
Bug #38637: COUNT DISTINCT prevents NULL testing in HAVING clause
IS NULL was not checking the correct row in a HAVING context.
At the first row of a new group (where the HAVING clause is evaluated)
the column and SELECT list references in the HAVING clause should
refer to the last row of the previous group and not to the current one.
This was not done for IS NULL, because it was using Item::is_null() doesn't
have a Item_is_null_result() counterpart to access the data from the
last row of the previous group. Note that all the Item::val_xxx() functions
(e.g. Item::val_int()) have their _result counterparts (e.g. Item::val_int_result()).
Fixed by implementing a is_null_result() (similarly to int_result()) and
calling this instead of is_null() column and SELECT list references inside
the HAVING clause.
mysql-test/r/having.result:
Bug #38637: test case
mysql-test/t/having.test:
Bug #38637: test case
sql/item.cc:
Bug #38637: implement Item::is_null_result() and call it
from Item_ref and Item_field as appropriate.
sql/item.h:
Bug #38637: implement Item::is_null_result() and call it
from Item_ref and Item_field as appropriate.
sql/item_func.cc:
Bug #38637: implement Item::is_null_result() and call it
from Item_ref and Item_field as appropriate.
sql/item_func.h:
Bug #38637: implement Item::is_null_result() and call it
from Item_ref and Item_field as appropriate.
Diffstat (limited to 'mysql-test/r')
-rw-r--r-- | mysql-test/r/having.result | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index f113304c767..bc8596100f8 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -424,3 +424,10 @@ select f1 from t1 group by f1 having max(f1)=f1; f1 set session sql_mode=''; drop table t1; +CREATE TABLE t1 ( a INT, b INT); +INSERT INTO t1 VALUES (1, 1), (2,2), (3, NULL); +SELECT b, COUNT(DISTINCT a) FROM t1 GROUP BY b HAVING b is NULL; +b COUNT(DISTINCT a) +NULL 1 +DROP TABLE t1; +End of 5.0 tests |