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

LP:823835 - Wrong result with derived_merge=on, EXISTS, RIGHT JOIN, derived table , correlated subquery in maria-5.3

Details

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

    Description

      This query:

      SELECT *
      FROM ( SELECT * FROM t2 ) AS alias1
      WHERE EXISTS (
      SELECT t1.a
      FROM t3
      RIGHT JOIN t1
      ON ( t3.d = t1.a )
      WHERE t1.c < alias1.d
      );

      returns no rows when executed with derived_merge=on, whereas with derived_merge=off, in mysql-5.5 and in postgresql it returns:

      ----------+

      c d

      ----------+

      0 r
      0 p

      ----------+

      explain:

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

      id select_type table type possible_keys key key_len ref rows Extra

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

      1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
      3 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1  
      3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where

      minimal optimizer_switch: derived_merge=on
      full optimizer_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=on,derived_merge=on,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,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

      test case:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 ( a int NOT NULL , e int, c varchar(32)) ;
      INSERT INTO t1 VALUES (28,9,'j');

      DROP TABLE IF EXISTS t2;
      CREATE TABLE t2 ( c int, d varchar(32)) ;
      INSERT INTO t2 VALUES (0,'r'),(0,'p');

      DROP TABLE IF EXISTS t3;
      CREATE TABLE t3 (d int);
      INSERT INTO t3 VALUES (0),(0);

      SET SESSION optimizer_switch='derived_merge=on';
      SELECT *
      FROM ( SELECT * FROM t2 ) AS alias1
      WHERE EXISTS (
      SELECT t1.a
      FROM t3
      RIGHT JOIN t1
      ON ( t3.d = t1.a )
      WHERE t1.c < alias1.d
      );

      bzr version-info
      revision-id: <email address hidden>
      date: 2011-08-09 18:34:26 +0300
      build-date: 2011-08-10 13:26:22 +0300
      revno: 3148
      branch-nick: maria-5.3

      Attachments

        Activity

          philipstoev Philip Stoev (Inactive) created issue -

          Re: Wrong result with derived_merge=on, EXISTS, RIGHT JOIN, derived table , correlated subquery in maria-5.3
          This bug is actually a duplicate of bug #823189. The difference is that a merged derived table is used instead of a merged view in the offending test case for this bug. As in the test case for bug #823189 the correlated subquery is over a right join and contains an outer reference to a derived table in the where clause.

          igor Igor Babaev (Inactive) added a comment - Re: Wrong result with derived_merge=on, EXISTS, RIGHT JOIN, derived table , correlated subquery in maria-5.3 This bug is actually a duplicate of bug #823189. The difference is that a merged derived table is used instead of a merged view in the offending test case for this bug. As in the test case for bug #823189 the correlated subquery is over a right join and contains an outer reference to a derived table in the where clause.

          Launchpad bug id: 823835

          ratzpo Rasmus Johansson (Inactive) added a comment - Launchpad bug id: 823835
          ratzpo Rasmus Johansson (Inactive) made changes -
          Field Original Value New Value
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Labels Launchpad
          ratzpo Rasmus Johansson (Inactive) made changes -
          Fix Version/s Maria 5.3 [ 11302 ]
          Labels Launchpad Launchpad MariaDB_5.3
          ratzpo Rasmus Johansson (Inactive) made changes -
          Resolution Fixed [ 1 ]
          Status Reopened [ 4 ] Closed [ 6 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Key IMT-7335 MDEV-2113
          Project ImportTest [ 10200 ] MariaDB Development [ 10000 ]
          Workflow jira [ 20984 ] defaullt [ 22957 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Key IMT-7335 MDEV-3248
          Project ImportTest [ 10200 ] MariaDB Development [ 10000 ]
          Workflow jira [ 20984 ] defaullt [ 24092 ]
          ratzpo Rasmus Johansson (Inactive) made changes -
          Key IMT-7335 MDEV-3720
          Project ImportTest [ 10200 ] MariaDB Development [ 10000 ]
          Workflow jira [ 20984 ] defaullt [ 24564 ]
          serg Sergei Golubchik made changes -
          Workflow defaullt [ 24564 ] MariaDB v2 [ 45872 ]
          serg Sergei Golubchik made changes -
          Labels Launchpad MariaDB_5.3 Launchpad
          ratzpo Rasmus Johansson (Inactive) made changes -
          Workflow MariaDB v2 [ 45872 ] MariaDB v3 [ 66559 ]
          serg Sergei Golubchik made changes -
          Workflow MariaDB v3 [ 66559 ] MariaDB v4 [ 145742 ]

          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.