[MDEV-13742] Provide an error for truncated DECIMAL field Created: 2017-09-05 Updated: 2021-05-11 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Insert, Data types |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | Kyle Joiner (Inactive) | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | upstream | ||
| Description |
|
Provide a server mode to prevent truncation of numerical data: Test case :
Instead of warning provide a mechanism to error. |
| Comments |
| Comment by Arnaud Adant [ 2017-09-06 ] | |||||
| Comment by Elena Stepanova [ 2017-09-07 ] | |||||
|
Also reproducible with MySQL 5.7. | |||||
| Comment by Alexander Barkov [ 2017-09-13 ] | |||||
|
In this script:
Both should return an error. | |||||
| Comment by Sergei Golubchik [ 2017-09-20 ] | |||||
|
This is not a bug, the behavior is intentional. SQL Standard specifies that truncation is not an error. That's why we don't issue an error.
Note that there is no exception when the value is truncated or rounded. So implementing an optional non-standard behavior where this truncation causes an error is by all means a new feature. | |||||
| Comment by Arnaud Adant [ 2017-09-21 ] | |||||
|
Thank you for pointing out the SQL standard. That really helps. However, this was never intended to be a bug. It was also reported to Oracle as a feature request : https://bugs.mysql.com/bug.php?id=87678 | |||||
| Comment by Sergei Golubchik [ 2017-09-21 ] | |||||
|
Yes. I've changed it to a feature. Just wanted to point out that this feature will be non-standard and thus it must be optional (and, most probably disabled by default). But this feature kind of make sense, I agree. It might be useful in some cases, even if non-standard. |