1use mysql;
2insert db (db,user,select_priv) values ('foo','dwr_foo','Y'), ('bar','dwr_bar','Y');
3insert roles_mapping (user,role) values ('dwr_qux_dev','dwr_foo'),('dwr_qux_dev','dwr_bar');
4insert ignore user (user,show_db_priv,is_role) values ('dwr_foo','N','Y'), ('dwr_bar','N','Y'), ('dwr_qux_dev','Y','Y');
5Warnings:
6Warning	1364	Field 'ssl_cipher' doesn't have a default value
7Warning	1364	Field 'x509_issuer' doesn't have a default value
8Warning	1364	Field 'x509_subject' doesn't have a default value
9Warning	1364	Field 'authentication_string' doesn't have a default value
10flush privileges;
11drop role dwr_foo;
12drop role dwr_bar;
13drop role dwr_qux_dev;
14use test;
15create table db_copy as select * from mysql.db;
16delete from mysql.db;
17flush privileges;
18create user u1@localhost;
19create role r1;
20create role r2;
21grant r1 to u1@localhost;
22grant select on test.* to r2;
23grant select on m_.* to r2;
24grant r2 to r1;
25show grants for u1@localhost;
26Grants for u1@localhost
27GRANT `r1` TO `u1`@`localhost`
28GRANT USAGE ON *.* TO `u1`@`localhost`
29show grants for r1;
30Grants for r1
31GRANT `r2` TO `r1`
32GRANT USAGE ON *.* TO `r1`
33GRANT USAGE ON *.* TO `r2`
34GRANT SELECT ON `test`.* TO `r2`
35GRANT SELECT ON `m_`.* TO `r2`
36drop user u1@localhost;
37drop role r1, r2;
38insert mysql.db select * from db_copy;
39flush privileges;
40drop table db_copy;
41