Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30008

Wrong results with optimizer_switch='semijoin=off'

    XMLWordPrintable

Details

    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)
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            alice Alice Sherepa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.