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

Wrong result upon GROUP BY on a table with indexed virtual column after INSERT IGNORE

    XMLWordPrintable

Details

    • Q2/2026 Server Maintenance

    Description

      CREATE TABLE t (a INT PRIMARY KEY, va TINYINT AS (a), KEY(va));
      INSERT IGNORE INTO t (a) VALUES (100),(150),(200);
       
      SELECT a, COUNT(*) FROM t GROUP BY a;
      SELECT * FROM t;
       
      DROP TABLE t;
      

      12.2 de72d02bffe6639ef0b7911966a3f85e3eba052f

      SELECT a, COUNT(*) FROM t GROUP BY a;
      a	COUNT(*)
      100	1
      150	2
      SELECT * FROM t;
      a	va
      100	100
      150	127
      200	127
      

      The result of the first SELECT is obviously wrong, it should return 3 rows, without COUNT=1 for each.

      The failure started happening after this commit in 12.1.1:

      commit 8cdee25952763a0401e4c2a4d61e92c13499bdc6
      Author: Yuchen Pei
      Date:   Wed Jun 4 11:43:30 2025 +1000
       
          MDEV-36132 Substitute vcol expressions with indexed vcol fields in ORDER BY and GROUP BY
      

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              elenst Elena Stepanova
              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.