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 3f6463e14b3 Optimized sqlParser to support examples from MySQL Test
Suite. (#25577)
3f6463e14b3 is described below
commit 3f6463e14b359ba0f2fbdef112833e76c459b500
Author: Cong Hu <[email protected]>
AuthorDate: Thu May 11 18:42:15 2023 +0800
Optimized sqlParser to support examples from MySQL Test Suite. (#25577)
* Optimize DDLStatement.g4 alterOrderList.
* Optimize BaseRule.g4 pluginName.
---
parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4 | 2 +-
.../sql/dialect/mysql/src/main/antlr4/imports/mysql/DDLStatement.g4 | 2 +-
test/it/parser/src/main/resources/case/dcl/alter-user.xml | 1 +
test/it/parser/src/main/resources/case/ddl/alter-table.xml | 4 ++++
test/it/parser/src/main/resources/sql/supported/dcl/alter-user.xml | 1 +
test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml | 1 +
6 files changed, 9 insertions(+), 2 deletions(-)
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 c261f1434c1..b7490a2ba94 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
@@ -738,7 +738,7 @@ componentName
;
pluginName
- : identifier
+ : textOrIdentifier
;
hostname
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 434492c31be..4ac5a702afe 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
@@ -109,7 +109,7 @@ alterListItem
;
alterOrderList
- : identifier direction? (COMMA_ identifier direction?)*
+ : columnRef direction? (COMMA_ columnRef direction?)*
;
tableConstraintDef
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 27f5e163c1e..876d202dc4e 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
@@ -67,4 +67,5 @@
<alter-user sql-case-id="alter_azure_ad_user_with_login" />
<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" />
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/ddl/alter-table.xml
b/test/it/parser/src/main/resources/case/ddl/alter-table.xml
index 7a5246918f4..9bd6647ae24 100644
--- a/test/it/parser/src/main/resources/case/ddl/alter-table.xml
+++ b/test/it/parser/src/main/resources/case/ddl/alter-table.xml
@@ -1242,4 +1242,8 @@
</column-definition>
</modify-column>
</alter-table>
+
+ <alter-table sql-case-id="alter_table_order_by">
+ <table name="t_order" start-index="12" stop-index="18" />
+ </alter-table>
</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 898558b9d1f..049f7e87821 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
@@ -67,4 +67,5 @@
<sql-case id="alter_azure_ad_user_with_login" value="ALTER USER
[westus/joe] WITH LOGIN = [email protected]" db-types="SQLServer" />
<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
"DHE-RSA-AES256-SHA"" db-types="MySQL" />
</sql-cases>
diff --git
a/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
b/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
index c46a37d8b35..eeef48aeca4 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
@@ -155,4 +155,5 @@
<sql-case id="alter_table_set_access_method" value="ALTER TABLE t_order
SET ACCESS METHOD heap, SET ACCESS METHOD heap2" db-types="PostgreSQL" />
<sql-case id="alter_table_drop_expression" value="ALTER TABLE t_order
ALTER COLUMN a DROP EXPRESSION;" db-types="PostgreSQL" />
<sql-case id="alter_table_modify_column_precision_with_decimal"
value="ALTER TABLE t_order MODIFY COLUMN a VARCHAR(10.000000000001)"
db-types="MySQL" />
+ <sql-case id="alter_table_order_by" value="ALTER TABLE t_order ORDER BY
t_order.id, t_order.status desc" db-types="MySQL" />
</sql-cases>