You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by wu...@apache.org on 2021/06/18 15:24:33 UTC

[shardingsphere] branch master updated: User resource name instead of IDENTIFIER in G4 file for Readwrite-splitting (#10875)

This is an automated email from the ASF dual-hosted git repository.

wuweijie 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 829eecf  User resource name instead of IDENTIFIER in G4 file for Readwrite-splitting (#10875)
829eecf is described below

commit 829eecf97595e512930d89d20f5a8289fadb58c7
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Jun 18 23:24:10 2021 +0800

    User resource name instead of IDENTIFIER in G4 file for Readwrite-splitting (#10875)
---
 .../antlr4/imports/readwrite-splitting/RDLStatement.g4   | 16 ++++++++++------
 .../core/ReadwriteSplittingRuleSQLStatementVisitor.java  | 11 ++++++-----
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/RDLStatement.g4 b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/RDLStatement.g4
index d1714df..e196a51 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/RDLStatement.g4
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/RDLStatement.g4
@@ -28,7 +28,7 @@ alterReadwriteSplittingRule
     ;
 
 dropReadwriteSplittingRule
-    : DROP READWRITE_SPLITTING RULE IDENTIFIER (COMMA IDENTIFIER)*
+    : DROP READWRITE_SPLITTING RULE ruleName (COMMA ruleName)*
     ;
 
 readwriteSplittingRuleDefinition
@@ -36,22 +36,26 @@ readwriteSplittingRuleDefinition
     ;
 
 staticReadwriteSplittingRuleDefinition
-    : WRITE_RESOURCE EQ writeResourceName COMMA READ_RESOURCES LP resourceName (COMMA resourceName)* RP
+    : WRITE_RESOURCE EQ writeResourceName COMMA READ_RESOURCES LP readResourceNames RP
     ;
 
 dynamicReadwriteSplittingRuleDefinition
-    : AUTO_AWARE_RESOURCE EQ IDENTIFIER
+    : AUTO_AWARE_RESOURCE EQ resourceName
+    ;
+
+ruleName
+    : IDENTIFIER
     ;
 
 writeResourceName
     : resourceName
     ;
 
-resourceName
-    : IDENTIFIER
+readResourceNames
+    : resourceName (COMMA resourceName)*
     ;
 
-ruleName
+resourceName
     : IDENTIFIER
     ;
 
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwrit [...]
index 9282d4d..1129c1d 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.readwritesplitting.distsql.parser.core;
 
 import org.antlr.v4.runtime.RuleContext;
-import org.antlr.v4.runtime.tree.TerminalNode;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementBaseVisitor;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.AlgorithmDefinitionContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.AlgorithmPropertyContext;
@@ -26,6 +25,7 @@ import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleSt
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.CreateReadwriteSplittingRuleContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.DropReadwriteSplittingRuleContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.ReadwriteSplittingRuleDefinitionContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.RuleNameContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.SchemaNameContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.ShowReadwriteSplittingRulesContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.StaticReadwriteSplittingRuleDefinitionContext;
@@ -61,7 +61,7 @@ public final class ReadwriteSplittingRuleSQLStatementVisitor extends ReadwriteSp
     
     @Override
     public ASTNode visitDropReadwriteSplittingRule(final DropReadwriteSplittingRuleContext ctx) {
-        return new DropReadwriteSplittingRuleStatement(ctx.IDENTIFIER().stream().map(TerminalNode::getText).collect(Collectors.toList()));
+        return new DropReadwriteSplittingRuleStatement(ctx.ruleName().stream().map(RuleNameContext::getText).collect(Collectors.toList()));
     }
     
     @Override
@@ -77,11 +77,12 @@ public final class ReadwriteSplittingRuleSQLStatementVisitor extends ReadwriteSp
         }
         if (null == ctx.staticReadwriteSplittingRuleDefinition()) {
             return new ReadwriteSplittingRuleSegment(
-                    ctx.ruleName().getText(), ctx.dynamicReadwriteSplittingRuleDefinition().IDENTIFIER().getText(), ctx.algorithmDefinition().algorithmName().getText(), props);
+                    ctx.ruleName().getText(), ctx.dynamicReadwriteSplittingRuleDefinition().resourceName().getText(), ctx.algorithmDefinition().algorithmName().getText(), props);
         }
         StaticReadwriteSplittingRuleDefinitionContext staticRuleDefinitionCtx = ctx.staticReadwriteSplittingRuleDefinition();
-        return new ReadwriteSplittingRuleSegment(ctx.ruleName().getText(), staticRuleDefinitionCtx.writeResourceName().getText(),
-                staticRuleDefinitionCtx.resourceName().stream().map(RuleContext::getText).collect(Collectors.toList()), ctx.algorithmDefinition().algorithmName().getText(), props);
+        return new ReadwriteSplittingRuleSegment(ctx.ruleName().getText(), 
+                staticRuleDefinitionCtx.writeResourceName().getText(), staticRuleDefinitionCtx.readResourceNames().resourceName().stream().map(RuleContext::getText).collect(Collectors.toList()), 
+                ctx.algorithmDefinition().algorithmName().getText(), props);
     }
     
     @Override