summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-09-24 11:16:36 +0400
committerAlexander Barkov <bar@mariadb.com>2019-09-24 11:18:39 +0400
commit5f118b26c83960c8fa98bfd544f57ffd76b55304 (patch)
tree762e9475ea3b0e402ebd0571a55958b377a3fab4 /mysql-test/t
parent896974fc3d721aabe1afbf637a566cab856a731d (diff)
parent67b0faa29e59387b74ae8547c96cf0f31fc3d9d1 (diff)
downloadmariadb-git-5f118b26c83960c8fa98bfd544f57ffd76b55304.tar.gz
Merge remote-tracking branch 'origin/5.5' into 10.1
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/func_math.test38
-rw-r--r--mysql-test/t/type_newdecimal.test43
2 files changed, 81 insertions, 0 deletions
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index 4c2d7921593..bb9e46c4378 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -587,6 +587,44 @@ INSERT INTO t1 VALUES (1),(2);
SELECT STDDEV_SAMP(ROUND('0', 309)) FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-20495 Assertion `precision > 0' failed in decimal_bin_size upon CREATE .. SELECT with zerofilled decimal
+--echo #
+
+--echo # Testing that dyadic arithmetic operations are symmetric
+--echo # for (+1) and (-1) and produce the same length in CONCAT(),
+--echo # because (+1) and (-1) have the same data type: signed int.
+
+CREATE TABLE t1 AS SELECT
+ CONCAT(+1%2.0),
+ CONCAT(-1%2.0),
+ CONCAT(+1/2.0),
+ CONCAT(-1/2.0),
+ CONCAT(+1*2.0),
+ CONCAT(-1*2.0),
+ CONCAT(+1+2.0),
+ CONCAT(-1+2.0),
+ CONCAT(+1-2.0),
+ CONCAT(-1-2.0);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT
+ CONCAT(+1%2),
+ CONCAT(-1%2),
+ CONCAT(+1/2),
+ CONCAT(-1/2),
+ CONCAT(+1*2),
+ CONCAT(-1*2),
+ CONCAT(+1+2),
+ CONCAT(-1+2),
+ CONCAT(+1-2),
+ CONCAT(-1-2);
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 03e55831972..9b1beeb3f51 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1625,6 +1625,49 @@ SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
+--echo # MDEV-20495 Assertion `precision > 0' failed in decimal_bin_size upon CREATE .. SELECT with zerofilled decimal
+--echo #
+
+CREATE TABLE t1 (d DECIMAL(1,0) ZEROFILL);
+CREATE TABLE t2 AS SELECT 0 MOD d AS f FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED);
+CREATE TABLE t2 AS SELECT 0 MOD d AS f FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE IF EXISTS t1,t2;
+
+CREATE TABLE t1 (d DECIMAL(1,0) ZEROFILL);
+CREATE TABLE t2 AS SELECT CAST(0 AS UNSIGNED) MOD d AS f FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED);
+CREATE TABLE t2 AS SELECT CAST(0 AS UNSIGNED) MOD d AS f FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-20560 Assertion `precision > 0' failed in decimal_bin_size upon SELECT with MOD short unsigned decimal
+--echo #
+
+CREATE TABLE t1 (a DECIMAL(1,0) UNSIGNED);
+INSERT INTO t1 VALUES (1.0),(2.0);
+SELECT DISTINCT 1 MOD a FROM t1;
+CREATE TABLE t2 AS SELECT DISTINCT 1 MOD a AS f FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (a DECIMAL(1,0) UNSIGNED);
+INSERT INTO t1 VALUES (1.0),(2.0);
+SELECT DISTINCT 1 MOD a FROM t1;
+CREATE TABLE t2 AS SELECT DISTINCT CAST(1 AS UNSIGNED) MOD a AS f FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t1, t2;
+
+
+--echo #
--echo # End of 5.5 tests
--echo #