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

"Invalid use of group function" on 2nd execution of PS for SELECT from view created with aggregate functions

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.4(EOL), 10.5, 10.6, 10.10(EOL), 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL), 11.3(EOL)
    • 10.5, 10.6, 10.11
    • Prepared Statements
    • None

    Description

      After fix enable "ps2-protocol" for cases marked with MDEV-32038

      Testcase:

      CREATE TABLE t1 (a int, b INT, d INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));
      INSERT INTO t1 VALUES (1,1,0,'a'), (1,2,0,'b'), (1,3,0,'c'), (1,4,0,'d'),
      (1,5,0,'e'), (2,1,0,'f'), (2,2,0,'g'), (2,3,0,'h'), (3,4,0,'i'), (3,3,0,'j'),
      (3,2,0,'k'), (3,1,0,'l'), (1,9,0,'m'), (1,0,10,'n'), (2,0,5,'o'), (3,0,7,'p');
       
      create view v1 as SELECT tt.a,
       (SELECT (SELECT c FROM t1 as t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a)
        LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test
        FROM t1 as tt;
       
      prepare stmt from "select * from v1";
       
      execute stmt;
      execute stmt;
       
      deallocate prepare stmt;
       
      drop view v1;
       
      DROP TABLE t1;
      

      Actual value:

      prepare stmt from "select * from v1";
      execute stmt;
      a	test
      1	n
      1	n
      1	n
      1	n
      1	n
      1	n
      1	n
      2	o
      2	o
      2	o
      2	o
      3	p
      3	p
      3	p
      3	p
      3	p
      execute stmt;
       
      mysqltest: At line 14: query 'execute stmt' failed: ER_INVALID_GROUP_FUNC_USE (1111): Invalid use of group function
      

      Expected value:

      prepare stmt from "select * from v1";
      execute stmt;
      a	test
      1	n
      1	n
      1	n
      1	n
      1	n
      1	n
      1	n
      2	o
      2	o
      2	o
      2	o
      3	p
      3	p
      3	p
      3	p
      3	p
      execute stmt;
      a	test
      1	n
      1	n
      1	n
      1	n
      1	n
      1	n
      1	n
      2	o
      2	o
      2	o
      2	o
      3	p
      3	p
      3	p
      3	p
      3	p
      

      Attachments

        Issue Links

          Activity

            People

              shulga Dmitry Shulga
              lstartseva Lena Startseva
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.