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

Bad error message for SET DEFAULT ROLE when user account is not granted the role

    XMLWordPrintable

Details

    Description

      Let's say that we create a role and a user account:

      MariaDB [(none)]> CREATE ROLE 'test_role';
      Query OK, 0 rows affected (0.004 sec)
       
      MariaDB [(none)]> CREATE USER 'test_user'@'%';
      Query OK, 0 rows affected (0.004 sec)
      

      If we try to set this role to the user's default role without first granting the role to the user, then we see this error message:

      MariaDB [(none)]> SET DEFAULT ROLE 'test_role' FOR 'test_user'@'%';
      ERROR 1959 (OP000): Invalid role specification `test_role`
      

      This "Invalid role specification" error message is incorrect. It would be more accurate to say something like this:

      User `test_user`@`%` has not been granted role `test_role`

      Obviously, if we grant the role to the user before executing SET DEFAULT ROLE, then everything works fine:

      MariaDB [(none)]> GRANT 'test_role' TO 'test_user'@'%';
      Query OK, 0 rows affected (0.004 sec)
       
      MariaDB [(none)]> SET DEFAULT ROLE 'test_role' FOR 'test_user'@'%';
      Query OK, 0 rows affected (0.004 sec)
      

      Attachments

        Issue Links

          Activity

            People

              anel Anel Husakovic
              GeoffMontee Geoff Montee (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.