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

Wrong result with table elimination combined with not_null_range_scan

Details

    Description

      The following tests shows we get different results depending on the setting of
      'not_null_range_scan':

      CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
      INSERT INTO t1 VALUES (10,1),(null,2);
      CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=MyISAM;
      INSERT INTO t2 VALUES (1),(2);
      SET optimizer_switch= 'not_null_range_scan=on';
      SELECT t1.b FROM t1 LEFT JOIN t2 ON t1.a = t2.pk WHERE t1.a IS NULL ORDER BY t1.b;
      SET optimizer_switch= 'not_null_range_scan=off';
      SELECT t1.b FROM t1 LEFT JOIN t2 ON t1.a = t2.pk WHERE t1.a IS NULL ORDER BY t1.b;

      The first test returns 0 rows and the second test 1 row.

      Attachments

        Activity

          monty Michael Widenius created issue -
          monty Michael Widenius made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]

          The bug was that build_notnull_conds_for_range_scans() did not take into
          account the join_tab is not yet sorted with constant tables first.
          Fixed the bug by testing explicitly if a table is a const table.

          monty Michael Widenius added a comment - The bug was that build_notnull_conds_for_range_scans() did not take into account the join_tab is not yet sorted with constant tables first. Fixed the bug by testing explicitly if a table is a const table.
          monty Michael Widenius made changes -
          Component/s Optimizer [ 10200 ]
          Fix Version/s 10.6.9 [ 27507 ]
          Fix Version/s 10.7.5 [ 27505 ]
          Fix Version/s 10.8.4 [ 27503 ]
          Fix Version/s 10.9.2 [ 27115 ]
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]
          ralf.gebhardt Ralf Gebhardt made changes -
          Fix Version/s 10.5.17 [ 27509 ]
          Fix Version/s 10.5.16 [ 27508 ]

          People

            monty Michael Widenius
            monty Michael Widenius
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.