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.

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.0, 10.1, 10.2
    • Fix Version/s: 5.5.55
    • Component/s: Optimizer
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: