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

Select from view fails if definition of view has aggregate function ( like 'GROUP_CONCAT(COUNT(a))' ) in query

    XMLWordPrintable

Details

    Description

      Select from view fails with error "Invalid use of group function" if definition of view has 'GROUP_CONCAT(COUNT(a))' in query.

      Test:

      CREATE TABLE t1 (a int, b int);
      CREATE TABLE t2 (m int, n int);
      INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4);
      INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44);
       
      CREATE VIEW v1 AS SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c
        FROM t1 GROUP BY a;
       
      SELECT * FROM v1;
       
      DROP VIEW v1;
      DROP table t1,t2;
      

      Actual result:

      At line 9: query 'SELECT * FROM v1' failed: 1111: Invalid use of group function
      

      Expected result:

      c
      2
      3
      1,1
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              lstartseva Lena Startseva
              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.