DBZ-5271 Support set role statement for mysql8

This commit is contained in:
harveyyue 2022-06-20 09:54:15 +08:00 committed by Jiri Pechanec
parent 0924256a8a
commit a608569217
4 changed files with 27 additions and 3 deletions

View File

@ -63,7 +63,7 @@ ddlStatement
| dropDatabase | dropEvent | dropIndex
| dropLogfileGroup | dropProcedure | dropFunction
| dropServer | dropTable | dropTablespace
| dropTrigger | dropView
| dropTrigger | dropView | dropRole | setRole
| renameTable | truncateTable
;
@ -183,7 +183,7 @@ createFunction
;
createRole
: CREATE ROLE (IF NOT EXISTS)? roleName
: CREATE ROLE (IF NOT EXISTS)? roleName (',' roleName)*
;
createServer
@ -755,6 +755,15 @@ dropView
fullId (',' fullId)* dropType=(RESTRICT | CASCADE)?
;
dropRole
: DROP ROLE ifExists? roleName (',' roleName)*
;
setRole
: SET DEFAULT ROLE (NONE | ALL | roleName (',' roleName)*)
TO (userName | uid) (',' (userName | uid))*
| SET ROLE roleOption
;
// Other DDL statements
@ -2002,7 +2011,7 @@ tableName
;
roleName
: uid
: userName | uid
;
fullColumnName

View File

@ -452,6 +452,8 @@ END; -- //-- delimiter ;
-- Create Role
create role 'RL_COMPLIANCE_NSA';
create role if not exists 'RL_COMPLIANCE_NSA';
CREATE ROLE 'admin', 'developer';
CREATE ROLE 'webapp'@'localhost';
#end
#begin
CREATE VIEW view_with_cte1 AS

View File

@ -66,3 +66,8 @@ drop function if exists foo;
drop function bar;
#end
#begin
-- Drop Role
DROP ROLE 'admin', 'developer';
DROP ROLE 'webapp'@'localhost';
#end

View File

@ -103,3 +103,11 @@ GRANT FEDERATED_ADMIN ON *.* TO 'mysqluser'@'localhost'
GRANT READ_ONLY_ADMIN ON *.* TO 'mysqluser'@'localhost'
GRANT REPLICATION_MASTER_ADMIN ON *.* TO 'mysqluser'@'localhost'
GRANT REPLICATION REPLICA ON *.* TO 'mysqluser'@'localhost'
-- Set Role
SET ROLE DEFAULT;
SET ROLE 'role1', 'role2';
SET ROLE ALL;
SET ROLE ALL EXCEPT 'role1', 'role2';
-- Set Default Role
SET DEFAULT ROLE 'admin', 'developer' TO 'joe'@'10.0.0.1';
SET DEFAULT ROLE `admin`@'%' to `dt_user`@`%`;