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

Wrong result for range w/o min endpoint, ORDER BY DESC and ICP

    XMLWordPrintable

Details

    • Q1/2026 Server Development

    Description

      While fixing MDEV-38649, discovered the following (regardless of whether the fix for that ticket is present):

      MariaDB [test]> CREATE TABLE t2 (a INT, b INT not null, KEY(b));
      Query OK, 0 rows affected (0.038 sec)
       
      MariaDB [test]> INSERT INTO t2 VALUES (2,8),(9,1),(4,6),(11,13),(15,17);
      Query OK, 5 rows affected (0.008 sec)
      Records: 5  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> SELECT a, b FROM t2 WHERE b != 10 and b < 30 ORDER BY b DESC;
      +------+----+
      | a    | b  |
      +------+----+
      |   15 | 17 |
      |   11 | 13 |
      +------+----+
      2 rows in set (0.002 sec)
      

      Meanwhile, MySQL 9.5.0:

      mysql> CREATE TABLE t2 (a INT, b INT not null, KEY(b));
      Query OK, 0 rows affected (0.040 sec)
       
      mysql> INSERT INTO t2 VALUES (2,8),(9,1),(4,6),(11,13),(15,17);
      Query OK, 5 rows affected (0.015 sec)
      Records: 5  Duplicates: 0  Warnings: 0
       
      mysql> SELECT a, b FROM t2 WHERE b != 10 and b < 30 ORDER BY b DESC;
      +------+----+
      | a    | b  |
      +------+----+
      |   15 | 17 |
      |   11 | 13 |
      |    2 |  8 |
      |    4 |  6 |
      |    9 |  1 |
      +------+----+
      5 rows in set (0.002 sec)
      

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              Gosselin Dave Gosselin
              Dave Gosselin Dave Gosselin
              Sergei Petrunia Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.