1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Reworked the implementation of create role and drop role.

Also fixed issue with drop role not clearing internal memory entry
for that role. The issue was due to a condition introduced in handle_grant_data

Updated testsuite to also check the possible error conditions.
This commit is contained in:
Vicențiu Ciorbaru
2013-10-18 05:41:25 -07:00
committed by Sergei Golubchik
parent db850c525f
commit ce4851c3d0
6 changed files with 118 additions and 195 deletions

View File

@ -1,8 +1,15 @@
use mysql;
create role test_role1@host1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@host1' at line 1
create role test_role2@host2, test_role1@host1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@host2, test_role1@host1' at line 1
create role test_role1;
create role test_role2, test_role3;
select user, host, is_role from user where user like 'test';
select user, host, is_role from user where user like 'test%';
user host is_role
test_role1 Y
test_role2 Y
test_role3 Y
drop role test_role1;
drop role test_role2, test_role3;
create role test_role1;
@ -10,12 +17,20 @@ create role test_role1;
ERROR HY000: Operation CREATE ROLE failed for 'test_role1'
create role test_role1, test_role2;
ERROR HY000: Operation CREATE ROLE failed for 'test_role1'
select user, host, is_role from user where user like 'test';
select user, host, is_role from user where user like 'test%';
user host is_role
test_role1 Y
test_role2 Y
drop role test_role1;
drop role test_role1;
ERROR HY000: Operation DROP ROLE failed for 'test_role1'
drop role test_role1, test_role2;
ERROR HY000: Operation DROP ROLE failed for 'test_role1'
select user, host, is_role from user where user like 'test';
drop role root;
ERROR HY000: Operation DROP ROLE failed for 'root'
create user dummy@'';
drop role dummy;
ERROR HY000: Operation DROP ROLE failed for 'dummy'
drop user dummy@'';
select user, host, is_role from user where user like 'test%';
user host is_role

View File

@ -1,11 +1,17 @@
connect (mysql, localhost, root,,);
use mysql;
#test valid syntax
--error ER_PARSE_ERROR
create role test_role1@host1;
--error ER_PARSE_ERROR
create role test_role2@host2, test_role1@host1;
create role test_role1;
create role test_role2, test_role3;
--sorted_result
select user, host, is_role from user where user like 'test';
select user, host, is_role from user where user like 'test%';
drop role test_role1;
drop role test_role2, test_role3;
@ -18,7 +24,7 @@ create role test_role1;
create role test_role1, test_role2;
--sorted_result
select user, host, is_role from user where user like 'test';
select user, host, is_role from user where user like 'test%';
drop role test_role1;
--error ER_CANNOT_USER
@ -26,6 +32,14 @@ drop role test_role1;
--error ER_CANNOT_USER
drop role test_role1, test_role2;
#test that we can not drop users when calling drop role
--error ER_CANNOT_USER
drop role root;
create user dummy@'';
--error ER_CANNOT_USER
drop role dummy;
drop user dummy@'';
--sorted_result
select user, host, is_role from user where user like 'test';
select user, host, is_role from user where user like 'test%';
disconnect mysql;