summaryrefslogtreecommitdiff
path: root/mysql-test/main/func_math.result
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-08-05 08:56:12 +0400
committerAlexander Barkov <bar@mariadb.com>2020-08-05 08:56:12 +0400
commit0041dacc1b8e85e1958355d1cfdc36055b05a884 (patch)
tree472367c10443c5b1419c867802237160a81cd7a0 /mysql-test/main/func_math.result
parent14a5f73cdaf43ea40b990ab0dd6eb1553a5c86ce (diff)
downloadmariadb-git-0041dacc1b8e85e1958355d1cfdc36055b05a884.tar.gz
MDEV-23118 FORMAT(d1,dec) where dec=0/38 and d1 is DECIMAL(38,38) gives incorrect results
FORMAT() can print more integer digits (than the argument has) if rounding happens: FORMAT(9.9,0) -> '10' The old code did not take this into account. Fix: 1. One extra digit is needed in case of rounding - If args[1] is a not-NULL constant, then reserve space for one extra integer digit if the requested number of decimals is less than args[0]->decimals. - Otherwise, reserve space for one extra integer digit if args[0]->decimals is not 0, because rounding can potentially happen (depending on the exact data in arguments). 2. One extra digit is also needed if the argument has no integer digits, e.g. in a data type like DECIMAL(38,38). The conditions 1 and 2 are ORed. 3. Fixing FORMAT_MAX_DECIMALS from 30 to 38. This was forgotten in 10.2.1 (when the limit for the number of fractional digits in DECIMAL was extended).
Diffstat (limited to 'mysql-test/main/func_math.result')
-rw-r--r--mysql-test/main/func_math.result8
1 files changed, 4 insertions, 4 deletions
diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result
index a397f927265..c0072641d3b 100644
--- a/mysql-test/main/func_math.result
+++ b/mysql-test/main/func_math.result
@@ -2295,7 +2295,7 @@ FORMAT(-1e308,2)
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `FORMAT(-1e308,2)` varchar(416) DEFAULT NULL
+ `FORMAT(-1e308,2)` varchar(417) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 AS SELECT FORMAT('-1e308',2);
@@ -2305,7 +2305,7 @@ FORMAT('-1e308',2)
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `FORMAT('-1e308',2)` varchar(416) DEFAULT NULL
+ `FORMAT('-1e308',2)` varchar(417) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 AS SELECT FORMAT(DATE'20191231',0),FORMAT(TIME'99:05:00',0),FORMAT(TIMESTAMP'2019-12-31 23:59:59.123456',0);
@@ -2317,7 +2317,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`FORMAT(DATE'20191231',0)` varchar(11) DEFAULT NULL,
`FORMAT(TIME'99:05:00',0)` varchar(10) DEFAULT NULL,
- `FORMAT(TIMESTAMP'2019-12-31 23:59:59.123456',0)` varchar(19) DEFAULT NULL
+ `FORMAT(TIMESTAMP'2019-12-31 23:59:59.123456',0)` varchar(21) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (y YEAR);
@@ -3549,7 +3549,7 @@ FORMAT(f,0)
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
- `FORMAT(f,0)` varchar(53) DEFAULT NULL
+ `FORMAT(f,0)` varchar(54) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1,t2;
#