Details
Description
When a string value is insterted into an INT, DOUBLE or DECIMAL column, it send different warnings in case of EDOM errors (when they could not find any digits) and truncation errors:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (''),('123x');
SHOW WARNINGS;
+---------+------+-----------------------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------------------+ | Warning | 1366 | Incorrect integer value: '' for column 'a' at row 1 | | Warning | 1265 | Data truncated for column 'a' at row 2 | +---------+------+-----------------------------------------------------+
If I force implicit string-to-number conversion the other way around:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR(10));
INSERT INTO t1 VALUES (''),('123x');
SELECT a+1 FROM t1;
SHOW WARNINGS;
it does not distinguish between EDOM and truncation:
+---------+------+------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: '' | | Warning | 1292 | Truncated incorrect DOUBLE value: '123x' | +---------+------+------------------------------------------+
Functions and literals also do not distinguish between EDOM and truncation:
SELECT ''+1,'123x'+1; SHOW WARNINGS;
+---------+------+------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: '' | | Warning | 1292 | Truncated incorrect DOUBLE value: '123x' | +---------+------+------------------------------------------+
In case of EDOM the warning tells about truncation, which is not true.
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions