| Bug #76353 | "Truncated incorrect INTEGER value" in INSERT...SELECT with CASE tested for NULL | ||
|---|---|---|---|
| Submitted: | 17 Mar 2015 14:55 | Modified: | 17 Mar 2015 18:16 |
| Reporter: | Bernhard Haumacher | Email Updates: | |
| Status: | Duplicate | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.6.22 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[17 Mar 2015 14:55]
Bernhard Haumacher
[17 Mar 2015 17:12]
MySQL Verification Team
Thank you for the bug report. Looks duplicate of bug you have mentioned the difference is you maybe have a sql_mode which converts the warnings in error see below:
mysql 5.6 > INSERT INTO `storage` (`a`, `b`)
-> SELECT
-> t1.id `a`,
-> (CASE WHEN t1.a1 = 'foo' THEN t1.`id` ELSE t2.`dst` END) `b`
-> FROM `a` t1
-> LEFT OUTER JOIN `ab` t2
-> ON t1.id = t2.src
-> WHERE
-> NOT (
-> (CASE WHEN t1.a1 = 'foo' THEN t1.`id` ELSE t2.`dst` END)
-> IS NULL);
ERROR 1292 (22007): Truncated incorrect INTEGER value: 'x'
mysql 5.6 > SET sql_mode = '';
Query OK, 0 rows affected (0.00 sec)
mysql 5.6 > INSERT INTO `storage` (`a`, `b`)
-> SELECT
-> t1.id `a`,
-> (CASE WHEN t1.a1 = 'foo' THEN t1.`id` ELSE t2.`dst` END) `b`
-> FROM `a` t1
-> LEFT OUTER JOIN `ab` t2
-> ON t1.id = t2.src
-> WHERE
-> NOT (
-> (CASE WHEN t1.a1 = 'foo' THEN t1.`id` ELSE t2.`dst` END)
-> IS NULL);
Query OK, 2 rows affected, 2 warnings (0.05 sec)
Records: 2 Duplicates: 0 Warnings: 2
[17 Mar 2015 17:55]
Bernhard Haumacher
Yes, you are right. When setting sql_mode to empty, the statement completes with as many warnings, as rows are inserted. At least, the inserted result is correct. Not a feature anyway, isn't it?
[17 Mar 2015 17:58]
Bernhard Haumacher
And what's not mentioned/not correct/different to http://bugs.mysql.com/bug.php?id=43437 is that its a regression in 5.6, since everything worked fine in 5.1. #43437 states that it also happens in 5.0 and 5.1!
[17 Mar 2015 18:16]
MySQL Verification Team
duplicate of http://bugs.mysql.com/bug.php?id=43437.
