1source include/not_embedded.inc; 2 3create user foo@localhost; 4grant create user on *.* to foo@localhost; 5 6######################################## 7# syntax tests 8######################################## 9 10create role role1; 11create role role2 with admin current_user; 12--error ER_MALFORMED_DEFINER 13create role role3 with admin current_role; 14create role role3 with admin role1; 15create role role4 with admin root@localhost; 16 17# privilege checks, one needs SUPER to specify an arbitrary admin 18connect (c1, localhost, foo,,); 19--error ER_SPECIFIC_ACCESS_DENIED_ERROR 20create role role5 with admin root@localhost; 21--error ER_SPECIFIC_ACCESS_DENIED_ERROR 22create role role5 with admin role3; 23create role role5 with admin foo@localhost; 24 25connection default; 26# non-existing admin. works. warning. error in the log on acl_load. 27call mtr.add_suppression("Invalid roles_mapping table entry user:'foo@bar', rolename:'role6'"); 28create role role6 with admin foo@bar; 29 30--error ER_PARSE_ERROR 31create user bar with admin current_user; 32 33grant role1 to foo@localhost with admin option; 34grant role2 to foo@localhost; 35grant role2 to role1; 36grant role4 to role3 with admin option; 37--error ER_PARSE_ERROR 38grant select on *.* to foo@localhost with admin option; 39 40--sorted_result 41show grants for foo@localhost; 42--sorted_result 43show grants for role1; 44--sorted_result 45show grants for role4; 46--sorted_result 47select * from mysql.roles_mapping; 48flush privileges; 49--sorted_result 50show grants for foo@localhost; 51--sorted_result 52show grants for role1; 53--sorted_result 54show grants for role4; 55--sorted_result 56select * from information_schema.applicable_roles; 57 58grant role2 to role1 with admin option; 59revoke role1 from foo@localhost; 60revoke admin option for role4 from role3; 61revoke admin option for role2 from foo@localhost; 62revoke admin option for role1 from root@localhost; 63 64--sorted_result 65show grants for foo@localhost; 66--sorted_result 67show grants for role1; 68--sorted_result 69show grants for role4; 70--sorted_result 71select * from mysql.roles_mapping; 72flush privileges; 73--sorted_result 74show grants for foo@localhost; 75--sorted_result 76show grants for role1; 77--sorted_result 78show grants for role4; 79--sorted_result 80select * from information_schema.applicable_roles; 81 82# Now, root@localhost don't have admin option for role1: 83--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR 84grant role1 to role4; 85--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR 86grant role1 to role4 with admin option; 87# but role3 is grantable 88grant role3 to role2; 89revoke role3 from role2; 90 91# now, a diamond 92grant role4 to role2 with admin option; 93revoke role2 from current_user; 94revoke role4 from current_user; 95grant role4 to current_user; 96 97 98######################################## 99# cleanup 100######################################## 101drop role role1, role2, role3, role4, role5, role6; 102drop user foo@localhost; 103