From 1b3430a5ae6b2f6d5c251f1ff07f5c273b1dc175 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Aug 2016 16:04:40 +0400 Subject: MDEV-10500 CASE/IF Statement returns multiple values and shifts further result values to the next column We assume all around the code that null_value==true is in sync with NULL value returned by val_str()/val_decimal(). Item_sum_sum::val_decimal() erroneously returned a non-NULL value together with null_value set to true. Fixing to return NULL instead. --- mysql-test/t/func_group.test | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'mysql-test/t/func_group.test') diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index bd3ed4ad32d..5824d99afa5 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1565,3 +1565,28 @@ EXECUTE stmt; EXECUTE stmt; DROP TABLE t1,t2,t3,t4,t5,t6; + +--echo # +--echo # MDEV-10500 CASE/IF Statement returns multiple values and shifts further result values to the next column +--echo # + +CREATE TABLE t1 ( + id int not null AUTO_INCREMENT, + active bool not null, + data1 bigint, + data2 bigint, + data3 bigint, + primary key (id) +); +INSERT INTO t1 (active,data1,data2,data3) VALUES (1,null,100,200); +SELECT + CASE WHEN active THEN SUM(data1) END AS C_1, + SUM(data2) AS C_2, + SUM(data3) AS C_3 +FROM t1; +SELECT + IF(active, SUM(data1), 5) AS C_1, + SUM(data2) AS C_2, + SUM(data3) AS C_3 +FROM t1; +DROP TABLE t1; -- cgit v1.2.1 From 5269d378dfd576ecd03c82b3e763a98c83235636 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 8 Aug 2016 18:37:02 +0400 Subject: MDEV-10468 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() --- mysql-test/t/func_group.test | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'mysql-test/t/func_group.test') diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 5824d99afa5..7013009fae7 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1590,3 +1590,9 @@ SELECT SUM(data3) AS C_3 FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-10468 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() +--echo # +SELECT STDDEV_POP(f) FROM (SELECT "1e+309" AS f UNION SELECT "-1e+309" AS f) tbl; +SELECT STDDEV(f) FROM (SELECT 1.7976931348623157e+308 AS f UNION SELECT -1.7976931348623157e+308 AS f) tbl; -- cgit v1.2.1