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 621cd574686 Enhance the support for MySQL SQL parsing in 
ShardingSphere (#31043)
621cd574686 is described below

commit 621cd5746869a6eb89737f66f85020cc50f2e6a7
Author: zhuruixuan <[email protected]>
AuthorDate: Sun Apr 28 16:34:10 2024 +0800

    Enhance the support for MySQL SQL parsing in ShardingSphere (#31043)
    
    * Added FIDO authentication support for MySQL, optimized user 
modifications, and improved keyword definitions.
    
    * Added FIDO authentication support for MySQL, optimized user 
modifications, and improved keyword definitions.
---
 .../mysql/src/main/antlr4/imports/mysql/DCLStatement.g4    | 14 +++++++++++++-
 .../mysql/src/main/antlr4/imports/mysql/MySQLKeyword.g4    |  8 ++++++++
 test/it/parser/src/main/resources/case/dcl/alter-user.xml  |  1 +
 .../src/main/resources/sql/supported/dcl/alter-user.xml    |  1 +
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git 
a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DCLStatement.g4 
b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DCLStatement.g4
index 8cc1d6d44d4..0d55d1e8196 100644
--- a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DCLStatement.g4
+++ b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DCLStatement.g4
@@ -135,7 +135,7 @@ accountLockPasswordExpireOption
     ;
 
 alterUser
-    : ALTER USER ifExists? alterUserList requireClause? connectOptions? 
accountLockPasswordExpireOptions?
+    : ALTER USER ifExists? alterUserList requireClause? connectOptions? 
accountLockPasswordExpireOptions? alterOperation?
     | ALTER USER ifExists? USER LP_ RP_ userFuncAuthOption
     | ALTER USER ifExists? username DEFAULT ROLE (NONE | ALL | roleName 
(COMMA_ roleName)*)
     ;
@@ -148,6 +148,18 @@ alterUserList
     : alterUserEntry (COMMA_ alterUserEntry)*
     ;
 
+alterOperation
+    : (ADD | MODIFY | DROP | SET) factoryOperation
+    ;
+
+factoryOperation
+    : NUMBER_ FACTOR (IDENTIFIED WITH authentication_fido)?
+    ;
+
+authentication_fido
+    : AUTHENTICATION_FIDO
+    ;
+
 dropUser
     : DROP USER ifExists? username (COMMA_ username)*
     ;
diff --git 
a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/MySQLKeyword.g4 
b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/MySQLKeyword.g4
index 18118be32e8..66dbaa252c9 100644
--- a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/MySQLKeyword.g4
+++ b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/MySQLKeyword.g4
@@ -3149,3 +3149,11 @@ ZONE
 TIMESTAMPDIFF
     : T I M E S T A M P D I F F
     ;
+
+AUTHENTICATION_FIDO
+    : A U T H E N T I C A T I O N UL_ F I D O
+    ;
+
+FACTOR
+    : F A C T O R
+    ;
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 f9e12310a45..701d2a4deab 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
@@ -69,4 +69,5 @@
     <alter-user sql-case-id="alter_azure_ad_user_without_login" />
     <alter-user sql-case-id="alter_user_alias_to_existing_azure_id" />
     <alter-user sql-case-id="alter_user_identified_with_single_quoted" />
+    <alter-user sql-case-id="alter_user_with_factor" />
 </sql-parser-test-cases>
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 86e576f4cf4..1c7325eccd3 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
@@ -69,4 +69,5 @@
     <sql-case id="alter_azure_ad_user_without_login" value="ALTER USER 
[westus/joe] FROM EXTERNAL PROVIDER" db-types="SQLServer" />
     <sql-case id="alter_user_alias_to_existing_azure_id" value="ALTER USER 
[westus/joe] WITH LOGIN = [email protected], name= joe_alias" 
db-types="SQLServer" />
     <sql-case id="alter_user_identified_with_single_quoted" value="ALTER USER 
tu1@localhost IDENTIFIED WITH 'sha256_password' REQUIRE CIPHER 
&quot;DHE-RSA-AES256-SHA&quot;" db-types="MySQL" />
+    <sql-case id="alter_user_with_factor" value="ALTER USER 
'alice'@'localhost' MODIFY 2 FACTOR IDENTIFIED WITH authentication_fido" 
db-types="MySQL" />
 </sql-cases>

Reply via email to