| 1 |
source include/not_embedded.inc; |
| 2 |
|
| 3 |
create role r1; |
| 4 |
create role r2; |
| 5 |
create role r3; |
| 6 |
create role r4; |
| 7 |
create user u1; |
| 8 |
|
| 9 |
#CREATE A CHAIN OF ROLES |
| 10 |
grant r2 to r1; |
| 11 |
grant r3 to r2; |
| 12 |
grant r4 to r3; |
| 13 |
grant r1 to u1; |
| 14 |
grant r4 to r1; |
| 15 |
|
| 16 |
--sorted_result |
| 17 |
show grants for u1; |
| 18 |
--sorted_result |
| 19 |
show grants for r1; |
| 20 |
|
| 21 |
grant SELECT on *.* to u1; |
| 22 |
grant INSERT on mysql.* to r1; |
| 23 |
grant DELETE on mysql.roles_mapping to r2; |
| 24 |
grant UPDATE on mysql.user to r3; |
| 25 |
|
| 26 |
create function mysql.test_func (s CHAR(20)) |
| 27 |
returns CHAR(50) DETERMINISTIC |
| 28 |
return concat('Test string: ',s); |
| 29 |
|
| 30 |
|
| 31 |
delimiter |; |
| 32 |
create procedure mysql.test_proc (OUT param1 INT) |
| 33 |
begin |
| 34 |
select COUNT(*) into param1 from mysql.roles_mapping; |
| 35 |
end| |
| 36 |
delimiter ;| |
| 37 |
|
| 38 |
grant execute on function mysql.test_func to r2; |
| 39 |
grant execute on procedure mysql.test_proc to r3; |
| 40 |
grant execute on mysql.* to r4; |
| 41 |
|
| 42 |
--sorted_result |
| 43 |
show grants for r1; |
| 44 |
--sorted_result |
| 45 |
show grants for r2; |
| 46 |
--sorted_result |
| 47 |
show grants for r3; |
| 48 |
--sorted_result |
| 49 |
show grants for r4; |
| 50 |
|
| 51 |
revoke all privileges, grant option from r4; |
| 52 |
|
| 53 |
--sorted_result |
| 54 |
show grants for r1; |
| 55 |
--sorted_result |
| 56 |
show grants for r2; |
| 57 |
--sorted_result |
| 58 |
show grants for r3; |
| 59 |
--sorted_result |
| 60 |
show grants for r4; |
| 61 |
|
| 62 |
revoke all privileges, grant option from r3; |
| 63 |
--sorted_result |
| 64 |
show grants for r1; |
| 65 |
--sorted_result |
| 66 |
show grants for r2; |
| 67 |
--sorted_result |
| 68 |
show grants for r3; |
| 69 |
--sorted_result |
| 70 |
show grants for r4; |
| 71 |
|
| 72 |
revoke all privileges, grant option from r2; |
| 73 |
--sorted_result |
| 74 |
show grants for r1; |
| 75 |
--sorted_result |
| 76 |
show grants for r2; |
| 77 |
--sorted_result |
| 78 |
show grants for r3; |
| 79 |
--sorted_result |
| 80 |
show grants for r4; |
| 81 |
|
| 82 |
revoke all privileges, grant option from r1; |
| 83 |
--sorted_result |
| 84 |
show grants for r1; |
| 85 |
--sorted_result |
| 86 |
show grants for r2; |
| 87 |
--sorted_result |
| 88 |
show grants for r3; |
| 89 |
--sorted_result |
| 90 |
show grants for r4; |
| 91 |
|
| 92 |
revoke all privileges, grant option from u1; |
| 93 |
|
| 94 |
show grants for u1; |
| 95 |
|
| 96 |
drop function mysql.test_func; |
| 97 |
drop procedure mysql.test_proc; |
| 98 |
|
| 99 |
--sorted_result |
| 100 |
show grants for r1; |
| 101 |
|
| 102 |
drop role r1, r2, r3, r4; |
| 103 |
drop user u1; |