Bug #117704 WHERE Clause Fails to Filter NULL Values in Condition (col1 = col2)
| Submitted: | 14 Mar 2025 9:24 | Modified: | 14 Mar 2025 10:42 |
|---|---|---|---|
| Reporter: | zhiqiang cheng | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
| Version: | 9.1.0, 8.0.41, 8.4.4, 9.2.0 | OS: | Ubuntu (20.04) |
| Assigned to: | CPU Architecture: | Any |
[14 Mar 2025 10:42]
MySQL Verification Team
Hello zhiqiang cheng, Thank you for the report and test case. regards, Umesh
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.039 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.
Description: When using a WHERE clause with a condition like (col1 = col2), MySQL fails to filter the rows correctly. Specifically, when performing a RIGHT OUTER JOIN and checking the condition (ref_1.c1) = (subq_0.c_0) where subq_0.c_0 is NULL, the result should be filtered out because NULL = ref_1.c1 should evaluate to NULL, and therefore not return rows.However, MySQL does not filter out rows as expected. How to repeat: Create Test Table and Insert Sample Data: DROP TABLE IF EXISTS `t1`; CREATE TABLE `t1` ( `c1` int ) ; INSERT INTO `t1` VALUES (1); Execute the Following Query: select subq_0.c_0 as c_0, ref_1.c1 as c_1 from ((select 1 as c_0 mysql version: github commit: 61a3a1d8ef15512396b4c2af46e922a19bf2b174 version: 9.1.0 os version: Linux ubuntu 5.15.0-134-generic #145~20.04.1-Ubuntu SMP Mon Feb 17 13:27:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux from t1 as ref_0 where false) as subq_0 right outer join t1 as ref_1 on (true)) where ((ref_1.c1) = (subq_0.c_0)); Expected Result: Empty set (0.00 sec) Actual Result: +-----+------+ | c_0 | c_1 | +-----+------+ | NULL | 1 | +-----+------+ 1 row in set (0.01 sec) Here, NULL = 1 should evaluate to NULL, and thus the row should be filtered out. However, it still appears in the result.