[MDEV-30008] Wrong results with optimizer_switch='semijoin=off' Created: 2022-11-14  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Sergei Petrunia
Resolution: Unresolved Votes: 0
Labels: 11.0-sel, not-10.3, regression


 Description   

CREATE TABLE t1 (id int, d1 TIMESTAMP);
INSERT INTO t1 (id,d1) VALUES (1,'2022-11-15 11:00:00.0'),(1,'2022-11-15 10:00:00.0'),(1,'2022-11-14 11:00:00.0');
 
select * FROM t1 where d1 in (select d1 from t1 );
set optimizer_switch='semijoin=off';
select * FROM t1 where d1 in (select d1 from t1 );

 
MariaDB [test]> select * FROM t1 where d1 in (select d1 from t1 );
+------+---------------------+
| id   | d1                  |
+------+---------------------+
|    1 | 2022-11-15 11:00:00 |
|    1 | 2022-11-15 10:00:00 |
|    1 | 2022-11-14 11:00:00 |
+------+---------------------+
3 rows in set (0,002 sec)
 
MariaDB [test]> set optimizer_switch='semijoin=off';
Query OK, 0 rows affected (0,000 sec)
 
MariaDB [test]> select * FROM t1 where d1 in (select d1 from t1 );
Empty set (0,002 sec)
 
 
MariaDB [test]> analyze select * FROM t1 where d1 in (select t1.d1 from t1 );
+------+--------------+-------+------+---------------+------+---------+------+------+--------+----------+------------+-------------+
| id   | select_type  | table | type | possible_keys | key  | key_len | ref  | rows | r_rows | filtered | r_filtered | Extra       |
+------+--------------+-------+------+---------------+------+---------+------+------+--------+----------+------------+-------------+
|    1 | PRIMARY      | t1    | ALL  | NULL          | NULL | NULL    | NULL | 3    | 3.00   |   100.00 |       0.00 | Using where |
|    2 | MATERIALIZED | t1    | ALL  | NULL          | NULL | NULL    | NULL | 3    | NULL   |   100.00 |       NULL |             |
+------+--------------+-------+------+---------------+------+---------+------+------+--------+----------+------------+-------------+
2 rows in set (0,002 sec)


Generated at Thu Feb 08 10:12:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.