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

Wrong result from a query with IN subquery used in WHERE of EXISTS subquery.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5, 10.0, 10.1, 10.2
    • 5.5.55
    • Optimizer
    • None

    Description

      The following test case produces a wrong result set:

      CREATE TABLE t1 (
        pk INT, f1 INT NOT NULL, f2 VARCHAR(3), f3 INT NULL, PRIMARY KEY(pk)) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (1,1,'foo',8), (2,5,'bar',7);
       
      SELECT sq1.f2    FROM t1 AS sq1 
          WHERE EXISTS ( SELECT * FROM t1 AS sq2                      
                                           WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 );
       
      MariaDB [test]> SELECT sq1.f2    FROM t1 AS sq1     WHERE EXISTS ( SELECT * FROM t1 AS sq2                       WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 );
      Empty set (0.00 sec)
      

      The problem is reproduced in 10.0,10.1,10.2 with the same test case if subquery_cache is set to 'off' in the optimizer switch:

      set optimizer_switch='subquery_cache=off';
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              igor Igor Babaev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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