diff --git a/mysql-test/suite/roles/prepare_stmt_with_role.result b/mysql-test/suite/roles/prepare_stmt_with_role.result index 71dffaafa92..e859b2e304b 100644 --- a/mysql-test/suite/roles/prepare_stmt_with_role.result +++ b/mysql-test/suite/roles/prepare_stmt_with_role.result @@ -20,12 +20,17 @@ Grants for root@localhost GRANT developers TO 'root'@'localhost' WITH ADMIN OPTION GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION +# Test reexecution. +EXECUTE stmtCreateRole; +ERROR HY000: Operation CREATE ROLE failed for 'developers' # # Now grant the role to the test user. # SET @grantRole = 'GRANT developers to test_user'; PREPARE stmtGrantRole FROM @grantRole; EXECUTE stmtGrantRole; +# Test reexecution. +EXECUTE stmtGrantRole; # # We should see 2 entries in the roles_mapping table. # @@ -43,6 +48,17 @@ GRANT USAGE ON *.* TO 'test_user'@'%' SET @revokeRole = 'REVOKE developers FROM test_user'; PREPARE stmtRevokeRole FROM @revokeRole; EXECUTE stmtRevokeRole; +EXECUTE stmtRevokeRole; +ERROR HY000: Cannot revoke role 'developers' from: 'test_user'@'%'. +SHOW GRANTS FOR test_user; +Grants for test_user@% +GRANT USAGE ON *.* TO 'test_user'@'%' +EXECUTE stmtGrantRole; +SHOW GRANTS FOR test_user; +Grants for test_user@% +GRANT developers TO 'test_user'@'%' +GRANT USAGE ON *.* TO 'test_user'@'%' +EXECUTE stmtRevokeRole; SHOW GRANTS FOR test_user; Grants for test_user@% GRANT USAGE ON *.* TO 'test_user'@'%' @@ -67,5 +83,25 @@ GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION SHOW GRANTS FOR test_user; Grants for test_user@% GRANT USAGE ON *.* TO 'test_user'@'%' +# +# Test reexecution. +# +EXECUTE stmtCreateRole; +SELECT user, host,is_role FROM mysql.user +WHERE user = 'developers'; +user host is_role +developers Y +SELECT * FROM mysql.roles_mapping; +Host User Role Admin_option +localhost root developers Y +SHOW GRANTS; +Grants for root@localhost +GRANT developers TO 'root'@'localhost' WITH ADMIN OPTION +GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION +GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION +SHOW GRANTS FOR test_user; +Grants for test_user@% +GRANT USAGE ON *.* TO 'test_user'@'%' +EXECUTE stmtDropRole; # Cleanup. DROP USER test_user; diff --git a/mysql-test/suite/roles/prepare_stmt_with_role.test b/mysql-test/suite/roles/prepare_stmt_with_role.test index be2c92b3e36..516e9ddab34 100644 --- a/mysql-test/suite/roles/prepare_stmt_with_role.test +++ b/mysql-test/suite/roles/prepare_stmt_with_role.test @@ -18,12 +18,18 @@ SELECT user, host,is_role FROM mysql.user WHERE user = 'developers'; SHOW GRANTS; +--echo # Test reexecution. +--error ER_CANNOT_USER +EXECUTE stmtCreateRole; + --echo # --echo # Now grant the role to the test user. --echo # SET @grantRole = 'GRANT developers to test_user'; PREPARE stmtGrantRole FROM @grantRole; EXECUTE stmtGrantRole; +--echo # Test reexecution. +EXECUTE stmtGrantRole; --echo # --echo # We should see 2 entries in the roles_mapping table. @@ -38,7 +44,13 @@ SHOW GRANTS FOR test_user; SET @revokeRole = 'REVOKE developers FROM test_user'; PREPARE stmtRevokeRole FROM @revokeRole; EXECUTE stmtRevokeRole; +--error ER_CANNOT_REVOKE_ROLE +EXECUTE stmtRevokeRole; +SHOW GRANTS FOR test_user; +EXECUTE stmtGrantRole; +SHOW GRANTS FOR test_user; +EXECUTE stmtRevokeRole; SHOW GRANTS FOR test_user; --echo # @@ -57,5 +69,17 @@ SELECT * FROM mysql.roles_mapping; SHOW GRANTS; SHOW GRANTS FOR test_user; +--echo # +--echo # Test reexecution. +--echo # +EXECUTE stmtCreateRole; +SELECT user, host,is_role FROM mysql.user +WHERE user = 'developers'; +SELECT * FROM mysql.roles_mapping; + +SHOW GRANTS; +SHOW GRANTS FOR test_user; +EXECUTE stmtDropRole; + --echo # Cleanup. DROP USER test_user;