An unknown error occured.
Bug #46641 | Unclear warning message 'Warning: 1292: Truncated incorrect DOUBLE value: ___' | ||
---|---|---|---|
Submitted: | 11 Aug 2009 0:54 | Modified: | 17 Aug 2009 8:22 |
Reporter: | Roel Van de Paar | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
Version: | 5.1.36/5.4 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[11 Aug 2009 0:54]
Roel Van de Paar
[11 Aug 2009 1:02]
MySQL Verification Team
Thank you for the bug report.
[11 Aug 2009 1:25]
Roel Van de Paar
Also see bug #19398
[16 Aug 2009 23:52]
Roel Van de Paar
> It is not clear why the above is wrong. I am not sure that it is necessarily an 'incorrect' warning message. However, it seems like a very 'unclear' warning message; When a user reads the following: "Truncated incorrect DOUBLE value: 'test '" for this query: select * from test5 join test6 on f1 where f1='test'; It could mean a lot of things. To me I read this as follows: 'Truncated' means shortened 'Incorrect ... value' means there is some sort of incorrect value 'DOUBLE' points to a data type 'test ' is the input that was used in the query, though with a space added? Without further research, none of these makes sense to me: 'Truncated': i.e. What was truncated? Truncated to what? Why was something truncated? Why is there a space in 'test '? 'Incorrect ... value': Why was the value incorrect? A similar query without the 'on f1' does not yield an error: mysql> select * from test5 join test6 where f1='test'; 'DOUBLE': Why a DOUBLE value while the query was referencing character strings? 'test ': why was the space added? Why was it truncated? > Strings are converted to floats in these type of comparisons. It is true that the numeric value of the string is 'zero' and as such, the truncation of it from double to integer has no practical consequences - i.e. there is no actual change in the value, but still, a trancation is taking place and there are cases where a warning is warented even if the value is not changing. Based on the linked bug, and some further research (given the EXPLAIN EXTENDED+SHOW WARNINGS output below), I think I understand this. The query is really evaluated as: select `testfor`.`test5`.`f1` AS `f1`,`testfor`.`test6`.`f2` AS `f2` from `testfor`.`test5` join `testfor`.`test6` where ((`testfor`.`test5`.`f1` = 'test') and `testfor`.`test5`.`f1`) I think the problem is that the following syntax is allowed: mysql> select * from test5 where f1; Empty set, 2 warnings (0.00 sec) mysql> show warnings; +---------+------+--------------------------------------------+ | Level | Code | Message | +---------+------+--------------------------------------------+ | Warning | 1292 | Truncated incorrect INTEGER value: 'test ' | | Warning | 1292 | Truncated incorrect INTEGER value: 'test2' | +---------+------+--------------------------------------------+ 2 rows in set (0.00 sec) I assume it is trying to convert this to an integer because it is trying to an 'IS TRUE' comparison; mysql> create table test9(id boolean); Query OK, 0 rows affected (0.05 sec) mysql> insert into test9 values (0),(1),(0); Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from test9 where id; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.00 sec) How about an invalid syntax warning (or even error) for this instead; ----- Error/Warning: 'WHERE comparisons between numerical and non-numerical columns are not allowed' ----- This does not fully explain why it is using a FLOAT in the warning above instead though. As a sidenote, the space(s) seem to have something to do with the defined column length: mysql> create table test5(f1 char(10)); Query OK, 0 rows affected (0.03 sec) mysql> insert into test5 values('test'),('test123'),('test12345'); Query OK, 3 rows affected (0.01 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> select * from test5 where f1; Empty set, 3 warnings (0.00 sec) mysql> show warnings; +---------+------+-------------------------------------------------+ | Level | Code | Message | +---------+------+-------------------------------------------------+ | Warning | 1292 | Truncated incorrect INTEGER value: 'test ' | | Warning | 1292 | Truncated incorrect INTEGER value: 'test123 ' | | Warning | 1292 | Truncated incorrect INTEGER value: 'test12345 ' | +---------+------+-------------------------------------------------+ 3 rows in set (0.00 sec)
[17 Aug 2009 8:22]
Susanne Ebrecht
Set back to verified because of last comment of Roel.