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

Database permissions are not enough to run a subquery with GROUP BY within a view

    XMLWordPrintable

Details

    Description

      create database db;
      use db;
      create table t (i int);
       
      create user foo@localhost;
      grant all on db.* to foo@localhost;
       
      --connect (con1,localhost,foo,,)
       
      use db;
      create view v as select * from (select i from t group by i) sq;
      select * from v;
       
      # Cleanup
      --disconnect con1
      --connection default
      drop view v;
      drop table t;
      drop user foo@localhost;
      

      The view gets created all right, but SELECT * FROM v fails:

      mysqltest: At line 12: query 'select * from v' failed: 1356: View 'db.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
      


      Here is a slightly different test case which might give a hint for a reason:

      create database db;
      use db;
      create table t1 (i int);
      create table t2 (j int);
       
      create user foo@localhost;
      grant all on db.* to foo@localhost;
       
      --connect (con1,localhost,foo,,)
       
      use db;
      create view v as select 1 from t1 inner join (select j from t2 group by j) `rs` on(i = j);
      select * from v;
       
      # Cleanup
      --disconnect con1
      --connection default
      drop view v;
      drop table t1, t2;
      drop user foo@localhost;
      

      In this case, SELECT ends with a different error:

      mysqltest: At line 13: query 'select * from v' failed: 1143: SELECT command denied to user 'foo'@'localhost' for column 'j' in table '/data/bld/10.2/mysql-test/var/tmp/mysqld.1/#sql_23ef_0'
      

      So, it looks like it's the temporary table that the user has no access to.

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              elenst Elena Stepanova
              Votes:
              1 Vote for this issue
              Watchers:
              6 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.