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 4a550ba2378 Support parsing MySQL stored procedure syntax - part 3 
(#35503)
4a550ba2378 is described below

commit 4a550ba2378c0dca5a91afbe0a228d42987dd977
Author: theNorthWindBlow <104822140+thenorthwindb...@users.noreply.github.com>
AuthorDate: Tue Aug 5 13:50:49 2025 +0800

    Support parsing MySQL stored procedure syntax - part 3 (#35503)
    
    * Support parsing MySQL stored procedure syntax part3
    
    * Add GraalVM Reachability Metadata and corresponding nativeTest for Presto 
Iceberg Connector (#35504)
    
    * Fix binding method in ProxyBackendHandlerFactory to include database type 
(#35506)
    
    * Add doc for Presto optional plugin (#35505)
    
    * Fix binding method in ProxyBackendHandlerFactory to include database type 
(#35507)
    
    * Refactor MySQLComStmtPrepareExecutor to use a class-level databaseType 
variable (#35508)
    
    * Optimize MySQLComFieldListPacketExecutor with DatabaseType (#35509)
    
    - Add a private final DatabaseType field initialized with "MySQL"
    - Replace inline DatabaseType retrieval with the new field for better 
readability and performance
    
    * Optimize MySQL multi-statements handling (#35510)
    
    - Extract DatabaseType instance as a private field to improve performance
    - Update SQLParserEngine initialization to use the pre-loaded DatabaseType
    - Modify SQLBindEngine invocation to include DatabaseType as a parameter
    
    * Add database type parameter to SQLBindEngine.bind method (#35511)
    
    * Optimize MySQL multi-statements handling
    
    - Extract DatabaseType instance as a private field to improve performance
    - Update SQLParserEngine initialization to use the pre-loaded DatabaseType
    - Modify SQLBindEngine invocation to include DatabaseType as a parameter
    
    * Add database type parameter to SQLBindEngine.bind method
    - Update the SQLBindEngine.bind method call to include the databaseType 
parameter
    - This change ensures that the database type is properly passed during SQL 
statement binding
    
    * Refactor PostgreSQLComParseExecutor to utilize DatabaseType in SQL parser 
engine creation (#35512)
    
    * Refactor PostgreSQLComDescribeExecutor to use ShardingSphereMetaData for 
SQL statement binding (#35513)
    
    * Support set datasource properties type with java.time.Duration (#34667) 
(#35241)
    
    * Fix PostgreSQLComDescribeExecutorTest (#35514)
    
    * Refactor PostgreSQLComDescribeExecutor to use ShardingSphereMetaData for 
SQL statement binding
    
    * Fix PostgreSQLComDescribeExecutorTest
    
    * Update release notes (#35515)
    
    * Refactor PostgreSQLBatchedStatementsExecutor to use database type 
consistently (#35516)
    
    * Refactor MySQLComFieldListPacketExecutor to use database type 
consistently (#35517)
    
    * Refactor PostgreSQLBatchedStatementsExecutor to use database type 
consistently
    
    * Refactor MySQLComFieldListPacketExecutor to use database type consistently
    
    * Refactor MySQLComFieldListPacketExecutor to use database type consistently
    
    * Refactor UnicastResourceShowExecutor to use database type consistently 
(#35518)
    
    * Refactor PreviewExecutor to use database type consistently (#35519)
    
    * Refactor SQL parsing to use DatabaseType consistently on 
ShardingSpherePreparedStatement and ShardingSphereStatement (#35520)
    
    * Add database type parameter to SQLBindEngine.bind method (#35521)
    
    - Update SQLBindEngine.bind method signature to include DatabaseType 
parameter
    - Modify test cases in various modules to pass DatabaseType to the bind 
method
    - This change enables more precise handling of database-specific SQL 
statements
    
    * Update RELEASE-NOTES.md
    
    This update is for Support parsing MySQL stored procedure syntax-part 3 
#35503
    
    ---------
    
    Co-authored-by: zhangyuanxing <zhangyuanxin...@meituan.com>
    Co-authored-by: Ling Hengqian <linghengq...@outlook.com>
    Co-authored-by: Liang Zhang <zhangli...@apache.org>
    Co-authored-by: null <466144...@qq.com>
---
 RELEASE-NOTES.md                                    |  1 +
 .../mysql/src/main/antlr4/imports/mysql/BaseRule.g4 |  4 ++--
 .../src/main/antlr4/imports/mysql/DDLStatement.g4   |  3 ++-
 .../main/resources/case/ddl/create-procedure.xml    | 21 +++++++++++++++++++++
 .../sql/supported/ddl/create-procedure.xml          |  3 +++
 5 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 73f8ba55f57..73f84be5044 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -41,6 +41,7 @@
 1. SQL Parser: Support Doris CREATE MATERIALIZED VIEW - 
[#31499](https://github.com/apache/shardingsphere/pull/31499)
 1. SQL Parser: Enhance combineType in Oracle to support EXCEPT ALL and 
INTERSECT ALL - [#35099](https://github.com/apache/shardingsphere/pull/35099)
 1. SQL Parser: Support parsing MySQL stored procedure syntax - 
[#35137](https://github.com/apache/shardingsphere/pull/35137), 
[#35441](https://github.com/apache/shardingsphere/pull/35441)
+1. SQL Parser: Support parsing MySQL stored procedure syntax - 
[#35503](https://github.com/apache/shardingsphere/pull/35503/files)
 1. SQL Parser: Support Oracle SQL parsing V1 keywords as identifiers - 
[#35373](https://github.com/apache/shardingsphere/pull/35373)
 1. SQL Parser: Support Oracle in literal sql parsing - 
[#35384](https://github.com/apache/shardingsphere/pull/35384)
 1. SQL Parser: Add MySQL interval expression sql parsing - 
[#35468](https://github.com/apache/shardingsphere/pull/35468)
diff --git a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4 
b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
index 83c5ab9fa7a..2e4b7b57a39 100644
--- a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
+++ b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
@@ -865,8 +865,8 @@ charsetWithOptBinary
     : ascii
     | unicode
     | BYTE
-    | charset charsetName BINARY?
-    | BINARY (charset charsetName)?
+    | charset charsetName collateClause? BINARY?
+    | BINARY (charset charsetName collateClause?)?
     ;
 
 ascii
diff --git 
a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DDLStatement.g4 
b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
index fd56fa6146d..ae78ec4c370 100644
--- a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
+++ b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
@@ -682,7 +682,8 @@ validStatement
     | insert | replace | update | delete | select | call
     | createView | prepare | executeStmt | commit | deallocate
     | setVariable | beginStatement | declareStatement | flowControlStatement | 
cursorStatement | conditionHandlingStatement
-    | setStatement | showStatement | showCreateTable | startTransaction | 
rollback | commit | show) SEMI_?
+    | setStatement | showStatement | showCreateTable | startTransaction | 
rollback | commit | show
+    | alterEvent | dropEvent) SEMI_?
     ;
 
 showStatement
diff --git a/test/it/parser/src/main/resources/case/ddl/create-procedure.xml 
b/test/it/parser/src/main/resources/case/ddl/create-procedure.xml
index 0e4435ccb83..3a61e85bdca 100644
--- a/test/it/parser/src/main/resources/case/ddl/create-procedure.xml
+++ b/test/it/parser/src/main/resources/case/ddl/create-procedure.xml
@@ -122,4 +122,25 @@
             <sql-statement start-index="78" stop-index="102" 
statement-class-simple-name="ShowCreateTableStatement" />
         </sql-statements>
     </create-procedure>
+    <create-procedure 
sql-case-id="create_procedure_with_custom_collation_and_insert">
+        <procedure-name name="p" />
+        <sql-statements>
+            <sql-statement start-index="28" stop-index="87" 
statement-class-simple-name="DeclareStatement" />
+            <sql-statement start-index="90" stop-index="125" 
statement-class-simple-name="MySQLSetStatement" />
+            <sql-statement start-index="128" stop-index="181" 
statement-class-simple-name="MySQLCreateTableStatement" />
+            <sql-statement start-index="184" stop-index="208" 
statement-class-simple-name="MySQLInsertStatement" />
+        </sql-statements>
+    </create-procedure>
+    <create-procedure sql-case-id="create_procedure_with_alter_event">
+        <procedure-name name="p1" />
+        <sql-statements>
+            <sql-statement start-index="28" stop-index="54" 
statement-class-simple-name="MySQLAlterEventStatement" />
+        </sql-statements>
+    </create-procedure>
+    <create-procedure sql-case-id="create_procedure_with_drop_event">
+        <procedure-name name="p1" />
+        <sql-statements>
+            <sql-statement start-index="28" stop-index="40" 
statement-class-simple-name="MySQLDropEventStatement" />
+        </sql-statements>
+    </create-procedure>
 </sql-parser-test-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/ddl/create-procedure.xml 
b/test/it/parser/src/main/resources/sql/supported/ddl/create-procedure.xml
index 2daaf507f8d..6694eaa42de 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/create-procedure.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-procedure.xml
@@ -58,4 +58,7 @@
     <sql-case id="create_procedure_with_charset_parameters_and_insert" 
value="CREATE PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER 
SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); 
END;" db-types="MySQL" />
     <sql-case 
id="create_procedure_with_create_table_and_show_create_table_schema" 
value="CREATE PROCEDURE mysqltest2.p2() BEGIN CREATE TABLE t2(col1 
VARCHAR(10)); SHOW CREATE TABLE t2; END;" db-types="MySQL" />
     <sql-case id="create_procedure_with_show_create_table_in_default_schema" 
value="CREATE PROCEDURE p1() BEGIN CREATE TABLE t1(col1 VARCHAR(10)); SHOW 
CREATE TABLE t1; END;" db-types="MySQL" />
+    <sql-case id="create_procedure_with_custom_collation_and_insert" 
value="create procedure p () begin declare a varchar(1) charset utf8mb4 collate 
utf8mb4_test_ci; set @a = 'a' collate utf8mb4_test_ci; create table tp (t 
varchar(1) collate utf8mb4_test_ci); insert into t values (@a); end;" 
db-types="MySQL"/>
+    <sql-case id="create_procedure_with_alter_event" value="create procedure 
p1() begin alter event e1 rename to e2; end;" db-types="MySQL"/>
+    <sql-case id="create_procedure_with_drop_event" value="create procedure 
p1() begin drop event e1; end;" db-types="MySQL"/>
 </sql-cases>

Reply via email to