Bug #11469 wrong WHERE NULL-value optimization (CONCAT_WS?)
| Submitted: | 20 Jun 2005 20:12 | Modified: | 29 Jun 2005 20:32 |
|---|---|---|---|
| Reporter: | Alex Zimnitski | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 4.1.12a | OS: | Windows (windows 2000) |
| Assigned to: | Igor Babaev | CPU Architecture: | Any |
[20 Jun 2005 20:12]
Alex Zimnitski
[21 Jun 2005 7:51]
Hartmut Holzgraefe
SELECT t1.`id`,CONCAT_WS( ' -> ', t3.title, t2.title, t1.title) AS col1 FROM `product_characteristic` AS t1 LEFT JOIN `product_characteristic` AS t2 ON t1.`id_product_characteristic`=t2.`id` LEFT JOIN `product_characteristic` AS t3 ON t2.`id_product_characteristic`=t3.`id` returns +----+---------------+ | id | col1 | +----+---------------+ | 1 | Main | | 2 | Main -> Toys | | 3 | Main -> Games | +----+---------------+ so we'd expect row #2 to match the "like '%toys%'" condition, but SELECT t1.`id`,CONCAT_WS( ' -> ', t3.title, t2.title, t1.title) AS col1 FROM `product_characteristic` AS t1 LEFT JOIN `product_characteristic` AS t2 ON t1.`id_product_characteristic`=t2.`id` LEFT JOIN `product_characteristic` AS t3 ON t2.`id_product_characteristic`=t3.`id` WHERE CONCAT_WS( ' -> ', t3.title, t2.title, t1.title) LIKE '%toys%'; returns an empty set. as soon as the t3.title column in the WHERE clause is replaced by IF(t3.title IS NULL, NULL, t3.title) which is supposed to be a no-op as t3.title is NULL already so it is just replacing NULL with NULL, the result is SELECT t1.`id`,CONCAT_WS( ' -> ', t3.title, t2.title, t1.title) AS col1 FROM `product_characteristic` AS t1 LEFT JOIN `product_characteristic` AS t2 ON t1.`id_product_characteristic`=t2.`id` LEFT JOIN `product_characteristic` AS t3 ON t2.`id_product_characteristic`=t3.`id` WHERE CONCAT_WS( ' -> ', if(t3.title is null,NULL,t3.title), t2.title, t1.title) LIKE '%Toy%'; +----+--------------+ | id | col1 | +----+--------------+ | 2 | Main -> Toys | +----+--------------+ 1 row in set (0,00 sec) as expected
[29 Jun 2005 9:40]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/26512
[29 Jun 2005 17:22]
Igor Babaev
ChangeSet
1.2324 05/06/29 02:40:25 igor@rurik.mysql.com +3 -0
func_str.test:
Added test cases for bug #11469.
item_strfunc.h:
Fixed bug #11469: wrong implementation of the not_null_tables
method for CONCAT_WS.
The fix will appear in 4.1.13 and 5.0.9.
[29 Jun 2005 20:32]
Mike Hillyer
Documented in 5.0.9 and 4.1.13 changelogs.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.056 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.