From 9840bb21ef683afd59a30a79ebc5bd5ad33a7c1a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 3 Aug 2020 10:53:06 +0400 Subject: MDEV-23366 ROUND(18446744073709551615,rand()*0) returns a wrong result Changing that in case of *INT and hex hybrid input: - ROUND(x,NULL) creates a column with the same type as x. The old code created a DOUBLE column, which was not relevant at all. This change simplifies the code a lot. - ROUND(x,non_constant) creates a column of the INT, BIGINT or DECIMAL data type (depending on the exact type of x). The old code created a column of the DOUBLE data type, which lead to precision loss. Hence MDEV-23366. - ROUND(bigint_30,negative_constant) creates a column of the DECIMAL(30,0) data type. The old code created DECIMAL(29,0), which looked strange: the data type promoted to a higher one, but max length reduced. Now the length attribute is preserved. --- mysql-test/main/func_math.result | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mysql-test/main/func_math.result') diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result index 68922b09bf7..163478f330c 100644 --- a/mysql-test/main/func_math.result +++ b/mysql-test/main/func_math.result @@ -348,7 +348,6 @@ truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, 4 4 0 Warnings: Note 1105 Cast to unsigned converted negative integer to it's positive complement -Note 1105 Cast to unsigned converted negative integer to it's positive complement select round(10000000000000000000, -19), truncate(10000000000000000000, -19); round(10000000000000000000, -19) truncate(10000000000000000000, -19) 10000000000000000000 10000000000000000000 @@ -1784,7 +1783,7 @@ ROUND(10e0,NULL) AS c3; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` double DEFAULT NULL, + `c1` int(2) DEFAULT NULL, `c2` double DEFAULT NULL, `c3` double DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -- cgit v1.2.1