Bug #111493 | sql return wrong results | ||
---|---|---|---|
Submitted: | 20 Jun 2023 8:25 | Modified: | 20 Jun 2023 12:52 |
Reporter: | hel le | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[20 Jun 2023 8:25]
hel le
[20 Jun 2023 12:16]
MySQL Verification Team
Hi Mr. le, Thank you for your bug report. However, it is not a bug. Your RIGHT JOIN matches zero rows, so it's output is an empty set. Hence, WHERE clause is here irrelevant, since it is applied to the empty set. Not a bug.
[20 Jun 2023 12:32]
hel le
when turn off materialization , result has value. trun on materialization result is empty. mysql> set optimizer_switch='materialization=off'; Query OK, 0 rows affected (0.00 sec) mysql> select ref_2.c_state as c0 from test1 right join test5 as ref_2 on ( EXISTS ( select ref_0.id from test1 `ref_0` inner join sqltester.test1 `ref_1` on (`ref_0`.`name` is not null) ) ) where EXISTS ( select 1 from test5 as ref_15 where (ref_15.c_state is NULL) ) and ref_2.c_state is NULL group by 1; +------+ | c0 | +------+ | NULL | +------+ 1 row in set (0.00 sec) mysql> set optimizer_switch='materialization=on'; Query OK, 0 rows affected (0.01 sec) mysql> select ref_2.c_state as c0 from test1 right join test5 as ref_2 on ( EXISTS ( select ref_0.id from test1 `ref_0` inner join sqltester.test1 `ref_1` on (`ref_0`.`name` is not null) ) ) where EXISTS ( select 1 from test5 as ref_15 where (ref_15.c_state is NULL) ) and ref_2.c_state is NULL group by 1; Empty set (0.00 sec) The query results should not be inconsistent due to different parameters. So it returns an empty error.
[20 Jun 2023 12:52]
MySQL Verification Team
Hi Mr. le, Yes, you are correct that optimiser switches should not affect results, but actually according to: https://dev.mysql.com/doc/refman/8.0/en/subquery-materialization.html it is quite possible that this can occur. This means that documentation has to be amended. We shall verify this bug as the optimiser bug, but it will, most likely, be addressed in the Manual. Verified.