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/r/func_group.result | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'mysql-test/r/func_group.result') diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index ac076ec4348..0253548236c 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -2270,3 +2270,30 @@ t2_id GROUP_CONCAT(IF (t6.b, t6.f, t5.f) ORDER BY 1) EXECUTE stmt; t2_id GROUP_CONCAT(IF (t6.b, t6.f, t5.f) ORDER BY 1) DROP TABLE t1,t2,t3,t4,t5,t6; +# +# MDEV-10500 CASE/IF Statement returns multiple values and shifts further result values to the next column +# +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; +C_1 C_2 C_3 +NULL 100 200 +SELECT +IF(active, SUM(data1), 5) AS C_1, +SUM(data2) AS C_2, +SUM(data3) AS C_3 +FROM t1; +C_1 C_2 C_3 +NULL 100 200 +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/r/func_group.result | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mysql-test/r/func_group.result') diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 0253548236c..38fae2f0a4f 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -2297,3 +2297,15 @@ FROM t1; C_1 C_2 C_3 NULL 100 200 DROP TABLE t1; +# +# MDEV-10468 Assertion `nr >= 0.0' failed in Item_sum_std::val_real() +# +SELECT STDDEV_POP(f) FROM (SELECT "1e+309" AS f UNION SELECT "-1e+309" AS f) tbl; +STDDEV_POP(f) +1.7976931348623157e308 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '1e+309' +Warning 1292 Truncated incorrect DOUBLE value: '-1e+309' +SELECT STDDEV(f) FROM (SELECT 1.7976931348623157e+308 AS f UNION SELECT -1.7976931348623157e+308 AS f) tbl; +STDDEV(f) +1.7976931348623157e308 -- cgit v1.2.1