Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
5.3.12, 5.5.36, 10.0.9
-
None
-
None
Description
This SQL script inserts two out-of-range numbers:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a TINYINT);
|
INSERT INTO t1 VALUES (127.1),(128);
|
SHOW WARNINGS;
|
SELECT * FROM t1;
|
However, only one warning is reported:
+---------+------+--------------------------------------------+
|
| Level | Code | Message |
|
+---------+------+--------------------------------------------+
|
| Warning | 1264 | Out of range value for column 'a' at row 2 |
|
+---------+------+--------------------------------------------+
|
A prove that both numbers were truncated:
mysql> SELECT * FROM t1;
|
+------+
|
| a |
|
+------+
|
| 127 |
|
| 127 |
|
+------+
|
2 rows in set (0.00 sec)
|
It should be fixed to report truncation in both cases.
The problem happens because the valid range is checked after conversion to integer.
It should be checked before conversion.