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

Select from view fails if definition of view has 'HAVING' in query

    XMLWordPrintable

Details

    Description

      Select from view fails if definition of view has 'HAVING' in query.

      Test:

      CREATE TABLE t1 (a int, b int);
      CREATE TABLE t2 (c int, d int);
       
      INSERT INTO t1 VALUES
        (1,10), (2,10), (1,20), (2,20), (3,20), (2,30), (4,40);
      INSERT INTO t2 VALUES
        (2,10), (2,20), (4,10), (5,10), (3,20), (2,40);
       
      SELECT a, MAX(b), MIN(b) FROM t1 GROUP BY a;
      SELECT * FROM t2;
       
      CREATE VIEW v1 as SELECT a FROM t1 GROUP BY a
        HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20);
       
      SELECT * FROM  v1;
       
      DROP VIEW v1;
      DROP TABLE t1,t2;
      

      Actual result:

      mysqltest: At line 18: query 'SELECT * FROM  v1' failed: 1356: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
      

      Expected result:

      a
      2
      4
      

      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.