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

Wrong value in WITH ROLLUP summary rows when grouping by expression that is a function

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.11
    • N/A
    • Optimizer, Parser
    • None
    • Not for Release Notes

    Description

      In a GROUP BY ... WITH ROLLUP query, if the grouping argument is a function and is wrapped by a function in the SELECT-list, summary rows are not correctly indicated with NULL.

      Query to reproduce:

      CREATE TABLE t1 (
        a INT,
        b INT
      );
       
      INSERT INTO t1 VALUES
      (1, 1),
      (1, 2),
      (1, 3),
      (2, 1),
      (2, 2),
      (2, 3);
       
      SELECT a + a + 1, SUM(b) FROM t1 GROUP BY a + a WITH ROLLUP;
      

      MySQL result:

      +-----------+--------+
      | a + a + 1 | SUM(b) |
      +-----------+--------+
      |         3 |      6 |
      |         5 |      6 |
      |      NULL |     12 |
      +-----------+--------+
      

      MariaDB result:

      +-----------+--------+
      | a + a + 1 | SUM(b) |
      +-----------+--------+
      |         3 |      6 |
      |         5 |      6 |
      |         5 |     12 |
      +-----------+--------+
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jaeheonshim Jaeheon Shim
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.