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

Suspicious behaviour around creation of multi-column indexes

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6, 10.11, 11.4, 11.4.5, 10.5(EOL), 11.7(EOL)
    • 10.6, 10.11, 11.4
    • Optimizer
    • None
    • Ubuntu (x86)

    Description

      This is a cross-posted issue from MySQL: https://bugs.mysql.com/bug.php?id=117439


      Consider the following test case:

      CREATE TABLE IF NOT EXISTS t0(c0 INT, c1 INT);
      INSERT INTO t0(c0, c1) VALUES(1, 1);
      INSERT INTO t0(c0, c1) VALUES(NULL, 2);
      INSERT INTO t0(c0, c1) VALUES(NULL, 1);
      INSERT INTO t0(c0, c1) VALUES(1, 2);
      CREATE INDEX i0 ON t0(c0, c1); -- Line A
      INSERT INTO t0(c0, c1) VALUES(1, 1);
       
      SELECT
          t0.c0 AS ref0,
          MAX(t0.c1) AS ref1
      FROM t0 WHERE (t0.c1 = 1) > 0
      GROUP BY t0.c0;
      

      The query does not fetch any rows.

      The expected result should be:

      ref0 ref1
      null 1
      1 1

      This is unexpected because in the table t0, the rows with (c0, c1) values as (null, 1), (1, 1), (1, 1) satisfy `(t0.c1 = 1) > 0`. Therefore, the GROUP BY operation should be performed on those rows, hence should not return an empty result.

      When the index i0 is removed, or when the index i0 is created at any point before `Line A`, 2 rows are returned as expected.

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            emilyong Emily Ong
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.