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

Optimizer trace requires ALL global privileges when query uses a view

    XMLWordPrintable

Details

    Description

      To get optimizer trace for a query involving a view, the user has to have all global privileges. Removing any privilege, even completely irrelevant like REPLICATION SLAVE ADMIN or DELETE HISTORY, makes the optimizer trace remain empty. No errors or warnings are produced.

      create table t (a int);
      create view v as select * from t;
       
      create user all_priv@localhost;
      grant all on *.* to all_priv@localhost;
       
      create user all_but_one@localhost;
      grant all on *.* to all_but_one@localhost;
      revoke DELETE HISTORY on *.* from all_but_one@localhost;
       
      --connect(con_all_priv,localhost,all_priv,,test)
       
      set optimizer_trace= 'enabled=on';
      select * from t;
      select query, length(trace) from information_schema.optimizer_trace;
      select * from v;
      select query, length(trace) from information_schema.optimizer_trace;
       
      --connect(con_all_but_one,localhost,all_but_one,,test)
       
      set optimizer_trace= 'enabled=on';
      select * from t;
      select query, length(trace) from information_schema.optimizer_trace;
      select * from v;
      select query, length(trace) from information_schema.optimizer_trace;
       
      # Cleanup
      --disconnect con_all_priv
      --disconnect con_all_but_one
      --connection default
      drop user all_priv@localhost, all_but_one@localhost;
      drop view v;
      drop table t;
      

      10.4 f97f6955

      connect con_all_but_one,localhost,all_but_one,,test;
      set optimizer_trace= 'enabled=on';
      select * from t;
      a
      select query, length(trace) from information_schema.optimizer_trace;
      query	length(trace)
      select * from t	933
      select * from v;
      a
      select query, length(trace) from information_schema.optimizer_trace;
      query	length(trace)
      	0
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.