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

LP:887479 - Wrong result with firstmatch=off , ORDER BY , join_cache_level = 3, innodb

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • 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 c
      FROM t2
      )
      ORDER BY t1.a;

      returns
      a b
      3888 20

      when executed with firstmatch=off

      and

      a b
      3888 20
      3914 17

      for all other execution plans.

      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; Using filesort; Start temporary
      1 PRIMARY t2 ref c c 5 test.t1.b 1 Using index; End temporary

      minimal switch: semijoin=on,firstmatch=off ; join_cache_level=3..8
      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=off,firstmatch=off,loosescan=on,materialization=off,in_to_exists=on,semijoin=on,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-11-07 16:39:02 +0400
      build-date: 2011-11-08 11:48:08 +0200
      revno: 3273
      branch-nick: maria-5.3

      test case:

      --source include/have_innodb.inc

      CREATE TABLE t1 (a int NOT NULL , b int) ENGINE=InnoDB;
      INSERT INTO t1 VALUES (3914,17),(3888,20);

      CREATE TABLE t2 (c int, KEY (c)) ENGINE=InnoDB;
      INSERT INTO t2 VALUES (17),(20);

      SET SESSION join_cache_level=3;
      SET SESSION optimizer_switch='firstmatch=OFF';

      SELECT *
      FROM t1
      WHERE (t1.b) IN (
      SELECT c
      FROM t2
      )
      ORDER BY t1.a;

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 887479

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

              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: