You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/10/05 01:25:03 UTC

[shardingsphere] branch master updated: Support Parsing `ALTER ROLE` in Oracle (#21340)

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 389d98bccdc Support Parsing `ALTER ROLE` in Oracle (#21340)
389d98bccdc is described below

commit 389d98bccdca6766662707b5a505e43a4e534a3c
Author: Everly Precia Suresh <77...@users.noreply.github.com>
AuthorDate: Wed Oct 5 06:54:45 2022 +0530

    Support Parsing `ALTER ROLE` in Oracle (#21340)
    
    * SUPPORT PARSING ALTER ROLE IN ORACLE
    
    * Fix testcase
---
 .../src/main/antlr4/imports/oracle/DCLStatement.g4                | 6 +++++-
 .../src/main/antlr4/imports/oracle/OracleKeyword.g4               | 8 ++++++++
 .../apache/shardingsphere/sql/parser/autogen/OracleStatement.g4   | 1 +
 .../src/main/resources/case/dcl/alter-role.xml                    | 2 +-
 .../src/main/resources/sql/supported/dcl/alter-role.xml           | 2 +-
 5 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DCLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DCLStatement.g4
index 1cc6dfba647..8b039d845b7 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DCLStatement.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DCLStatement.g4
@@ -319,7 +319,11 @@ dropRole
     ;
 
 alterRole
-    : ALTER ROLE
+    : ALTER ROLE roleName ( NOT IDENTIFIED | IDENTIFIED (
+    | BY password 
+    | USING packageName 
+    | EXTERNALLY 
+    | GLOBALLY AS (STRING_ | SQ_ AZURE_ROLE EQ_ identifier SQ_ | SQ_ IAM_GROUP_NAME EQ_ identifier SQ_) ) ) (CONTAINER EQ_ (CURRENT | ALL))?
     ;
 
 setRole
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
index 2a7e0dc4238..f94c362fafb 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
@@ -3072,6 +3072,14 @@ CONNECT_TIME
     : C O N N E C T UL_ T I M E
     ;
 
+AZURE_ROLE
+    : A Z U R E UL_ R O L E
+    ;
+
+IAM_GROUP_NAME
+    : I A M UL_ G R O U P UL_ N A M E
+    ;
+
 LOGICAL_READS_PER_SESSION
     : L O G I C A L UL_ R E A D S UL_ P E R UL_ S E S S I O N
     ;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
index 0a6a3b1f0d3..e8e2b7e7ee2 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
@@ -133,5 +133,6 @@ execute
     | dropMaterializedViewLog
     | dropMaterializedZonemap
     | alterResourceCost
+    | alterRole
     ) SEMI_?
     ;
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dcl/alter-role.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dcl/alter-role.xml
index 0e2738e1006..ad10c0c65ba 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dcl/alter-role.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dcl/alter-role.xml
@@ -19,7 +19,7 @@
 <sql-parser-test-cases>
     <alter-role sql-case-id="alter_no_identified_role" />
     <alter-role sql-case-id="alter_external_role" />
-    <alter-role sql-case-id="alter_global_role" />
+    <alter-role sql-case-id="alter_role_globally"/>
     <alter-role sql-case-id="alter_role_with_password" />
     <alter-role sql-case-id="alter_role_with_container" />
     <alter-role sql-case-id="alter_role_with_password_postgresql" />
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dcl/alter-role.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dcl/alter-role.xml
index ed596d7ef9f..eefd06d1f54 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dcl/alter-role.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dcl/alter-role.xml
@@ -19,7 +19,7 @@
 <sql-cases>
     <sql-case id="alter_no_identified_role" value="ALTER ROLE role1 NOT IDENTIFIED" db-types="Oracle" />
     <sql-case id="alter_external_role" value="ALTER ROLE role1 IDENTIFIED EXTERNALLY" db-types="Oracle" />
-    <sql-case id="alter_global_role" value="ALTER ROLE role1 IDENTIFIED GLOBALLY" db-types="Oracle" />
+    <sql-case id="alter_role_globally" value="ALTER ROLE role1 IDENTIFIED GLOBALLY AS 'AZURE_ROLE = accountant'" db-types="Oracle" />
     <sql-case id="alter_role_with_password" value="ALTER ROLE role1 IDENTIFIED BY password" db-types="Oracle" />
     <sql-case id="alter_role_with_container" value="ALTER ROLE role1 NOT IDENTIFIED CONTAINER = ALL" db-types="Oracle" />
     <sql-case id="alter_role_with_password_postgresql" value="ALTER ROLE role1 WITH ENCRYPTED PASSWORD 'password'" db-types="PostgreSQL,openGauss" />