[MDEV-20305] Data loss on DOUBLE and DECIMAL conversion to INT Created: 2019-08-09 Updated: 2020-06-06 Resolved: 2020-06-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data types |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.5.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Notice, the result for `b << 0` and `c << 0` is wrong. It should be 18446744073709551615. The problem happens because Field_double::val_int() and Field_new_decimal::val_int() truncate to max signed bigint value. It's not easy to fix this in the current code base.
to:
so the underlying Field or Item can return the entire range -9223372036854775808 .. 18446744073709551615, i.e. from the minimum possible SIGNED value to maximum possible UNSIGNED value. |
| Comments |
| Comment by Alexander Barkov [ 2019-08-09 ] | ||||||||||||||
|
Unexpected truncation is also repeatable in this script:
And in this script:
Note, there is a inconsistency:
| ||||||||||||||
| Comment by Alexander Barkov [ 2019-08-09 ] | ||||||||||||||
|
Similar problem:
It's expected to return 64 (at least for the DECIMAL literal). | ||||||||||||||
| Comment by Alexander Barkov [ 2019-08-09 ] | ||||||||||||||
|
Similar problem:
| ||||||||||||||
| Comment by Alexander Barkov [ 2019-08-09 ] | ||||||||||||||
|
| ||||||||||||||
| Comment by Alexander Barkov [ 2019-08-10 ] | ||||||||||||||
|
Same problem:
| ||||||||||||||
| Comment by Alexander Barkov [ 2020-06-04 ] | ||||||||||||||
|
Similar problem:
Notice, values for c2 and c4 were truncated. | ||||||||||||||
| Comment by Alexander Barkov [ 2020-06-04 ] | ||||||||||||||
|
Similar problem:
Expect 0 in both columns. |