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 2023/06/26 02:29:14 UTC

[shardingsphere] branch master updated: Support cache index default parse (#25535) (#26556)

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 8f83eb31ecb Support cache index default parse (#25535) (#26556)
8f83eb31ecb is described below

commit 8f83eb31ecb18d2cf2effb727fa0b8d64e3d61ce
Author: niu niu <zi...@aliyun.com>
AuthorDate: Mon Jun 26 10:29:07 2023 +0800

    Support cache index default parse (#25535) (#26556)
---
 .../mysql/visitor/statement/type/MySQLDALStatementVisitor.java    | 6 +++++-
 test/it/parser/src/main/resources/case/dal/cache-index.xml        | 8 ++++++++
 .../parser/src/main/resources/sql/supported/dal/cache-index.xml   | 1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/type/MySQLDALStatementVisitor.java b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/type/MySQLDALStatementVisitor.java
index 7708f670eac..a0e9e7410e3 100644
--- a/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/type/MySQLDALStatementVisitor.java
+++ b/parser/sql/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/type/MySQLDALStatementVisitor.java
@@ -415,7 +415,11 @@ public final class MySQLDALStatementVisitor extends MySQLStatementVisitor implem
             segment.getPartitions().addAll(((CollectionValue<PartitionSegment>) visit(ctx.partitionList())).getValue());
             result.setPartitionDefinition(segment);
         }
-        result.setName((IdentifierValue) visit(ctx.identifier()));
+        if (null != ctx.DEFAULT()) {
+            result.setName(new IdentifierValue(ctx.DEFAULT().getText()));
+        } else {
+            result.setName((IdentifierValue) visit(ctx.identifier()));
+        }
         return result;
     }
     
diff --git a/test/it/parser/src/main/resources/case/dal/cache-index.xml b/test/it/parser/src/main/resources/case/dal/cache-index.xml
index c9b3a8325b6..049609102a2 100644
--- a/test/it/parser/src/main/resources/case/dal/cache-index.xml
+++ b/test/it/parser/src/main/resources/case/dal/cache-index.xml
@@ -17,6 +17,14 @@
   -->
 
 <sql-parser-test-cases>
+    <cache-index sql-case-id="cache_index_with_in" name="default">
+        <table-index start-index="12" stop-index="13">
+            <table name="t1" start-index="12" stop-index="13" />
+        </table-index>
+        <table-index start-index="15" stop-index="16">
+            <table name="t2" start-index="15" stop-index="16" />
+        </table-index>
+    </cache-index>
     <cache-index sql-case-id="cache_index_single_table" name="hot_cache_index">
         <table-index start-index="12" stop-index="18">
             <table name="t_order" start-index="12" stop-index="18" />
diff --git a/test/it/parser/src/main/resources/sql/supported/dal/cache-index.xml b/test/it/parser/src/main/resources/sql/supported/dal/cache-index.xml
index 703384ce9b3..d80b9c8ce02 100644
--- a/test/it/parser/src/main/resources/sql/supported/dal/cache-index.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dal/cache-index.xml
@@ -17,6 +17,7 @@
   -->
 
 <sql-cases>
+    <sql-case id="cache_index_with_in" value="cache index t1,t2 in default" db-types="MySQL" />
     <sql-case id="cache_index_single_table" value="CACHE INDEX t_order IN hot_cache_index" db-types="MySQL" />
     <sql-case id="cache_index_multiple_table" value="CACHE INDEX t_order, t_user IN hot_cache_index" db-types="MySQL" />
     <sql-case id="cache_index_single_table_multiple_index" value="CACHE INDEX t_order INDEX (idx_a, idx_b) IN hot_cache_index" db-types="MySQL" />