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

LP:873263 - Wrong result with derived_with_keys, correlated subquery

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      The following query:

      SELECT * FROM t1 WHERE t1.b IN ( SELECT v2.a FROM v2 WHERE v2.b = t1.a );

      returns no rows when executed with derived_with_keys and

      a b
      5 4

      when executed otherwise.

      explain:

      id select_type table type possible_keys key key_len ref rows Extra
      1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
      2 DEPENDENT SUBQUERY <derived3> ref key0 key0 5 test.t1.a 2 Using where
      3 DERIVED t2 ALL NULL NULL NULL NULL 2

      minimal switch: derived_with_keys=ON;

      full switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=on,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on

      bzr version-info
      revision-id: <email address hidden>
      date: 2011-10-13 11:23:59 +0200
      build-date: 2011-10-13 14:15:52 +0300
      revno: 3232
      branch-nick: maria-5.3

      test case:

      CREATE TABLE t1 ( a int , b int ) ;
      INSERT INTO t1 VALUES (5,4),(9,8);

      CREATE TABLE t2 ( a int , b int ) ;
      INSERT INTO t2 VALUES (4,5),(5,1);

      CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
      SET SESSION optimizer_switch='derived_with_keys=ON';
      SELECT * FROM t1 WHERE t1.b IN ( SELECT v2.a FROM v2 WHERE v2.b = t1.a );

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            igor Igor Babaev added a comment -

            Re: Wrong result with derived_with_keys, correlated subquery
            This bug was fixed by the patch for bug #874006.

            Show
            igor Igor Babaev added a comment - Re: Wrong result with derived_with_keys, correlated subquery This bug was fixed by the patch for bug #874006.
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 873263

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 873263

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: