| Bug #42936 | Strings incorrectly converted to double | ||
|---|---|---|---|
| Submitted: | 17 Feb 2009 15:20 | Modified: | 20 Feb 2009 14:38 |
| Reporter: | Ray Ray | Email Updates: | |
| Status: | Duplicate | Impact on me: | |
| Category: | MySQL Server: General | Severity: | S3 (Non-critical) |
| Version: | 5.0.32, 5.0.74, 5.0.79-bzr | OS: | Linux |
| Assigned to: | CPU Architecture: | Any | |
[17 Feb 2009 15:20]
Ray Ray
[17 Feb 2009 15:44]
Valeriy Kravchuk
This is not a bug. When string column is compared to number they are compared as double numbers. This is documented. See http://dev.mysql.com/doc/refman/5.0/en/type-conversion.html for explanation.
[17 Feb 2009 19:07]
Ray Ray
So this is expected behavior?
select 'bob' in ('henry',1), 'bob'='henry' or 'bob'=1;
+----------------------+--------------------------+
| 'bob' in ('henry',1) | 'bob'='henry' or 'bob'=1 |
+----------------------+--------------------------+
| 1 | 0 |
+----------------------+--------------------------+
1 row in set, 3 warnings (0.00 sec)
Warning (Code 1292): Truncated incorrect DOUBLE value: 'henry'
Warning (Code 1292): Truncated incorrect DOUBLE value: 'bob'
Warning (Code 1292): Truncated incorrect DOUBLE value: 'bob'
[18 Feb 2009 11:21]
Valeriy Kravchuk
No, this is wrong:
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot -P3308 test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.74-enterprise-gpl-nt-log MySQL Enterprise Server - Pro Editi
on (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select 'bob' in ('henry',1), 'bob'='henry' or 'bob'=1;
+----------------------+--------------------------+
| 'bob' in ('henry',1) | 'bob'='henry' or 'bob'=1 |
+----------------------+--------------------------+
| 1 | 0 |
+----------------------+--------------------------+
1 row in set, 3 warnings (0.08 sec)
MySQL 5.1.30 gives correct result:
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot -P3310 test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.30-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select 'bob' in ('henry',1), 'bob'='henry' or 'bob'=1;
+----------------------+--------------------------+
| 'bob' in ('henry',1) | 'bob'='henry' or 'bob'=1 |
+----------------------+--------------------------+
| 0 | 0 |
+----------------------+--------------------------+
1 row in set, 2 warnings (0.00 sec)
mysql> show warnings\G
*************************** 1. row ***************************
Level: Warning
Code: 1292
Message: Truncated incorrect DOUBLE value: 'bob'
*************************** 2. row ***************************
Level: Warning
Code: 1292
Message: Truncated incorrect DOUBLE value: 'bob'
2 rows in set (0.02 sec)
[18 Feb 2009 12:23]
Valeriy Kravchuk
Latest 5.0.79 from bzr is also affected.
