summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorGagan Goel <gagan.nith@gmail.com>2019-12-30 15:11:01 -0500
committerRobert Bindar <robert@mariadb.org>2020-01-16 09:46:58 +0200
commitf0ca9bc669c742bab5a122e4caddb4b12a8c6c45 (patch)
tree2e5be8b0d229f26de4c7f03eb3e378b8eccab523 /mysql-test
parent1c97cd339e9513b152727f386573c8c048db0281 (diff)
downloadmariadb-git-f0ca9bc669c742bab5a122e4caddb4b12a8c6c45.tar.gz
MDEV-20732 Correctly set the length of the FORMAT() result for float data type as argument.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/main/func_math.result16
-rw-r--r--mysql-test/main/func_math.test7
-rw-r--r--mysql-test/main/func_str.result2
3 files changed, 24 insertions, 1 deletions
diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result
index d50abe00e72..5770859c377 100644
--- a/mysql-test/main/func_math.result
+++ b/mysql-test/main/func_math.result
@@ -2723,6 +2723,22 @@ t2 CREATE TABLE `t2` (
`c1` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1,t2;
+CREATE OR REPLACE TABLE t1 (f float);
+INSERT INTO t1 VALUES (3e38), (-3e38), (0), (12.34), (-12.34);
+CREATE OR REPLACE TABLE t2 AS SELECT FORMAT(f,0) FROM t1;
+SELECT * FROM t2;
+FORMAT(f,0)
+300,000,000,549,775,580,000,000,000,000,000,000,000
+-300,000,000,549,775,580,000,000,000,000,000,000,000
+0
+12
+-12
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `FORMAT(f,0)` varchar(53) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1,t2;
#
# End of 10.4 tests
#
diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test
index 5f333c06b78..15c27076ba3 100644
--- a/mysql-test/main/func_math.test
+++ b/mysql-test/main/func_math.test
@@ -1733,6 +1733,13 @@ SELECT HEX(c1) FROM t2;
SHOW CREATE TABLE t2;
DROP TABLE t1,t2;
+CREATE OR REPLACE TABLE t1 (f float);
+INSERT INTO t1 VALUES (3e38), (-3e38), (0), (12.34), (-12.34);
+CREATE OR REPLACE TABLE t2 AS SELECT FORMAT(f,0) FROM t1;
+SELECT * FROM t2;
+SHOW CREATE TABLE t2;
+DROP TABLE t1,t2;
+
--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result
index 5de77f18a24..b4e3f27eda6 100644
--- a/mysql-test/main/func_str.result
+++ b/mysql-test/main/func_str.result
@@ -2708,7 +2708,7 @@ create table t1(a float);
insert into t1 values (1.33);
select format(a, 2) from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def format(a, 2) 253 4 4 Y 0 39 8
+def format(a, 2) 253 56 4 Y 0 39 8
format(a, 2)
1.33
drop table t1;