summaryrefslogtreecommitdiff
path: root/mysql-test/main/ctype_utf8.result
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-08-03 13:56:10 +0400
committerAlexander Barkov <bar@mariadb.com>2020-08-04 08:09:08 +0400
commit6a2ee9c8bbec437e7eb50b1a273a017cdefc6e15 (patch)
tree4e8fa89371f463521d61dc3fe33d9a6989a0039e /mysql-test/main/ctype_utf8.result
parent706a7101bfacd29f4f5728034be92240e82df583 (diff)
downloadmariadb-git-6a2ee9c8bbec437e7eb50b1a273a017cdefc6e15.tar.gz
MDEV-23032 FLOOR()/CEIL() incorrectly calculate the precision of a DECIMAL(M,D) column
The code in Item_func_int_val::fix_length_and_dec_int_or_decimal() calculated badly the result data type for FLOOR()/CEIL(), so for example the decimal(38,10) input created a decimal(28,0) result. That was not correct, because one extra integer digit is needed. floor(-9.9) -> -10 ceil(9.9) -> 10 Rewritting the code in a more straightforward way. Additional changes: - FLOOR() now takes into account the presence of the UNSIGNED flag of the argument: FLOOR(unsigned decimal) does not need an extra digits. - FLOOR()/CEILING() now preserve the unsigned flag in the result data type is decimal. These changes give nicer data types.
Diffstat (limited to 'mysql-test/main/ctype_utf8.result')
-rw-r--r--mysql-test/main/ctype_utf8.result10
1 files changed, 6 insertions, 4 deletions
diff --git a/mysql-test/main/ctype_utf8.result b/mysql-test/main/ctype_utf8.result
index 9585931584b..bd35fd10f19 100644
--- a/mysql-test/main/ctype_utf8.result
+++ b/mysql-test/main/ctype_utf8.result
@@ -2817,21 +2817,23 @@ drop table t1;
select hex(concat(ceiling(0.5)));
hex(concat(ceiling(0.5)))
31
-create table t1 as select concat(ceiling(0.5)) as c1;
+create table t1 as select ceiling(0.5) as c0, concat(ceiling(0.5)) as c1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(4) CHARACTER SET utf8 DEFAULT NULL
+ `c0` int(3) NOT NULL,
+ `c1` varchar(3) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(floor(0.5)));
hex(concat(floor(0.5)))
30
-create table t1 as select concat(floor(0.5)) as c1;
+create table t1 as select floor(0.5) as c0, concat(floor(0.5)) as c1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c1` varchar(4) CHARACTER SET utf8 DEFAULT NULL
+ `c0` int(3) NOT NULL,
+ `c1` varchar(3) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
select hex(concat(round(0.5)));