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

LP:843857 - Wrong result with views + specific join order

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Resolution: Not a Bug
    • None
    • None
    • None

    Description

      The following query:

      SELECT STRAIGHT_JOIN *
      FROM view_H
      RIGHT JOIN ( view_DD LEFT JOIN BB ON view_DD.b = BB.a )
      ON view_H.a = view_DD.c
      WHERE view_H.b <> 102;

      produces the following plan:

      1 SIMPLE t1 ALL NULL NULL NULL NULL 2  
      1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
      1 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join)

      and the following wrong result:

      b a a b c a

      -----------------------------+

      -312147968 0 7 h 0 know
      -312147968 0 7 h 0 j

      all other plans produce the following result:

      b a a b c a

      -----------------------------+

      -312147968 0 7 h 0 NULL

      repeatable in maria-5.3. not repeatable in maria-5.2, mysql-5.5.

      revision-id: <email address hidden>
      date: 2011-09-06 20:59:29 +0400
      build-date: 2011-09-07 15:56:33 +0300
      revno: 3178
      branch-nick: maria-5.3

      switches:

      --join_cache_level=8
      --optimizer_switch=join_cache_incremental=ON,join_cache_bka=OFF,join_cache_hashed=OFF

      test case:

      CREATE TABLE t1 ( a varchar(32)) ;
      INSERT INTO t1 VALUES ('know'),('j');

      CREATE TABLE t2 ( b int, a int) ;
      INSERT INTO t2 VALUES ('-312147968','but');

      CREATE TABLE t3 ( a int NOT NULL , b varchar(32), c int) ;
      INSERT INTO t3 VALUES (7,'t2',0);

      CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2;
      CREATE OR REPLACE VIEW v3 AS SELECT * FROM t3;

      SELECT STRAIGHT_JOIN *
      FROM v2
      RIGHT JOIN ( v3 LEFT JOIN t1 ON v3.b = t1.a )
      ON v2.a = v3.c
      WHERE v2.b <> 102;

      Attachments

        Activity

          People

            igor Igor Babaev (Inactive)
            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.