Details
Description
This SQL script:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES ('10.6');
SELECT a, CAST('10.6' AS SIGNED) FROM t1;
SHOW WARNINGS;
returns:
+------+------------------------+
| a | CAST('10.6' AS SIGNED) |
+------+------------------------+
| 11 | 10 |
+------+------------------------+
1 row in set, 1 warning (0.00 sec)
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '10.6' |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)
Notice, when converting to a field, it rounds silently.
When converting in CAST, it truncates with a warning.
It should be fixed to expose similar behaviour in both cases.
The questions is: which of them is correct?
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions