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

LP:823301 - Wrong result with index_merge / sort_union and LEFT JOIN

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      The following query

      SELECT *
      FROM t1
      LEFT OUTER JOIN t2 ON t1.b = t2.a
      WHERE t1.c > 7 AND t1.e > 1 AND t1.e != 0 AND
      t1.e NOT IN ( 2 , 8 ) OR t1.e >= 7 AND t1.e < 8 OR t1.e > 7 ;

      returns 4 instead of 5 rows when executed with index_merge / sort_union .

      Explain:

      id select_type table type possible_keys key key_len ref rows Extra
      1 SIMPLE t1 index_merge PRIMARY,e,e_2 e,e_2 5,5 NULL 8 Using sort_union(e,e_2); Using where
      1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where

      test case:

      CREATE TABLE t1 ( b int, c int NOT NULL , d int, e int, KEY (e), PRIMARY KEY (c), KEY (e,c,d)) ;
      INSERT INTO t1 VALUES (0,58,7,7),(0,63,2,0),(0,64,186974208,8),(0,65,1,'-205389824'),
      (0,71,1901395968,'-258670592'),(0,72,321323008,'-749993984'),(0,73,0,3),(0,74,5,74252288),(0,75,5,3);

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

      SELECT *
      FROM t1
      LEFT OUTER JOIN t2 ON t1.b = t2.a
      WHERE t1.c > 7 AND t1.e > 1 AND t1.e != 0 AND t1.e NOT IN
      ( 2 , 8 )
      OR t1.e >= 7 AND t1.e < 8 OR t1.e > 7 ;

      bzr version-info:

      revision-id: <email address hidden>
      date: 2011-08-09 10:28:57 +0300
      build-date: 2011-08-09 16:40:36 +0300
      revno: 3147
      branch-nick: maria-5.3

      Reproducible in maria-5.3, Not reproducible in maria-5.2, mysql-5.5

      Attachments

        Activity

          People

            igor Igor Babaev
            philipstoev Philip Stoev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 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.