summaryrefslogtreecommitdiff
path: root/mysql-test/main/type_int.test
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-08-03 08:01:42 +0400
committerAlexander Barkov <bar@mariadb.com>2020-08-03 08:01:42 +0400
commit00f964ab4da08cc5fa71d3d9b9f262448a5f818a (patch)
treed38da363b56efad5960b432ec53878c86d216ee6 /mysql-test/main/type_int.test
parent3b87a68169bbe1ae8d23ead2f657a292fe29d14a (diff)
downloadmariadb-git-00f964ab4da08cc5fa71d3d9b9f262448a5f818a.tar.gz
MDEV-23367 ROUND(18446744073709551615,-1) returns a wrong result
This problem was fixed by MDEV-23368. Adding tests only.
Diffstat (limited to 'mysql-test/main/type_int.test')
-rw-r--r--mysql-test/main/type_int.test63
1 files changed, 63 insertions, 0 deletions
diff --git a/mysql-test/main/type_int.test b/mysql-test/main/type_int.test
index 6191a72fc25..e94fc4d3298 100644
--- a/mysql-test/main/type_int.test
+++ b/mysql-test/main/type_int.test
@@ -349,6 +349,69 @@ SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-23367 ROUND(18446744073709551615,-1) returns a wrong result
+--echo #
+
+--vertical_results
+SELECT
+ ROUND(18446744073709551615,-1) AS c01,
+ ROUND(18446744073709551615,-19) AS c19;
+
+CREATE OR REPLACE TABLE t1 AS
+SELECT
+ ROUND(18446744073709551615,-1) AS c01,
+ ROUND(18446744073709551615,-19) AS c19;
+
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+--horizontal_results
+
+DELIMITER $$;
+CREATE PROCEDURE p1(t VARCHAR(64))
+BEGIN
+ SELECT t AS ``;
+ EXECUTE IMMEDIATE REPLACE('CREATE TABLE t1 (a TYPE)', 'TYPE', t);
+ INSERT IGNORE INTO t1 VALUES (-100000000000000000000000000000);
+ INSERT IGNORE INTO t1 VALUES (100000000000000000000000000000);
+ CREATE TABLE t2 AS SELECT
+ a, ROUND(a,-1), ROUND(a,-2), ROUND(a,-19), ROUND(a,-20), ROUND(a,-30)
+ FROM t1
+ ORDER BY a;
+ SHOW CREATE TABLE t2;
+ SELECT * FROM t2;
+ DROP TABLE t1, t2;
+END;
+$$
+DELIMITER ;$$
+
+--vertical_results
+CALL p1('tinyint');
+CALL p1('smallint');
+CALL p1('mediumint');
+CALL p1('int');
+CALL p1('bigint');
+CALL p1('bigint(20)');
+CALL p1('bigint(21)');
+#CALL p1('bigint(22)');
+#CALL p1('bigint(23)');
+#CALL p1('bigint(30)');
+
+CALL p1('tinyint unsigned');
+CALL p1('smallint unsigned');
+CALL p1('mediumint unsigned');
+CALL p1('int unsigned');
+CALL p1('bigint unsigned');
+CALL p1('bigint(20) unsigned');
+CALL p1('bigint(21) unsigned');
+#CALL p1('bigint(22) unsigned');
+#CALL p1('bigint(23) unsigned');
+#CALL p1('bigint(30) unsigned');
+--horizontal_results
+
+DROP PROCEDURE p1;
+
--echo #
--echo # End of 10.4 tests