Bug #118313 The query result is incorrect.
Submitted: 30 May 9:17 Modified: 30 May 10:14
Reporter: BN QIU Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.41, 8.0.42, 8.4.5, 9.3.0 OS:Any
Assigned to: CPU Architecture:Any

[30 May 9:17] BN QIU
Description:
If the where condition is "col_1 is not null" or "col_1 is null" in a query statement in the form of "Left join (select 1 from test1) AS sub_1(col_1) ON (false)", the query result is incorrect.

How to repeat:
create table test1 ( id int);
insert into test1 values (1),(2);

create table test2( a int );
insert into test2 values (100),(120),(600);

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.41    |
+-----------+
1 row in set (0.00 sec)

mysql> select * from (select * from test2 LEFT JOIN (select 1 from test1) AS sub_1(col_1) ON (false)) as dt;
+------+-------+
| a    | col_1 |
+------+-------+
|  100 |  NULL |
|  120 |  NULL |
|  600 |  NULL |
+------+-------+
3 rows in set (0.00 sec)

mysql> select * from (select * from test2 LEFT JOIN (select 1 from test1) AS sub_1(col_1) ON (false)) as dt where col_1 is null;
Empty set (0.00 sec)

mysql> select * from (select * from test2 LEFT JOIN (select 1 from test1) AS sub_1(col_1) ON (false)) as dt where col_1 is not null;
+------+-------+
| a    | col_1 |
+------+-------+
|  100 |  NULL |
|  120 |  NULL |
|  600 |  NULL |
+------+-------+
3 rows in set (0.00 sec)
[30 May 10:14] MySQL Verification Team
Hello B QIU,

Thank you for the report and test case.
Verified as described.

regards,
Umesh