You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/10/24 08:44:08 UTC

[shardingsphere] branch master updated: Refactor some READWRITE_SPLITTING related syntax #21694 (#21699)

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

jianglongtao 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 dbe7065098e Refactor some READWRITE_SPLITTING related syntax #21694 (#21699)
dbe7065098e is described below

commit dbe7065098e042c460cba11bde187b699bbadd08
Author: jiangML <10...@qq.com>
AuthorDate: Mon Oct 24 16:44:01 2022 +0800

    Refactor some READWRITE_SPLITTING related syntax #21694 (#21699)
    
    * refactor some READWRITE_SPLITTING related syntax
    
    * update doc
    
    * optimize code
---
 .../distsql/syntax/ral/_index.cn.md                | 12 +++++-----
 .../distsql/syntax/ral/_index.en.md                | 12 +++++-----
 .../distsql/usage/db-discovery.cn.md               |  4 ++--
 .../distsql/usage/db-discovery.en.md               |  4 ++--
 .../distsql/usage/encrypt-rule.cn.md               |  4 ++--
 .../distsql/usage/encrypt-rule.en.md               |  4 ++--
 .../distsql/usage/readwirte-splitting-rule.cn.md   |  4 ++--
 .../distsql/usage/readwirte-splitting-rule.en.md   |  4 ++--
 .../distsql/usage/shadow-rule.cn.md                |  4 ++--
 .../distsql/usage/shadow-rule.en.md                |  4 ++--
 .../distsql/usage/sharding-rule.cn.md              |  4 ++--
 .../distsql/usage/sharding-rule.en.md              |  4 ++--
 .../antlr4/imports/readwrite-splitting/BaseRule.g4 |  4 ++++
 .../imports/readwrite-splitting/RALStatement.g4    | 12 ++++------
 .../autogen/ReadwriteSplittingDistSQLStatement.g4  |  5 ++---
 .../ReadwriteSplittingDistSQLStatementVisitor.java | 26 ++++++++++------------
 ...owReadwriteSplittingReadResourcesStatement.java | 10 +++++++--
 .../SetReadwriteSplittingStatusStatement.java      |  6 +++--
 ...ShowReadwriteSplittingReadResourcesHandler.java | 12 ++++++----
 .../SetReadwriteSplittingStatusHandler.java        | 12 +++++++++-
 .../jaxb/cases/domain/SQLParserTestCases.java      |  2 +-
 .../src/main/resources/case/ral/queryable.xml      |  2 +-
 .../main/resources/sql/supported/ral/queryable.xml |  2 +-
 23 files changed, 88 insertions(+), 69 deletions(-)

diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md
index 3c33d637540..2270aae0952 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md
@@ -35,12 +35,12 @@ RAL (Resource & Rule Administration Language) 为 Apache ShardingSphere 的管
 
 ## 熔断
 
-| 语句                                                                             | 说明                 | 示例                                        |
-| :------------------------------------------------------------------------------ | :------------------- | :----------------------------------------- |
-| [ENABLE / DISABLE] READWRITE_SPLITTING (READ)? resourceName [FROM databaseName] | 启用 / 禁用读库        | ENABLE READWRITE_SPLITTING READ resource_0 |
-| [ENABLE / DISABLE] INSTANCE instanceId                                          | 启用 / 禁用 proxy 实例 | DISABLE INSTANCE instance_1                |
-| SHOW INSTANCE LIST                                                              | 查询 proxy 实例信息    | SHOW INSTANCE LIST                         |
-| SHOW READWRITE_SPLITTING (READ)? resourceName [FROM databaseName]               | 查询所有读库的状态      | SHOW READWRITE_SPLITTING READ RESOURCES    |
+| 语句                                                                                               | 说明                                  | 示例                                                            |
+|:-------------------------------------------------------------------------------------------------|:------------------------------------|:--------------------------------------------------------------|
+| ALTER READWRITE_SPLITTING RULE [ groupName ] (ENABLE / DISABLE) resourceName [FROM databaseName] | 启用 / 禁用读库        | ALTER READWRITE_SPLITTING RULE group_1 ENABLE resource_0      |
+| [ENABLE / DISABLE] INSTANCE instanceId                                                           | 启用 / 禁用 proxy 实例                    | DISABLE INSTANCE instance_1                                   |
+| SHOW INSTANCE LIST                                                                               | 查询 proxy 实例信息                       | SHOW INSTANCE LIST                                            |
+| SHOW STATUS FROM READWRITE_SPLITTING (RULES / RULE groupName) [FROM databaseName]                | 查询所有读库的状态          | SHOW STATUS FROM READWRITE_SPLITTING RULES                    |
 
 ## 全局规则
 
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md
index e4dbe807128..eda9c85e70f 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md
@@ -35,12 +35,12 @@ RAL (Resource & Rule Administration Language) responsible for hint, circuit brea
 
 ## Circuit Breaker
 
-| Statement                                                                       | Function                           | Example                                    |
-| :------------------------------------------------------------------------------ | :--------------------------------- | :----------------------------------------- |
-| [ENABLE / DISABLE] READWRITE_SPLITTING (READ)? resourceName [FROM databaseName] | Enable or disable read data source | ENABLE READWRITE_SPLITTING READ resource_0 |
-| [ENABLE / DISABLE] INSTANCE instanceId                                          | Enable or disable proxy instance   | DISABLE INSTANCE instance_1                |
-| SHOW INSTANCE LIST                                                              | Query proxy instance information   | SHOW INSTANCE LIST                         |
-| SHOW READWRITE_SPLITTING (READ)? resourceName [FROM databaseName]               | Query all read resources status    | SHOW READWRITE_SPLITTING READ RESOURCES    |
+| Statement                                                                                            | Function                           | Example                                                    |
+|:-----------------------------------------------------------------------------------------------------|:-----------------------------------|:-----------------------------------------------------------|
+| ALTER READWRITE_SPLITTING RULE [ groupName ] (ENABLE / DISABLE) resourceName [FROM databaseName]     | Enable or disable read data source | ALTER READWRITE_SPLITTING RULE group_1 ENABLE resource_0   |
+| [ENABLE / DISABLE] INSTANCE instanceId                                                               | Enable or disable proxy instance   | DISABLE INSTANCE instance_1                                |
+| SHOW INSTANCE LIST                                                                                   | Query proxy instance information   | SHOW INSTANCE LIST                                         |
+| SHOW STATUS FROM READWRITE_SPLITTING (RULES / RULE groupName) [FROM databaseName]                    | Query all read resources status    | SHOW STATUS FROM READWRITE_SPLITTING RULES                 |
 
 ## Global Rule
 
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/db-discovery.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/db-discovery.cn.md
index 8a6b08d9800..f7d40b8ff3e 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/db-discovery.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/db-discovery.cn.md
@@ -6,7 +6,7 @@ weight = 5
 ## 资源操作
 
 ```sql
-ADD RESOURCE ds_0 (
+REGISTER STORAGE UNIT ds_0 (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_0",
@@ -70,7 +70,7 @@ DROP DB_DISCOVERY HEARTBEAT db_discovery_group_0_heartbeat;
 - 删除数据源
 
 ```sql
-DROP RESOURCE ds_0,ds_1,ds_2;
+UNREGISTER STORAGE UNIT ds_0,ds_1,ds_2;
 ```
 
 - 删除分布式数据库
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/db-discovery.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/db-discovery.en.md
index c6d0cae63c7..be07e221bf9 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/db-discovery.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/db-discovery.en.md
@@ -6,7 +6,7 @@ weight = 5
 ## Resource Operation
 
 ```sql
-ADD RESOURCE ds_0 (
+REGISTER STORAGE UNIT ds_0 (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_0",
@@ -70,7 +70,7 @@ DROP DB_DISCOVERY HEARTBEAT db_discovery_group_0_heartbeat;
 - Drop resource
 
 ```sql
-DROP RESOURCE ds_0,ds_1,ds_2;
+UNREGISTER STORAGE UNIT ds_0,ds_1,ds_2;
 ```
 
 - Drop distributed database
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule.cn.md
index 6ec4f35020e..5e900a06406 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule.cn.md
@@ -6,7 +6,7 @@ weight = 3
 ## 资源操作
 
 ```sql
-ADD RESOURCE ds_0 (
+REGISTER STORAGE UNIT ds_0 (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_0",
@@ -56,7 +56,7 @@ DROP ENCRYPT RULE t_encrypt;
 - 删除数据源
 
 ```sql
-DROP RESOURCE ds_0;
+UNREGISTER STORAGE UNIT ds_0;
 ```
 
 - 删除分布式数据库
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule.en.md
index 6023c9544ff..014c3d17f86 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule.en.md
@@ -6,7 +6,7 @@ weight = 3
 ## Resource Operation
 
 ```sql
-ADD RESOURCE ds_0 (
+REGISTER STORAGE UNIT ds_0 (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_0",
@@ -56,7 +56,7 @@ DROP ENCRYPT RULE t_encrypt;
 - Drop resource
 
 ```sql
-DROP RESOURCE ds_0;
+UNREGISTER STORAGE UNIT ds_0;
 ```
 
 - Drop distributed database
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule.cn.md
index e692983df1a..e333217b386 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule.cn.md
@@ -6,7 +6,7 @@ weight = 2
 ## 资源操作
 
 ```sql
-ADD RESOURCE write_ds (
+REGISTER STORAGE UNIT write_ds (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_0",
@@ -52,7 +52,7 @@ DROP READWRITE_SPLITTING RULE group_0;
 - 删除数据源
 
 ```sql
-DROP RESOURCE write_ds,read_ds;
+UNREGISTER STORAGE UNIT write_ds,read_ds;
 ```
 
 - 删除分布式数据库
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule.en.md
index 833322dbcdb..ba0332e5922 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule.en.md
@@ -6,7 +6,7 @@ weight = 2
 ## Resource Operation
 
 ```sql
-ADD RESOURCE write_ds (
+REGISTER STORAGE UNIT write_ds (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_0",
@@ -52,7 +52,7 @@ DROP READWRITE_SPLITTING RULE group_0;
 - Drop resource
 
 ```sql
-DROP RESOURCE write_ds,read_ds;
+UNREGISTER STORAGE UNIT write_ds,read_ds;
 ```
 
 - Drop distributed database
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule.cn.md
index 799f8426aa9..d94dd734a51 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule.cn.md
@@ -6,7 +6,7 @@ weight = 5
 ## 资源操作
 
 ```sql
-ADD RESOURCE ds_0 (
+REGISTER STORAGE UNIT ds_0 (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_0",
@@ -57,7 +57,7 @@ DROP SHADOW RULE group_0;
 - 删除数据源
 
 ```sql
-DROP RESOURCE ds_0,ds_1,ds_2;
+UNREGISTER STORAGE UNIT ds_0,ds_1,ds_2;
 ```
 
 9. 删除分布式数据库
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule.en.md
index 5c4a19935f7..673b0a6d4e9 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule.en.md
@@ -6,7 +6,7 @@ weight = 5
 ## Resource Operation
 
 ```sql
-ADD RESOURCE ds_0 (
+REGISTER STORAGE UNIT ds_0 (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_0",
@@ -57,7 +57,7 @@ DROP SHADOW RULE group_0;
 - Drop resource
 
 ```sql
-DROP RESOURCE ds_0,ds_1,ds_2;
+UNREGISTER STORAGE UNIT ds_0,ds_1,ds_2;
 ```
 
 - Drop distributed database
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule.cn.md
index 4eabf043ce8..b93038c6385 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule.cn.md
@@ -6,7 +6,7 @@ weight = 1
 ## 资源操作
 
 ```sql
-ADD RESOURCE ds_0 (
+REGISTER STORAGE UNIT ds_0 (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_1",
@@ -60,7 +60,7 @@ DROP SHARDING TABLE RULE t_order;
 - 删除数据源
 
 ```sql
-DROP RESOURCE ds_0, ds_1;
+UNREGISTER STORAGE UNIT ds_0, ds_1;
 ```
 
 - 删除分布式数据库
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule.en.md
index c3c8752b328..60b53712958 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule.en.md
@@ -8,7 +8,7 @@ weight = 1
 - Configure data source information
 
 ```sql
-ADD RESOURCE ds_0 (
+REGISTER STORAGE UNIT ds_0 (
     HOST="127.0.0.1",
     PORT=3306,
     DB="ds_1",
@@ -62,7 +62,7 @@ DROP SHARDING TABLE RULE t_order;
 - Drop resource
 
 ```sql
-DROP RESOURCE ds_0, ds_1;
+UNREGISTER STORAGE UNIT ds_0, ds_1;
 ```
 
 - Drop distributed database
diff --git a/features/readwrite-splitting/distsql/parser/src/main/antlr4/imports/readwrite-splitting/BaseRule.g4 b/features/readwrite-splitting/distsql/parser/src/main/antlr4/imports/readwrite-splitting/BaseRule.g4
index 5bbe04b19da..082bf1718b6 100644
--- a/features/readwrite-splitting/distsql/parser/src/main/antlr4/imports/readwrite-splitting/BaseRule.g4
+++ b/features/readwrite-splitting/distsql/parser/src/main/antlr4/imports/readwrite-splitting/BaseRule.g4
@@ -26,3 +26,7 @@ databaseName
 resourceName
     : IDENTIFIER
     ;
+
+groupName
+    : IDENTIFIER
+    ;
diff --git a/features/readwrite-splitting/distsql/parser/src/main/antlr4/imports/readwrite-splitting/RALStatement.g4 b/features/readwrite-splitting/distsql/parser/src/main/antlr4/imports/readwrite-splitting/RALStatement.g4
index ee25f3cd37c..9973fc13a7d 100644
--- a/features/readwrite-splitting/distsql/parser/src/main/antlr4/imports/readwrite-splitting/RALStatement.g4
+++ b/features/readwrite-splitting/distsql/parser/src/main/antlr4/imports/readwrite-splitting/RALStatement.g4
@@ -31,16 +31,12 @@ clearReadwriteSplittingHint
     : CLEAR READWRITE_SPLITTING HINT
     ;
 
-enableReadDataSource
-    : ENABLE READWRITE_SPLITTING (READ)? resourceName (FROM databaseName)?
+alterReadwriteSplittingRuleStatus
+    : ALTER READWRITE_SPLITTING RULE (groupName)? (ENABLE | DISABLE) resourceName (FROM databaseName)?
     ;
 
-disableReadDataSource
-    : DISABLE READWRITE_SPLITTING (READ)? resourceName (FROM databaseName)?
-    ;
-
-showReadwriteSplittingReadResources
-    : SHOW READWRITE_SPLITTING READ RESOURCES (FROM databaseName)?
+showStatusFromReadwriteSplittingRules
+    : SHOW STATUS FROM READWRITE_SPLITTING (RULES | RULE groupName) (FROM databaseName)?
     ;
 
 sourceValue
diff --git a/features/readwrite-splitting/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingDistSQLStatement.g4 b/features/readwrite-splitting/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingDistSQLStatement.g4
index 04968b24bd0..97c450a5bae 100644
--- a/features/readwrite-splitting/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingDistSQLStatement.g4
+++ b/features/readwrite-splitting/distsql/parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingDistSQLStatement.g4
@@ -27,9 +27,8 @@ execute
     | setReadwriteSplittingHintSource
     | showReadwriteSplittingHintStatus
     | clearReadwriteSplittingHint
-    | enableReadDataSource
-    | disableReadDataSource
-    | showReadwriteSplittingReadResources
+    | alterReadwriteSplittingRuleStatus
+    | showStatusFromReadwriteSplittingRules
     | countReadwriteSplittingRule
     ) SEMI?
     ;
diff --git a/features/readwrite-splitting/distsql/parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java b/features/readwrite-splitting/distsql/parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java
index a599c5bb0eb..72203b1f7a7 100644
--- a/features/readwrite-splitting/distsql/parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java
+++ b/features/readwrite-splitting/distsql/parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java
@@ -22,18 +22,17 @@ import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQ
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.AlgorithmDefinitionContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.AlgorithmPropertyContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.AlterReadwriteSplittingRuleContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.AlterReadwriteSplittingRuleStatusContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.ClearReadwriteSplittingHintContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.CountReadwriteSplittingRuleContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.CreateReadwriteSplittingRuleContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.DatabaseNameContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.DisableReadDataSourceContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.DropReadwriteSplittingRuleContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.EnableReadDataSourceContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.ReadwriteSplittingRuleDefinitionContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.SetReadwriteSplittingHintSourceContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.ShowReadwriteSplittingHintStatusContext;
-import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.ShowReadwriteSplittingReadResourcesContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.ShowReadwriteSplittingRulesContext;
+import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.ShowStatusFromReadwriteSplittingRulesContext;
 import org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingDistSQLStatementParser.StaticReadwriteSplittingRuleDefinitionContext;
 import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import org.apache.shardingsphere.readwritesplitting.distsql.parser.segment.ReadwriteSplittingRuleSegment;
@@ -77,15 +76,12 @@ public final class ReadwriteSplittingDistSQLStatementVisitor extends ReadwriteSp
     }
     
     @Override
-    public ASTNode visitEnableReadDataSource(final EnableReadDataSourceContext ctx) {
-        DatabaseSegment schemaSegment = Objects.nonNull(ctx.databaseName()) ? (DatabaseSegment) visit(ctx.databaseName()) : null;
-        return new SetReadwriteSplittingStatusStatement(ctx.ENABLE().getText().toUpperCase(), getIdentifierValue(ctx.resourceName()), schemaSegment);
-    }
-    
-    @Override
-    public ASTNode visitDisableReadDataSource(final DisableReadDataSourceContext ctx) {
-        DatabaseSegment schemaSegment = Objects.nonNull(ctx.databaseName()) ? (DatabaseSegment) visit(ctx.databaseName()) : null;
-        return new SetReadwriteSplittingStatusStatement(ctx.DISABLE().getText().toUpperCase(), getIdentifierValue(ctx.resourceName()), schemaSegment);
+    public ASTNode visitAlterReadwriteSplittingRuleStatus(final AlterReadwriteSplittingRuleStatusContext ctx) {
+        DatabaseSegment databaseSegment = Objects.nonNull(ctx.databaseName()) ? (DatabaseSegment) visit(ctx.databaseName()) : null;
+        String groupName = getIdentifierValue(ctx.groupName());
+        String status = null == ctx.ENABLE() ? ctx.DISABLE().getText().toUpperCase() : ctx.ENABLE().getText().toUpperCase();
+        String resourceName = getIdentifierValue(ctx.resourceName());
+        return new SetReadwriteSplittingStatusStatement(databaseSegment, groupName, resourceName, status);
     }
     
     @Override
@@ -123,8 +119,10 @@ public final class ReadwriteSplittingDistSQLStatementVisitor extends ReadwriteSp
     }
     
     @Override
-    public ASTNode visitShowReadwriteSplittingReadResources(final ShowReadwriteSplittingReadResourcesContext ctx) {
-        return new ShowReadwriteSplittingReadResourcesStatement(Objects.nonNull(ctx.databaseName()) ? (DatabaseSegment) visit(ctx.databaseName()) : null);
+    public ASTNode visitShowStatusFromReadwriteSplittingRules(final ShowStatusFromReadwriteSplittingRulesContext ctx) {
+        DatabaseSegment databaseSegment = Objects.nonNull(ctx.databaseName()) ? (DatabaseSegment) visit(ctx.databaseName()) : null;
+        String groupName = getIdentifierValue(ctx.groupName());
+        return new ShowReadwriteSplittingReadResourcesStatement(databaseSegment, groupName);
     }
     
     @Override
diff --git a/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/ShowReadwriteSplittingReadResourcesStatement.java b/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/ShowReadwriteSplittingReadResourcesStatement.java
index b8bc569c10a..cef193fe0c5 100644
--- a/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/ShowReadwriteSplittingReadResourcesStatement.java
+++ b/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/ShowReadwriteSplittingReadResourcesStatement.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.readwritesplitting.distsql.parser.statement;
 
+import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DatabaseSegment;
@@ -27,13 +28,18 @@ import java.util.Optional;
 /**
  * Show readwrite-splitting read resources statement.
  */
+
+@Getter
 @RequiredArgsConstructor
 public final class ShowReadwriteSplittingReadResourcesStatement extends QueryableRALStatement implements FromDatabaseAvailable {
     
-    private final DatabaseSegment schema;
+    private final DatabaseSegment database;
+    
+    private final String groupName;
     
     @Override
     public Optional<DatabaseSegment> getDatabase() {
-        return Optional.ofNullable(schema);
+        return Optional.ofNullable(database);
     }
+    
 }
diff --git a/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/status/SetReadwriteSplittingStatusStatement.java b/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/status/SetReadwriteSplittingStatusStatement.java
index 9052ae5462f..d8fdc4ad1a3 100644
--- a/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/status/SetReadwriteSplittingStatusStatement.java
+++ b/features/readwrite-splitting/distsql/statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/status/SetReadwriteSplittingStatusStatement.java
@@ -32,11 +32,13 @@ import java.util.Optional;
 @Getter
 public class SetReadwriteSplittingStatusStatement extends UpdatableRALStatement implements FromDatabaseAvailable {
     
-    private final String status;
+    private final DatabaseSegment database;
+    
+    private final String groupName;
     
     private final String resourceName;
     
-    private final DatabaseSegment database;
+    private final String status;
     
     @Override
     public Optional<DatabaseSegment> getDatabase() {
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowReadwriteSplittingReadResourcesHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowReadwriteSplittingReadResourcesHandler.java
index bc178f81b7a..bdc74baef3b 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowReadwriteSplittingReadResourcesHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowReadwriteSplittingReadResourcesHandler.java
@@ -18,10 +18,10 @@
 package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable;
 
 import com.google.common.base.Strings;
-import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
-import org.apache.shardingsphere.infra.distsql.constant.ExportableItemConstants;
 import org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSelectedException;
 import org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
+import org.apache.shardingsphere.infra.distsql.constant.ExportableConstants;
+import org.apache.shardingsphere.infra.distsql.constant.ExportableItemConstants;
 import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDatabase;
@@ -70,7 +70,7 @@ public final class ShowReadwriteSplittingReadResourcesHandler extends QueryableR
         String databaseName = getDatabaseName();
         MetaDataContexts metaDataContexts = contextManager.getMetaDataContexts();
         ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(databaseName);
-        Collection<String> allReadResources = getAllReadResources(database);
+        Collection<String> allReadResources = getAllReadResources(database, getSqlStatement().getGroupName());
         Map<String, StorageNodeDataSource> persistentReadResources = getPersistentReadResources(databaseName, metaDataContexts.getPersistService());
         return buildRows(allReadResources, persistentReadResources);
     }
@@ -86,12 +86,16 @@ public final class ShowReadwriteSplittingReadResourcesHandler extends QueryableR
         return result;
     }
     
-    private Collection<String> getAllReadResources(final ShardingSphereDatabase database) {
+    private Collection<String> getAllReadResources(final ShardingSphereDatabase database, final String groupName) {
         Collection<String> exportKeys = Arrays.asList(ExportableConstants.EXPORT_STATIC_READWRITE_SPLITTING_RULE, ExportableConstants.EXPORT_DYNAMIC_READWRITE_SPLITTING_RULE);
         Map<String, Object> exportMap = database.getRuleMetaData().getRules().stream().filter(each -> each instanceof ExportableRule).map(each -> (ExportableRule) each)
                 .filter(each -> new RuleExportEngine(each).containExportableKey(exportKeys)).findFirst().map(each -> new RuleExportEngine(each).export(exportKeys)).orElse(Collections.emptyMap());
         Map<String, Map<String, String>> allReadwriteRuleMap = exportMap.values().stream().map(each -> ((Map<String, Map<String, String>>) each).entrySet())
                 .flatMap(Collection::stream).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (v1, v2) -> v2, LinkedHashMap::new));
+        if (!Strings.isNullOrEmpty(groupName)) {
+            allReadwriteRuleMap = allReadwriteRuleMap.entrySet().stream().filter(each -> groupName.equalsIgnoreCase(each.getKey()))
+                    .collect(Collectors.toMap(Entry::getKey, Entry::getValue, (v1, v2) -> v2, LinkedHashMap::new));
+        }
         return allReadwriteRuleMap.values().stream().map(each -> each.get(ExportableItemConstants.REPLICA_DATA_SOURCE_NAMES)).filter(each -> null != each && !each.isEmpty())
                 .map(this::deconstructString).flatMap(Collection::stream).collect(Collectors.toCollection(LinkedHashSet::new));
     }
diff --git a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
index 116465656fb..cf7127408b3 100644
--- a/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
+++ b/proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetReadwriteSplittingStatusHandler.java
@@ -74,7 +74,13 @@ public final class SetReadwriteSplittingStatusHandler extends UpdatableRALBacken
             checkEnable(contextManager, databaseName, disabledResources, toBeUpdatedResource);
         }
         Collection<String> groupNames = getGroupNames(toBeUpdatedResource, replicaResources, disabledResources, autoAwareResources);
-        updateStatus(databaseName, groupNames, toBeUpdatedResource, isDisable);
+        String groupName = getSqlStatement().getGroupName();
+        if (Strings.isNullOrEmpty(groupName)) {
+            updateStatus(databaseName, groupNames, toBeUpdatedResource, isDisable);
+        } else {
+            checkGroupName(groupNames, groupName);
+            updateStatus(databaseName, Collections.singleton(groupName), toBeUpdatedResource, isDisable);
+        }
     }
     
     private void checkReadwriteSplittingRule(final ContextManager contextManager, final String databaseName) {
@@ -95,6 +101,10 @@ public final class SetReadwriteSplittingStatusHandler extends UpdatableRALBacken
         }
     }
     
+    private void checkGroupName(final Collection<String> groupNames, final String groupName) {
+        ShardingSpherePreconditions.checkState(groupNames.contains(groupName), () -> new UnsupportedSQLOperationException(String.format("The current schema does not contain %s", groupName)));
+    }
+    
     private Map<String, String> getReplicaResources(final ContextManager contextManager, final String databaseName) {
         Map<String, Map<String, String>> readwriteSplittingRules = getExportedReadwriteSplittingRules(contextManager, databaseName);
         Map<String, String> result = new HashMap<>();
diff --git a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index 6a5ed5f23b6..aedf1e04817 100644
--- a/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++ b/test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -1140,7 +1140,7 @@ public final class SQLParserTestCases {
     @XmlElement(name = "clone")
     private final List<CloneStatementTestCase> cloneTestCases = new LinkedList<>();
     
-    @XmlElement(name = "show-readwrite-splitting-read-resources")
+    @XmlElement(name = "show-status-from-readwrite-splitting-rules")
     private final List<ShowReadwriteSplittingReadResourcesStatementTestCase> showReadwriteSplittingReadResourcesTestCases = new LinkedList<>();
     
     @XmlElement(name = "uninstall-component")
diff --git a/test/parser/src/main/resources/case/ral/queryable.xml b/test/parser/src/main/resources/case/ral/queryable.xml
index 8fd3266144c..b93a1b3dc8e 100644
--- a/test/parser/src/main/resources/case/ral/queryable.xml
+++ b/test/parser/src/main/resources/case/ral/queryable.xml
@@ -20,7 +20,7 @@
     <show-dist-variable sql-case-id="show-dist-variable" name="CACHED_CONNECTIONS" />
     <show-dist-variables sql-case-id="show-dist-variables" />
     
-    <show-readwrite-splitting-read-resources sql-case-id="show-readwrite-splitting-read-resources" />
+    <show-status-from-readwrite-splitting-rules sql-case-id="show-status-from-readwrite-splitting-rules" />
     
     <show-table-metadata sql-case-id="show-table-metadata">
         <table-name>t_order</table-name>
diff --git a/test/parser/src/main/resources/sql/supported/ral/queryable.xml b/test/parser/src/main/resources/sql/supported/ral/queryable.xml
index 764969fd0fb..dc0cc8a4738 100644
--- a/test/parser/src/main/resources/sql/supported/ral/queryable.xml
+++ b/test/parser/src/main/resources/sql/supported/ral/queryable.xml
@@ -20,7 +20,7 @@
     <distsql-case id="show-dist-variable" value="SHOW DIST VARIABLE WHERE NAME = CACHED_CONNECTIONS" />
     <distsql-case id="show-dist-variables" value="SHOW DIST VARIABLES" />
     
-    <distsql-case id="show-readwrite-splitting-read-resources" value="SHOW READWRITE_SPLITTING READ RESOURCES" />
+    <distsql-case id="show-status-from-readwrite-splitting-rules" value="SHOW STATUS FROM READWRITE_SPLITTING RULES" />
     
     <distsql-case id="show-table-metadata" value="SHOW TABLE METADATA t_order FROM database_name" />