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 06c7995ac1a fix mysql blob type field can be empty (#20243) (#20262)
06c7995ac1a is described below
commit 06c7995ac1a6566e9520c5e8da37973a8092c301
Author: mingyifei <[email protected]>
AuthorDate: Fri Aug 19 16:49:28 2022 +0800
fix mysql blob type field can be empty (#20243) (#20262)
* fix mysql blob type field can be empty hash (#20243)
* UUID_TO_BIN(),BIN_TO_UUID().The function is only available in MySQL 8.0
or later.
* Add test cases for SQL parse.
Co-authored-by: mingyifei <[email protected]>
---
.../src/main/antlr4/imports/mysql/Literals.g4 | 2 +-
.../src/main/resources/case/dml/insert.xml | 8 ++++++--
.../src/main/resources/sql/supported/dml/insert.xml | 2 +-
.../src/main/resources/sql/unsupported/unsupported.xml | 2 --
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Literals.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Literals.g4
index 94e0fc91652..7e16bb472b0 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Literals.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Literals.g4
@@ -58,7 +58,7 @@ DECIMAL_NUM_
;
HEX_DIGIT_
- : '0x' HEX_+ | X SQ_ HEX_+ SQ_
+ : '0x' HEX_+ | X SQ_ HEX_+ SQ_ | X SQ_ + SQ_
;
BIT_NUM_
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/insert.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/insert.xml
index 3b445433c35..1a43bd7bd74 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/insert.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/insert.xml
@@ -1469,13 +1469,17 @@
<insert sql-case-id="insert_with_digit_literals_value">
<table name="digit_literals_value_test" start-index="12"
stop-index="36" />
- <columns start-index="37" stop-index="42">
+ <columns start-index="37" stop-index="48">
<column name="col1" start-index="38" stop-index="41" />
+ <column name="col2" start-index="44" stop-index="47" />
</columns>
<values>
<value>
<assignment-value>
- <common-expression text="x'1234'" start-index="51"
stop-index="57" />
+ <common-expression text="x'1234'" start-index="57"
stop-index="63" />
+ </assignment-value>
+ <assignment-value>
+ <common-expression text="x''" start-index="66"
stop-index="68" />
</assignment-value>
</value>
</values>
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/insert.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/insert.xml
index 3f708b4cc93..799f9c4ba72 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/insert.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/insert.xml
@@ -62,7 +62,7 @@
<sql-case id="insert_select_without_generate_key_column" value="INSERT
INTO t_order_item(order_id, user_id, status, creation_date) SELECT order_id,
user_id, 'insert', '2017-08-08' FROM t_order_item WHERE order_id = ?"
db-types="MySQL" />
<sql-case id="insert_select_on_duplicate_key_update" value="INSERT INTO
t_order(order_id, user_id, status) SELECT order_id, user_id, status FROM
t_order WHERE order_id = ? ON DUPLICATE KEY UPDATE status = VALUES(status)"
db-types="MySQL" />
<sql-case id="insert_with_emoji_value" value="INSERT INTO
t_emoji_test(col1) VALUES('test😀')" db-types="MySQL" />
- <sql-case id="insert_with_digit_literals_value" value="INSERT INTO
digit_literals_value_test(col1) VALUES(x'1234')" db-types="MySQL" />
+ <sql-case id="insert_with_digit_literals_value" value="INSERT INTO
digit_literals_value_test(col1, col2) VALUES(x'1234', x'')" db-types="MySQL" />
<sql-case id="insert_with_with_clause" value="WITH cte (order_id, user_id)
AS (SELECT order_id, user_id FROM t_order) INSERT INTO t_order (order_id,
user_id) SELECT order_id, user_id FROM cte" db-types="SQLServer" />
<sql-case id="insert_without_columns_with_with_clause" value="WITH cte AS
(SELECT order_id, user_id FROM t_order) INSERT INTO t_order (order_id, user_id)
SELECT order_id, user_id FROM cte" db-types="SQLServer" />
<sql-case id="insert_without_into_keyword" value="INSERT t_order
(order_id, user_id, status) VALUES (?, ?, ?)" db-types="MySQL,SQLServer" />
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 46245920954..41e3feb247f 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
@@ -1164,8 +1164,6 @@
<sql-case id="select_by_mysql_source_test_case665" value="SELECT attrs.*
FROM t_json, JSON_TABLE(json_col, '$[*]' COLUMNS (nickname JSON PATH
'$.nickname')) as attrs" db-types="MySQL" />
<sql-case id="select_by_mysql_source_test_case666" value="SELECT b, b IN
('20161213'), b in ('20161213', 0) FROM t2"
db-types="MySQL" />
<sql-case id="select_by_mysql_source_test_case667" value="SELECT b, b in
('121314'), b in ('121314', 0) FROM t3" db-types="MySQL" />
- <sql-case id="select_by_mysql_source_test_case669" value="SELECT
bin_to_uuid(x'')" db-types="MySQL" />
- <sql-case id="select_by_mysql_source_test_case670" value="SELECT
bin_to_uuid(x'', true)" db-types="MySQL" />
<sql-case id="select_by_mysql_source_test_case671" value="SELECT
bug18589_f1(REPEAT("a", 767))" db-types="MySQL" />
<sql-case id="select_by_mysql_source_test_case672" value="SELECT c1 <=
REPEAT( SUBSTR( UPPER('Rdlpikti') , 1 , 2 ), 8 ) FROM t1"
db-types="MySQL" />
<sql-case id="select_by_mysql_source_test_case676" value="SELECT cast(
'2019-10-10 10:11' AT TIME ZONE 'UTC' AS DATETIME )"
db-types="MySQL" />