create user foo;
create role role1;
create role role2;
create role role3;
grant role1 to foo;
grant role2 to role1;
grant role3 to foo;
connect  foo, localhost, foo;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
foo@%	role1	NO	NO
foo@%	role3	NO	NO
role1	role2	NO	NULL
set default role role3;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
foo@%	role1	NO	NO
foo@%	role3	NO	YES
role1	role2	NO	NULL
set default role role1;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
foo@%	role1	NO	YES
foo@%	role3	NO	NO
role1	role2	NO	NULL
disconnect foo;
connection default;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
role1	role2	NO	NULL
root@localhost	role1	YES	NO
root@localhost	role2	YES	NO
root@localhost	role3	YES	NO
set default role none for foo;
connect  foo, localhost, foo;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
foo@%	role1	NO	NO
foo@%	role3	NO	NO
role1	role2	NO	NULL
disconnect foo;
connection default;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
role1	role2	NO	NULL
root@localhost	role1	YES	NO
root@localhost	role2	YES	NO
root@localhost	role3	YES	NO
set default role role1;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
role1	role2	NO	NULL
root@localhost	role1	YES	YES
root@localhost	role2	YES	NO
root@localhost	role3	YES	NO
set default role role2;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
role1	role2	NO	NULL
root@localhost	role1	YES	NO
root@localhost	role2	YES	YES
root@localhost	role3	YES	NO
set default role role3;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
role1	role2	NO	NULL
root@localhost	role1	YES	NO
root@localhost	role2	YES	NO
root@localhost	role3	YES	YES
set default role none;
select * from information_schema.applicable_roles;
GRANTEE	ROLE_NAME	IS_GRANTABLE	IS_DEFAULT
role1	role2	NO	NULL
root@localhost	role1	YES	NO
root@localhost	role2	YES	NO
root@localhost	role3	YES	NO
drop role role3;
drop role role2;
drop role role1;
drop user foo;
update mysql.global_priv set priv=json_compact(json_remove(priv, '$.default_role'));
