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/06/28 12:41:42 UTC

[shardingsphere] branch master updated: Support parsing create_bit_xor_table in MySQL (#14015) (#18659)

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 2e5427b066b Support parsing create_bit_xor_table in MySQL (#14015) (#18659)
2e5427b066b is described below

commit 2e5427b066bb51fcf38ccbe457532f8f20494440
Author: flyingzc <fl...@outlook.com>
AuthorDate: Tue Jun 28 20:41:32 2022 +0800

    Support parsing create_bit_xor_table in MySQL (#14015) (#18659)
    
    * Support parsing create_bit_xor_table in MySQL (#14015)
    
    * Support parsing create_bit_xor_table in MySQL (#14015)
---
 .../src/main/antlr4/imports/mysql/BaseRule.g4              |  1 +
 .../src/main/resources/case/ddl/create-table.xml           | 14 ++++++++++++++
 .../src/main/resources/case/ddl/drop-table.xml             |  4 ++++
 .../src/main/resources/sql/supported/ddl/create-table.xml  |  3 +++
 .../src/main/resources/sql/unsupported/unsupported.xml     |  6 ------
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
index 8552ef6092b..1bde99319a5 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/BaseRule.g4
@@ -49,6 +49,7 @@ customKeyword
     | LAST_VALUE
     | PRIMARY
     | MAXVALUE
+    | BIT_XOR
     ;
     
 literals
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-table.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-table.xml
index 1e576f84072..4b092453ef9 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-table.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-table.xml
@@ -1730,4 +1730,18 @@
             <column name="status" />
         </column-definition>
     </create-table>
+
+    <create-table sql-case-id="create_bit_xor_table">
+        <table name="BIT_XOR" start-index="13" stop-index="19" />
+        <column-definition type="int" start-index="21" stop-index="25">
+            <column name="a" />
+        </column-definition>
+    </create-table>
+
+    <create-table sql-case-id="create_bit_xor_table_with_space">
+        <table name="BIT_XOR" start-index="13" stop-index="19" />
+        <column-definition type="int" start-index="22" stop-index="26">
+            <column name="a" />
+        </column-definition>
+    </create-table>
 </sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/drop-table.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/drop-table.xml
index d27d94e5c8a..e53f7426e1a 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/drop-table.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/drop-table.xml
@@ -75,4 +75,8 @@
     <drop-table sql-case-id="drop_table_with_bracket">
         <table name="t_order" start-delimiter="[" end-delimiter="]" start-index="11" stop-index="19" />
     </drop-table>
+
+    <drop-table sql-case-id="drop_bit_xor_table">
+        <table name="BIT_XOR" start-index="11" stop-index="17" />
+    </drop-table>
 </sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-table.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-table.xml
index b97aad6b079..8b69dac0e85 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-table.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-table.xml
@@ -121,4 +121,7 @@
     <sql-case id="create_table_with_chinese_word" value="CREATE TABLE 测试表(id int PRIMARY KEY, status varchar(10))" />
     <sql-case id="create_table_with_chinese_word_with_quote_mysql" value="CREATE TABLE `测试表`(id int PRIMARY KEY, status varchar(10))" db-types="MySQL" />
     <sql-case id="create_table_with_chinese_word_with_quote" value="CREATE TABLE &quot;测试表&quot;(id int PRIMARY KEY, status varchar(10))" db-types="Oracle,PostgreSQL,openGauss,SQLServer,SQL92" />
+    <sql-case id="create_bit_xor_table" value="create table BIT_XOR(a int)" db-types="MySQL" />
+    <sql-case id="create_bit_xor_table_with_space" value="create table BIT_XOR (a int)" db-types="MySQL" />
+    <sql-case id="drop_bit_xor_table" value="drop table BIT_XOR" db-types="MySQL" />
 </sql-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
index 779e2841fe6..237ebec4978 100644
--- a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
@@ -22,7 +22,6 @@
     <sql-case id="assert_select_with_json_unquote_extract_sign_with_parameter_marker" value="SELECT * FROM t_order WHERE order_id -&gt;&gt; ?" db-types="MySQL" />
     <sql-case id="assert_insert_with_first" value="INSERT FIRST INTO TABLE_XXX (field1) VALUES (field1) SELECT field1 FROM TABLE_XXX2" db-types="Oracle" />
     <sql-case id="assert_dist_SQL_show_rule_parse_conflict" value="SHOW REPLICA_QUERY RULE FROM schema_name" />
-    <sql-case id="create_bit_xor_table" value="create table BIT_XOR (a int);" db-types="MySQL" />
     <sql-case id="select_with_comment1" value="select 2 as expected, /*!01000/**/*/ 2 as result;" db-types="MySQL" />
     <sql-case id="select_with_comment2" value="select 1 as expected, /*!99998/**/*/ 1 as result;" db-types="MySQL" />
     <sql-case id="select_with_comment5" value="select 7 as expected, /*!01000 1 + /* 8 + */ 2 + */ 4 as result;" db-types="MySQL" />
@@ -697,10 +696,6 @@
     <sql-case id="create_by_mysql_source_test_case1221" value="create procedure test_signal() begin DECLARE aaa VARCHAR(64); DECLARE bbb VARCHAR(64); DECLARE ccc VARCHAR(64); DECLARE ddd VARCHAR(64); DECLARE eee VARCHAR(64); DECLARE fff VARCHAR(64); DECLARE ggg VARCHAR(64); DECLARE hhh VARCHAR(64); DECLARE iii VARCHAR(64); DECLARE jjj VARCHAR(64); DECLARE kkk VARCHAR(64); DECLARE warn CONDITION FOR SQLSTATE &quot;01234&quot;; set aaa= repeat(&quot;A&quot;, 64); set bbb= repeat(&quot;B&qu [...]
     <sql-case id="create_by_mysql_source_test_case1222" value="create procedure test_signal() begin DECLARE céèçà foo CONDITION FOR SQLSTATE &apos;12345&apos;; SIGNAL céèçà SET MYSQL_ERRNO = 1000; end" db-types="MySQL" />
     <sql-case id="create_by_mysql_source_test_case1224" value="create procedure u() use sptmp" db-types="MySQL" />
-    <sql-case id="create_by_mysql_source_test_case1230" value="create table BIT_XOR (a int)" db-types="MySQL" />
-    <sql-case id="create_by_mysql_source_test_case1231" value="create table BIT_XOR (a int)" db-types="MySQL" />
-    <sql-case id="create_by_mysql_source_test_case1232" value="create table BIT_XOR(a int)" db-types="MySQL" />
-    <sql-case id="create_by_mysql_source_test_case1233" value="create table BIT_XOR(a int)" db-types="MySQL" />
     <sql-case id="create_by_mysql_source_test_case1234" value="create table `#mysql50#abc``def` ( id int )" db-types="MySQL" />
     <sql-case id="create_by_mysql_source_test_case1235" value="create table `` (a int)" db-types="MySQL" />
     <sql-case id="create_by_mysql_source_test_case1236" value="create table ```a` (i int)" db-types="MySQL" />
@@ -3044,7 +3039,6 @@
     <sql-case id="low_call_by_mysql_source_test_case206" value="call test.longprocedure(@value); select @value" db-types="MySQL" />
     <sql-case id="low_default-character-set=koi8r_by_mysql_source_test_case1" value="default-character-set=koi8r default-collation=koi8r_bin let $MYSQLD_LOG= $MYSQLTEST_VARDIR/log/save_dd_upgrade_1.log" db-types="MySQL" />
     <sql-case id="low_drop_by_mysql_source_test_case1" value="drop function `f``1`" db-types="MySQL" />
-    <sql-case id="low_drop_by_mysql_source_test_case3" value="drop table BIT_XOR" db-types="MySQL" />
     <sql-case id="low_drop_by_mysql_source_test_case4" value="drop table ```a`" db-types="MySQL" />
     <sql-case id="low_drop_by_mysql_source_test_case5" value="drop table `t1a``b`" db-types="MySQL" />
     <sql-case id="low_drop_by_mysql_source_test_case6" value="drop table `t``1`, `t 1`" db-types="MySQL" />