This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 018edf1cb7f Support parsing Oracle GRANT CREATE sql (#27911)
018edf1cb7f is described below

commit 018edf1cb7fd0d30d842d017e8a47a696a59360f
Author: Swapnil Patil <[email protected]>
AuthorDate: Sat Aug 12 00:12:45 2023 -0700

    Support parsing Oracle GRANT CREATE sql (#27911)
    
    * Support parsing Oracle GRANT CREATE sql
    
    * Support parsing Oracle GRANT CREATE sql
---
 .../oracle/src/main/antlr4/imports/oracle/DCLStatement.g4        | 9 +++++++++
 test/it/parser/src/main/resources/case/dcl/alter-user.xml        | 1 +
 test/it/parser/src/main/resources/case/dcl/grant.xml             | 1 +
 .../parser/src/main/resources/sql/supported/dcl/alter-user.xml   | 1 +
 .../parser/src/main/resources/sql/supported/dcl/grant-user.xml   | 1 +
 5 files changed, 13 insertions(+)

diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DCLStatement.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DCLStatement.g4
index 4651eaa5e64..6fae13fe007 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DCLStatement.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DCLStatement.g4
@@ -118,6 +118,7 @@ systemPrivilege
     | usersSystemPrivilege
     | viewsSystemPrivilege
     | miscellaneousSystemPrivilege
+    | ruleSystemPrivilege
     ;
 
 systemPrivilegeOperation
@@ -288,6 +289,14 @@ usersSystemPrivilege
     : systemPrivilegeOperation USER
     ;
 
+ruleSystemPrivilege
+    : createOperation* TO username
+    ;
+
+createOperation
+    : systemPrivilegeOperation (RULE SET? | EVALUATION CONTEXT) COMMA_?
+    ;
+
 viewsSystemPrivilege
     : (systemPrivilegeOperation | (UNDER | MERGE) ANY) VIEW
     ;
diff --git a/test/it/parser/src/main/resources/case/dcl/alter-user.xml 
b/test/it/parser/src/main/resources/case/dcl/alter-user.xml
index 876d202dc4e..f9e12310a45 100644
--- a/test/it/parser/src/main/resources/case/dcl/alter-user.xml
+++ b/test/it/parser/src/main/resources/case/dcl/alter-user.xml
@@ -44,6 +44,7 @@
     <alter-user sql-case-id="alter_user_expire_with_options" />
     <alter-user sql-case-id="alter_user_grant_proxy" />
     <alter-user sql-case-id="alter_user_grant_proxy_with_option" />
+    <alter-user sql-case-id="alter_user_default_role" />
     <alter-user sql-case-id="alter_user_revoke_proxy" />
     <alter-user sql-case-id="alter_user_proxys" />
     <alter-user sql-case-id="alter_user_with_password_postgresql" />
diff --git a/test/it/parser/src/main/resources/case/dcl/grant.xml 
b/test/it/parser/src/main/resources/case/dcl/grant.xml
index 1c1f6fa959d..399c7b0f2ef 100644
--- a/test/it/parser/src/main/resources/case/dcl/grant.xml
+++ b/test/it/parser/src/main/resources/case/dcl/grant.xml
@@ -104,6 +104,7 @@
     
     <grant sql-case-id="grant_program" />
     <grant sql-case-id="grant_roles_to_programs" />
+    <grant sql-case-id="grant_create_rule_to_user" />
     
     <grant sql-case-id="grant_all_on_table_to_roles">
         <table name="t_order" start-index="30" stop-index="36" />
diff --git a/test/it/parser/src/main/resources/sql/supported/dcl/alter-user.xml 
b/test/it/parser/src/main/resources/sql/supported/dcl/alter-user.xml
index 049f7e87821..86e576f4cf4 100644
--- a/test/it/parser/src/main/resources/sql/supported/dcl/alter-user.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dcl/alter-user.xml
@@ -44,6 +44,7 @@
     <sql-case id="alter_user_expire_with_options" value="ALTER USER user1 
PASSWORD EXPIRE ACCOUNT LOCK" db-types="Oracle" />
     <sql-case id="alter_user_grant_proxy" value="ALTER USER user1 GRANT 
CONNECT THROUGH user2" db-types="Oracle" />
     <sql-case id="alter_user_grant_proxy_with_option" value="ALTER USER user1 
GRANT CONNECT THROUGH user2 WITH ROLE role1" db-types="Oracle" />
+    <sql-case id="alter_user_default_role" value="ALTER USER johndoe DEFAULT 
ROLE clerk_role" db-types="Oracle" />
     <sql-case id="alter_user_revoke_proxy" value="ALTER USER user1 REVOKE 
CONNECT THROUGH user2" db-types="Oracle" />
     <sql-case id="alter_user_proxys" value="ALTER USER user1 GRANT CONNECT 
THROUGH user2 REVOKE CONNECT THROUGH user3" db-types="Oracle" />
     <sql-case id="alter_user_with_password_postgresql" value="ALTER USER user1 
WITH ENCRYPTED PASSWORD 'password'" db-types="PostgreSQL,openGauss" />
diff --git a/test/it/parser/src/main/resources/sql/supported/dcl/grant-user.xml 
b/test/it/parser/src/main/resources/sql/supported/dcl/grant-user.xml
index cf7df56d6af..936e78f23d4 100644
--- a/test/it/parser/src/main/resources/sql/supported/dcl/grant-user.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dcl/grant-user.xml
@@ -46,6 +46,7 @@
     <sql-case id="grant_object_privilege_column" value="GRANT SELECT 
(order_id) ON ds_0.t_order TO user1" db-types="Oracle" />
     <sql-case id="grant_program" value="GRANT role1 TO FUNCTION 
ds_0.function1" db-types="Oracle" />
     <sql-case id="grant_roles_to_programs" value="GRANT role1, role2 TO 
FUNCTION ds_0.function1, FUNCTION ds_0.function2" db-types="Oracle" />
+    <sql-case id="grant_create_rule_to_user" value="GRANT CREATE ANY RULE, 
CREATE ANY RULE SET, CREATE ANY EVALUATION CONTEXT TO johndoe" 
db-types="Oracle" />
     <sql-case id="grant_all_on_table_to_roles" value="GRANT ALL PRIVILEGES ON 
TABLE t_order TO role1, role2" db-types="PostgreSQL,openGauss" />
     <sql-case id="grant_all_on_table_to_current_user" value="GRANT ALL 
PRIVILEGES ON TABLE t_order TO CURRENT_USER" db-types="PostgreSQL,openGauss" />
     <sql-case id="grant_select_on_tables" value="GRANT SELECT ON TABLE 
t_order, t_order_item TO role1" db-types="PostgreSQL,openGauss" />

Reply via email to