[MDEV-6401] SET ROLE returning ERROR 1959 Invalid role specification for valid role Created: 2014-06-26  Updated: 2014-06-27  Resolved: 2014-06-27

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.12
Fix Version/s: 10.0.13

Type: Bug Priority: Major
Reporter: Michael Newcomb Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None
Environment:

Centos 6.5



 Description   

Cannot "SET ROLE" to a correctly-defined role that has been granted to an account. Seems to affect any account not defined as "@localhost"



 Comments   
Comment by Michael Newcomb [ 2014-06-26 ]

Executed as root, statements like:

create role WB_CLIENT;
 
grant execute on procedure badges.p_hubspotter_lookup to WB_CLIENT;
grant execute on procedure badges.p_wristband_lookup to WB_CLIENT;
grant execute on procedure badges.p_login to WB_CLIENT;
grant execute on procedure badges.p_hubspotter_list to WB_CLIENT;
grant execute on procedure badges.p_token_list to WB_CLIENT;
 
...
 
grant WB_CLIENT to 'wristband_client'@'10.%';

Log in as "wristband_client:"

mysql --user=wristband_client '--password=[password]' --host=[host]
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 164
Server version: 10.0.12-MariaDB MariaDB Server
 
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> use badges;
Database changed
MariaDB [badges]> show grants;
+--------------------------------------------------------------------------------------------------------------------------------------+
| Grants for wristband_client@10.%                                                                                                     |
+--------------------------------------------------------------------------------------------------------------------------------------+
| GRANT WB_CLIENT TO 'wristband_client'@'10.%'                                                                                         |
| GRANT CREATE TEMPORARY TABLES ON *.* TO 'wristband_client'@'10.%' IDENTIFIED BY PASSWORD '...' |
| GRANT SELECT ON `mysql`.`proc` TO 'wristband_client'@'10.%'                                                                          |
+--------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.02 sec)
 
MariaDB [badges]> set role WB_CLIENT;
ERROR 1959 (OP000): Invalid role specification `WB_CLIENT`.
MariaDB [badges]> select current_user();
+-----------------------+
| current_user()        |
+-----------------------+
| wristband_client@10.% |
+-----------------------+
1 row in set (0.03 sec)
 
MariaDB [badges]> SELECT * FROM INFORMATION_SCHEMA.APPLICABLE_ROLES;
+-----------------------+-----------+--------------+
| GRANTEE               | ROLE_NAME | IS_GRANTABLE |
+-----------------------+-----------+--------------+
| wristband_client@10.% | WB_CLIENT | NO           |
+-----------------------+-----------+--------------+
1 row in set (0.03 sec)

I have only ever been able to get SET ROLE to work if the account is defined as 'wristband_client'@'localhost'. Seen on two separate instances of MariaDB 10. This came from a freshly-installed instance (one week ago).

Comment by Elena Stepanova [ 2014-06-27 ]

MTR test case:

create role r1;
create user foo@'127.0.0.1';
grant r1 to foo@'127.0.0.1';
 
--connect (con1,127.0.0.1,foo,,)
show grants;
set role r1;

Generated at Thu Feb 08 07:11:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.