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.