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

ER_NO_SUCH_USER for empty user name in SET SESSION AUTHORIZATION looks inconsistent

Details

    Description

      When a user name (or host name) is empty in the user specification for SET SESSION AUTHORIZATION command, ER_NO_SUCH_USER is produced regardless whether the user with the empty value actually exists.

      According to set_authorization.test it is expected, but still, it looks strange, so I want to have it at least filed for those who come later wondering.

      d4c600f804af677ac3177497b3770dbd67c448f7

      MariaDB [test]> create or replace user ''@localhost;
      Query OK, 0 rows affected (0.013 sec)
       
      MariaDB [test]> show grants for ''@localhost;
      +--------------------------------------+
      | Grants for @localhost                |
      +--------------------------------------+
      | GRANT USAGE ON *.* TO ``@`localhost` |
      +--------------------------------------+
      1 row in set (0.000 sec)
       
      MariaDB [test]> set session authorization ''@localhost;
      ERROR 1449 (HY000): The user ''@'localhost' does not exist
      

      It would be easier to understand if it were some "not allowed" error, but getting ER_NO_SUCH_USER when the user very clearly exists is just weird.

      WIth an empty host it's a bit different, because even though CREATE and GRANT accept the empty host name, they convert it into the wildcard '%', so it could be claimed that SET SESSION AUTHORIZATION doesn't make the adjustment and expects the value to be exact – still a weak argument, but more than one can say for the user name.

      MariaDB [test]> create or replace user 'x'@'';
      Query OK, 0 rows affected (0.013 sec)
       
      MariaDB [test]> show grants for 'x'@'';
      +-------------------------------+
      | Grants for x@%                |
      +-------------------------------+
      | GRANT USAGE ON *.* TO `x`@`%` |
      +-------------------------------+
      1 row in set (0.000 sec)
       
      MariaDB [test]> set session authorization 'x'@'';
      ERROR 1449 (HY000): The user 'x'@'' does not exist
      

      A strong argument could be that the SQL standard demands this behavior. I don't have access to the standard to check if it's so.

      Attachments

        Issue Links

          Activity

            There are no comments yet on this issue.

            People

              Unassigned Unassigned
              elenst Elena Stepanova
              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.