Bug #81035 `NEWDECIMAL` result for ROUND() function is out of range of 65 digits
Description:
Output:
==
mysql> select round(999999999999999999999999999999999999999999999199999999999999999999999999999999999,-36);
Field 1: `round(999999999999999999999999999999999999999999999199999999999999999999999999999999999,-36)`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: NEWDECIMAL
Collation: binary (63)
Length: 82
Max_length: 81
Decimals: 0
Flags: NOT_NULL BINARY
+----------------------------------------------------------------------------------------------+
| round(999999999999999999999999999999999999999999999199999999999999999999999999999999999,-36) |
+----------------------------------------------------------------------------------------------+
| 999999999999999999999999999999999999999999999000000000000000000000000000000000000 |
+----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select round(9999999999999999999999999999999999999999999991999999999999999999999999999999999998,-37);
Field 1: `round(9999999999999999999999999999999999999999999991999999999999999999999999999999999998,-37)`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: NEWDECIMAL
Collation: binary (63)
Length: 66
Max_length: 66
Decimals: 0
Flags: NOT_NULL BINARY
+-----------------------------------------------------------------------------------------------+
| round(9999999999999999999999999999999999999999999991999999999999999999999999999999999998,-37) |
+-----------------------------------------------------------------------------------------------+
| 100000000000000000000000000000000000000000000000000000000000000000 |
+-----------------------------------------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
Problem:
==
From the following menual:
https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html
we can see that max value for decimal is 65 digit.
However, in the first select the result `999999999999999999999999999999999999999999999000000000000000000000000000000000000` contains 82 digits, which has already out of range of decimal, but the type in `column-type-info` is `NEWDECIMAL`.
How to repeat:
select round(999999999999999999999999999999999999999999999199999999999999999999999999999999999,-36);
select round(9999999999999999999999999999999999999999999991999999999999999999999999999999999998,-37);
Suggested fix:
Truncation is expected for first select, to 65 digits.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.