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 88744c1a987 Fix mysql comment sql (#29414)
88744c1a987 is described below
commit 88744c1a9873c01c51d554f055419e5e83c0e213
Author: niu niu <[email protected]>
AuthorDate: Fri Dec 15 18:27:51 2023 +0800
Fix mysql comment sql (#29414)
---
.../dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4 | 2 +-
test/it/parser/src/main/resources/case/dal/explain.xml | 13 +++++++++++++
test/it/parser/src/main/resources/case/dml/select.xml | 11 +++++++++++
.../parser/src/main/resources/sql/supported/dal/explain.xml | 1 +
.../parser/src/main/resources/sql/supported/dml/select.xml | 1 +
5 files changed, 27 insertions(+), 1 deletion(-)
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 4d3a5739f98..27dd6acc9c6 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
@@ -17,7 +17,7 @@
grammar BaseRule;
-import Symbol, Keyword, MySQLKeyword, Literals;
+import Comments, Symbol, Keyword, MySQLKeyword, Literals;
parameterMarker
: QUESTION_
diff --git a/test/it/parser/src/main/resources/case/dal/explain.xml
b/test/it/parser/src/main/resources/case/dal/explain.xml
index d8c4eee4b63..9bf5476a77f 100644
--- a/test/it/parser/src/main/resources/case/dal/explain.xml
+++ b/test/it/parser/src/main/resources/case/dal/explain.xml
@@ -998,4 +998,17 @@
</model>
</select>
</describe>
+
+ <describe sql-case-id="explain_with_select_comment">
+ <select>
+ <projections start-index="78" stop-index="78">
+ <shorthand-projection start-index="78" stop-index="78" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="85" stop-index="91"
/>
+ </from>
+ </select>
+ <comment start-index="0" stop-index="19" text="/*FORCE_IMCI_NODES*/" />
+ <comment start-index="36" stop-index="76" text="/*+
SET_VAR(cost_threshold_for_imci=0) */" />
+ </describe>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml
b/test/it/parser/src/main/resources/case/dml/select.xml
index 506e3db1f03..54ba480dd3a 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -17,6 +17,17 @@
-->
<sql-parser-test-cases>
+ <select sql-case-id="select_with_comment">
+ <projections start-index="70" stop-index="70">
+ <shorthand-projection start-index="70" stop-index="70" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="77" stop-index="83" />
+ </from>
+ <comment start-index="0" stop-index="19" text="/*FORCE_IMCI_NODES*/" />
+ <comment start-index="28" stop-index="68" text="/*+
SET_VAR(cost_threshold_for_imci=0) */" />
+ </select>
+
<select sql-case-id="select_position_function">
<projections start-index="7" stop-index="97">
<expression-projection text="position("0" in
"baaa" in (1))" start-index="7" stop-index="36">
diff --git a/test/it/parser/src/main/resources/sql/supported/dal/explain.xml
b/test/it/parser/src/main/resources/sql/supported/dal/explain.xml
index e8cf5fdf675..b8e488e013a 100644
--- a/test/it/parser/src/main/resources/sql/supported/dal/explain.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dal/explain.xml
@@ -71,4 +71,5 @@
<sql-case id="explain_set_statement_id_with_into_update" value="EXPLAIN
PLAN SET STATEMENT_ID = 'Raise in Tokyo' INTO plan_table FOR UPDATE employees
SET salary = salary * 1.10 WHERE department_id = (SELECT department_id FROM
departments WHERE location_id = 1700)" db-types="Oracle" />
<sql-case id="explain_for_select_with_unique_partition_by" value="EXPLAIN
PLAN FOR SELECT country, prod, year, sales FROM sales_view WHERE country IN
('Italy', 'Japan') MODEL UNIQUE DIMENSION PARTITION BY (country) DIMENSION BY
(prod, year)
MEASURES (sale sales) RULES UPSERT (sales['Bounce', 2003] =
AVG(sales)[ANY, 2002] * 1.24, sales[prod <> 'Bounce', 2003] =
sales['Bounce', 2003] * 0.25)" db-types="Oracle" />
+ <sql-case id="explain_with_select_comment" value="/*FORCE_IMCI_NODES*/
explain select /*+ SET_VAR(cost_threshold_for_imci=0) */ * from t_order"
db-types="MySQL" />
</sql-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index 7e7e5ef66b1..762e913b321 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -17,6 +17,7 @@
-->
<sql-cases>
+ <sql-case id="select_with_comment" value="/*FORCE_IMCI_NODES*/ select /*+
SET_VAR(cost_threshold_for_imci=0) */ * from t_order" db-types="MySQL" />
<sql-case id="select_position_function" value="select
position("0" in "baaa" in (1)),position("0" in
"1" in (1,2,3)),position("sql" in ("mysql"))"
db-types="MySQL" />
<sql-case id="select_extract_function_with_day_hour" value="select
extract(DAY_HOUR FROM "1999-01-02 10:11:12")" db-types="MySQL" />
<sql-case id="select_with_latin1" value="select _latin1'B' collate
latin1_bin in (_latin1'a',_latin1'b')" db-types="MySQL" />