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 a48334d  [DistSQL] Optimize some minor problems in DistSQL (#13844)
a48334d is described below

commit a48334d3439a33545aa5cab996d9eb96e4f2910a
Author: lanchengx <[email protected]>
AuthorDate: Mon Nov 29 04:29:41 2021 -0600

    [DistSQL] Optimize some minor problems in DistSQL (#13844)
    
    * `enable/disable instance statement` adds adaptation to instanceId.
    
    * `enable/disable instance statement` adds adaptation to instanceId.
    
    * Improve `refresh table metadata` statement.
    
    * Adjust the `shardingColumn` and `shardingAlgorithm` of the `create/alter 
sharding table rule` statement as required items.
    
    * Adjust the `shardingColumn` and `shardingAlgorithm` of the `create/alter 
sharding table rule` statement as required items.
    
    * `enable/disable instance statement` adds adaptation to instanceId.
    
    * Add documents related to `single table`.
    
    * Improve `refresh table metadata` statement.
    
    * Improve `refresh table metadata` statement.
    
    * Adjust the shadow document format.
---
 .../distsql/syntax/ral/_index.cn.md                | 29 ++++++++++----------
 .../distsql/syntax/ral/_index.en.md                | 29 ++++++++++----------
 .../syntax/rdl/rule-definition/db-discovery.cn.md  |  2 +-
 .../syntax/rdl/rule-definition/db-discovery.en.md  |  2 +-
 .../syntax/rdl/rule-definition/encrypt.cn.md       |  2 +-
 .../syntax/rdl/rule-definition/encrypt.en.md       |  2 +-
 .../rdl/rule-definition/readwrite-splitting.cn.md  |  2 +-
 .../rdl/rule-definition/readwrite-splitting.en.md  |  2 +-
 .../syntax/rdl/rule-definition/shadow.cn.md        |  4 +--
 .../syntax/rdl/rule-definition/shadow.en.md        |  4 +--
 .../syntax/rdl/rule-definition/sharding.cn.md      |  2 +-
 .../syntax/rdl/rule-definition/sharding.en.md      |  2 +-
 .../syntax/rdl/rule-definition/single-table.cn.md  | 31 ++++++++++++++++++++++
 .../syntax/rdl/rule-definition/single-table.en.md  | 31 ++++++++++++++++++++++
 .../src/main/antlr4/imports/RALStatement.g4        | 13 +++++++--
 .../core/common/CommonDistSQLStatementVisitor.java | 27 ++++++++++++++-----
 .../main/antlr4/imports/sharding/RDLStatement.g4   |  2 +-
 .../ral/common/RefreshTableMetadataHandler.java    |  2 +-
 18 files changed, 138 insertions(+), 50 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 ec65d9e..f6d8544 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
@@ -41,26 +41,27 @@ RAL (Resource & Rule Administration Language) 为 Apache 
ShardingSphere 的管
 | 语句                                                           | 说明            
                                    | 示例                                        
    |
 |:------------------------------------------------------------- 
|:-------------------------------------------------- 
|:----------------------------------------------  |
 | [enable / disable] readwrite_splitting read xxx [from schema] | 启用 / 禁用读库    
                                  | enable readwrite_splitting read resource_0  
    |
-| [enable / disable] instance IP=xxx, PORT=xxx                  | 启用 / 禁用 
proxy 实例                               | disable instance IP=127.0.0.1, 
PORT=3307        |
+| [enable / disable] instance [IP=xxx, PORT=xxx / instanceId]   | 启用 / 禁用 
proxy 实例                               | disable instance 127.0.0.1@3307        
    |
 | show instance list                                            | 查询 proxy 
实例信息                                  | show instance list                      
        |
 | show readwrite_splitting read resources [from schema]         | 查询所有读库的状态    
                                | show readwrite_splitting read resources       
  |
 
 
 ## 其他
 
-| 语句                                                 | 说明                      
                                   | 示例                                         
   |
-|:--------------------------------------------------- 
|:----------------------------------------------------------- 
|:----------------------------------------------- |
-| set variable proxy_property_name = xx               | proxy_property_name 为 
proxy 的[属性配置](/cn/user-manual/shardingsphere-proxy/configuration/props/) 
,需使用下划线命名 | set variable sql_show = true            |
-| set variable transaction_type = xx                  | 修改当前连接的事务类型, 支持 
LOCAL,XA,BASE                     | set variable transaction_type = XA          
     |
-| set variable agent_plugins_enabled = [true / false] | 设置 agent 插件的启用状态,默认值 
false                         | set variable agent_plugins_enabled = true       
 |
-| show all variables                                  | 查询 proxy 所有的属性配置       
                               | show all variable                              
  |
-| show variable proxy_property_name                   | 查询 proxy 属性配置,需使用下划线命名 
                           | show variable sql_show                           |
-| show variable transaction_type                      | 查询当前连接的事务类型            
                             | show variable transaction_type                   
|
-| show variable cached_connections                    | 查询当前连接中缓存的物理数据库连接个数    
                        | show variable cached_connections                 |
-| show variable agent_plugins_enabled                 | 查询 agent 插件的启用状态       
                              | show variable agent_plugins_enabled             
 |
-| preview SQL                                         | 预览实际 SQL               
                                 | preview select * from t_order                
    |
-| parse SQL                                           | 解析实际 SQL               
                                 | parse select * from t_order                  
    |
-| refresh table metadata [table]                      | 刷新所有表或者指定表的元数据         
                           | refresh table metadata                          |
+| 语句                                                                         | 
说明                                                         | 示例                 
                           |
+|:--------------------------------------------------------------------------- 
|:----------------------------------------------------------- 
|:----------------------------------------------- |
+| set variable proxy_property_name = xx                                       
| proxy_property_name 为 proxy 
的[属性配置](/cn/user-manual/shardingsphere-proxy/configuration/props/) ,需使用下划线命名 | 
set variable sql_show = true            |
+| set variable transaction_type = xx                                          
| 修改当前连接的事务类型, 支持 LOCAL,XA,BASE                     | set variable 
transaction_type = XA               |
+| set variable agent_plugins_enabled = [true / false]                         
| 设置 agent 插件的启用状态,默认值 false                         | set variable 
agent_plugins_enabled = true        |
+| show all variables                                                          
| 查询 proxy 所有的属性配置                                      | show all variable     
                           |
+| show variable proxy_property_name                                           
| 查询 proxy 属性配置,需使用下划线命名                            | show variable sql_show    
                       |
+| show variable transaction_type                                              
| 查询当前连接的事务类型                                          | show variable 
transaction_type                   |
+| show variable cached_connections                                            
| 查询当前连接中缓存的物理数据库连接个数                             | show variable 
cached_connections                 |
+| show variable agent_plugins_enabled                                         
| 查询 agent 插件的启用状态                                       | show variable 
agent_plugins_enabled              |
+| preview SQL                                                                 
| 预览实际 SQL                                                  | preview select * 
from t_order                    |
+| parse SQL                                                                   
| 解析实际 SQL                                                  | parse select * 
from t_order                      |
+| refresh table metadata                                                      
| 刷新所有表的元数据                                              | refresh table 
metadata                          |
+| refresh table metadata [tableName / tableName from resource resourceName]   
| 刷新指定表的元数据                                              | refresh table 
metadata t_order from resource ds_1 |
 
 ## 注意事项
 
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 17eee41..22eb790 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
@@ -39,25 +39,26 @@ RAL (Resource & Rule Administration Language) responsible 
for the added-on featu
 | Statement                                                     | Function     
                      | Example                                    |
 |:------------------------------------------------------------- 
|:---------------------------------- 
|:------------------------------------------ |
 | [enable / disable] readwrite_splitting read xxx [from schema] | Enable or 
disable read data source | enable readwrite_splitting read resource_0 |
-| [enable / disable] instance IP=xxx, PORT=xxx                  | Enable or 
disable proxy instance   | disable instance IP=127.0.0.1, PORT=3307   |
+| [enable / disable] instance [IP=xxx, PORT=xxx / instanceId]   | Enable or 
disable proxy instance   | disable instance 127.0.0.1@3307            |
 | show instance list                                            | Query proxy 
instance information   | show instance list                         |
 | show readwrite_splitting read resources [from schema]         | Query all 
read resources status    | show readwrite_splitting read resources    |
 
 ## Other
 
-| Statement                                           | Function               
                                                            | Example           
                        |
-|:--------------------------------------------------- 
|:----------------------------------------------------------------------------------
 |:----------------------------------------- |
-| set variable proxy_property_name = xx               | proxy_property_name is 
one of [properties 
configuration](/en/user-manual/shardingsphere-proxy/configuration/props/)  of 
proxy,name is split by underscore            | set variable sql_show = true     
       |  
-| set variable transaction_type = xx                  | Modify 
transaction_type of the current connection, supports LOCAL, XA, BASE        | 
set variable transaction_type = XA        |
-| set variable agent_plugins_enabled = [true / false] | Set whether the agent 
plugins are enabled, the default value is false              | set variable 
agent_plugins_enabled = true |
-| show all variables                                  | Query proxy all 
properties configuration                                           | show all 
variable                         |
-| show variable proxy_property_name                   | Query proxy properties 
configuration, name is split by underscore                  | show variable 
sql_show                    |
-| show variable transaction_type                      | Query the transaction 
type of the current connection                               | show variable 
transaction_type            |
-| show variable cached_connections                    | Query the number of 
cached physical database connections in the current connection | show variable 
cached_connections          |
-| show variable agent_plugins_enabled                 | Query whether the 
agent plugin are enabled                                         | show 
variable agent_plugins_enabled       |
-| preview SQL                                         | Preview the actual 
SQLs                                                            | preview 
select * from t_order             |
-| parse SQL                                           | Parse the actual SQLs  
                                                             | parse select * 
from t_order             |
-| refresh table metadata [table]                      | Refresh the metadata 
of all tables or a table                                      | refresh table 
metadata                    |
+| Statement                                                                   
| Function                                                                      
     | Example                                   |
+|:--------------------------------------------------------------------------- 
|:----------------------------------------------------------------------------------
 |:----------------------------------------- |
+| set variable proxy_property_name = xx                                       
| proxy_property_name is one of [properties 
configuration](/en/user-manual/shardingsphere-proxy/configuration/props/)  of 
proxy,name is split by underscore            | set variable sql_show = true     
       |  
+| set variable transaction_type = xx                                          
| Modify transaction_type of the current connection, supports LOCAL, XA, BASE   
     | set variable transaction_type = XA        |
+| set variable agent_plugins_enabled = [true / false]                         
| Set whether the agent plugins are enabled, the default value is false         
     | set variable agent_plugins_enabled = true |
+| show all variables                                                          
| Query proxy all properties configuration                                      
     | show all variable                         |
+| show variable proxy_property_name                                           
| Query proxy properties configuration, name is split by underscore             
     | show variable sql_show                    |
+| show variable transaction_type                                              
| Query the transaction type of the current connection                          
     | show variable transaction_type            |
+| show variable cached_connections                                            
| Query the number of cached physical database connections in the current 
connection | show variable cached_connections          |
+| show variable agent_plugins_enabled                                         
| Query whether the agent plugin are enabled                                    
     | show variable agent_plugins_enabled       |
+| preview SQL                                                                 
| Preview the actual SQLs                                                       
     | preview select * from t_order             |
+| parse SQL                                                                   
| Parse the actual SQLs                                                         
     | parse select * from t_order               |
+| refresh table metadata                                                      
| Refresh the metadata of all tables                                            
     | refresh table metadata                    |
+| refresh table metadata [tableName / tableName from resource resourceName]   
| Refresh the metadata of a table                                               
     | refresh table metadata t_order from resource ds_1                   |
 
 ## Notice
 
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/db-discovery.cn.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/db-discovery.cn.md
index 74ee8fd..312aa41 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/db-discovery.cn.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/db-discovery.cn.md
@@ -1,6 +1,6 @@
 +++
 title = "数据库发现"
-weight = 3
+weight = 4
 +++
 
 ## 语法说明
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/db-discovery.en.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/db-discovery.en.md
index 22bd621..9ab39a2 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/db-discovery.en.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/db-discovery.en.md
@@ -1,6 +1,6 @@
 +++
 title = "DB Discovery"
-weight = 3
+weight = 4
 +++
 
 ## Syntax
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt.cn.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt.cn.md
index 4b819c1..8070ddb 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt.cn.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt.cn.md
@@ -1,6 +1,6 @@
 +++
 title = "数据加密"
-weight = 4
+weight = 5
 +++
 
 ## 语法说明
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt.en.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt.en.md
index 75b7b5e..647ba30 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt.en.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt.en.md
@@ -1,6 +1,6 @@
 +++
 title = "Encrypt"
-weight = 4
+weight = 5
 +++
 
 ## Syntax
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting.cn.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting.cn.md
index 3b88ce9..7cb6290 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting.cn.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting.cn.md
@@ -1,6 +1,6 @@
 +++
 title = "读写分离"
-weight = 2
+weight = 3
 +++
 
 ## 语法说明
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting.en.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting.en.md
index 39c7ead..747d23f 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting.en.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting.en.md
@@ -1,6 +1,6 @@
 +++
 title = "Readwrite-Splitting"
-weight = 2
+weight = 3
 +++
 
 ## Syntax
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow.cn.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow.cn.md
index 4948063..d3e88c4 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow.cn.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow.cn.md
@@ -1,6 +1,6 @@
 +++
 title = "影子库压测"
-weight = 5
+weight = 6
 +++
 
 ## 语法说明
@@ -9,7 +9,7 @@ weight = 5
 CREATE SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ... 
 
 ALTER SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ... 
-``
+
 CREATE SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
 
 ALTER SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow.en.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow.en.md
index f7d794c..3e6d55d 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow.en.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow.en.md
@@ -1,6 +1,6 @@
 +++
 title = "Shadow"
-weight = 5
+weight = 6
 +++
 
 ## Syntax
@@ -9,7 +9,7 @@ weight = 5
 CREATE SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ... 
 
 ALTER SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ... 
-```
+
 CREATE SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
 
 ALTER SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
index 6adca0f..cedb53f 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.cn.md
@@ -26,7 +26,7 @@ shardingTableRuleDefinition:
     shardingAutoTableRule | shardingTableRule
    
 shardingAutoTableRule:
-    tableName(resources (COMMA shardingColumn)? (COMMA algorithmDefinition)? 
(COMMA keyGenerateStrategy)?)
+    tableName(resources COMMA shardingColumn COMMA algorithmDefinition (COMMA 
keyGenerateStrategy)?)
     
 shardingTableRule:
     tableName(dataNodes (COMMA  databaseStrategy)? (COMMA tableStrategy)? 
(COMMA keyGenerateStrategy)?)
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
index 1745e47..fc6fe58 100644
--- 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding.en.md
@@ -26,7 +26,7 @@ shardingTableRuleDefinition:
     shardingAutoTableRule | shardingTableRule
    
 shardingAutoTableRule:
-    tableName(resources (COMMA shardingColumn)? (COMMA algorithmDefinition)? 
(COMMA keyGenerateStrategy)?)
+    tableName(resources COMMA shardingColumn COMMA algorithmDefinition (COMMA 
keyGenerateStrategy)?)
     
 shardingTableRule:
     tableName(dataNodes (COMMA  databaseStrategy)? (COMMA tableStrategy)? 
(COMMA keyGenerateStrategy)?)
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/single-table.cn.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/single-table.cn.md
new file mode 100644
index 0000000..f9a4ae8
--- /dev/null
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/single-table.cn.md
@@ -0,0 +1,31 @@
++++
+title = "单表"
+weight = 2
++++
+
+## 定义
+
+```sql
+CREATE DEFAULT SINGLE TABLE RULE singleTableRuleDefinition
+
+ALTER DEFAULT SINGLE TABLE RULE singleTableRuleDefinition
+
+DROP DEFAULT SINGLE TABLE RULE
+
+singleTableRuleDefinition:
+    RESOURCE = resourceName
+```
+- `RESOURCE` 需使用 RDL 管理的数据源资源
+
+
+## 示例
+
+### Single Table Rule
+
+```sql
+CREATE DEFAULT SINGLE TABLE RULE RESOURCE = ds_0
+
+ALTER DEFAULT SINGLE TABLE RULE RESOURCE = ds_1
+
+DROP DEFAULT SINGLE TABLE RULE
+```
diff --git 
a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/single-table.en.md
 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/single-table.en.md
new file mode 100644
index 0000000..ed2e239
--- /dev/null
+++ 
b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/single-table.en.md
@@ -0,0 +1,31 @@
++++
+title = "Single Table"
+weight = 2
++++
+
+## Definition
+
+```sql
+CREATE DEFAULT SINGLE TABLE RULE singleTableRuleDefinition
+
+ALTER DEFAULT SINGLE TABLE RULE singleTableRuleDefinition
+
+DROP DEFAULT SINGLE TABLE RULE
+
+singleTableRuleDefinition:
+    RESOURCE = resourceName
+```
+- `RESOURCE` needs to use data source resource managed by RDL
+
+
+## Example
+
+### Single Table Rule
+
+```sql
+CREATE DEFAULT SINGLE TABLE RULE RESOURCE = ds_0
+
+ALTER DEFAULT SINGLE TABLE RULE RESOURCE = ds_1
+
+DROP DEFAULT SINGLE TABLE RULE
+```
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
index 9e1a80e..178e6e4 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/antlr4/imports/RALStatement.g4
@@ -32,11 +32,11 @@ showAllVariables
     ;
 
 enableInstance
-    :ENABLE INSTANCE IP EQ ip COMMA PORT EQ port
+    :ENABLE INSTANCE (instanceId | instanceDefination)
     ;
 
 disableInstance
-    :DISABLE INSTANCE IP EQ ip COMMA PORT EQ port
+    :DISABLE INSTANCE (instanceId | instanceDefination)
     ;
 
 showInstance
@@ -59,6 +59,14 @@ variableValue
     : IDENTIFIER | STRING | (MINUS)? INT 
     ;
 
+instanceDefination
+    : IP EQ ip COMMA PORT EQ port
+    ;
+    
+instanceId
+    : ip AT port
+    ;
+    
 ip
     : IDENTIFIER | NUMBER+
     ;
@@ -66,6 +74,7 @@ ip
 port
     : INT
     ;
+    
 refreshScope
     : tableName | tableName FROM RESOURCE resourceName
     ;
diff --git 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
index 274c2f6..f7be4c2 100644
--- 
a/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
+++ 
b/shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
@@ -29,6 +29,8 @@ import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementPa
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.DropDefaultSingleTableRuleContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.DropResourceContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.EnableInstanceContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.InstanceDefinationContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.InstanceIdContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PasswordContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PoolPropertiesContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PoolPropertyContext;
@@ -42,10 +44,10 @@ import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementPa
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowSingleTableRulesContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowVariableContext;
 import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.RefreshTableMetadataStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearHintStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetInstanceStatusStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.set.SetVariableStatement;
-import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.RefreshTableMetadataStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowAllVariablesStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowInstanceStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.show.ShowVariableStatement;
@@ -107,18 +109,31 @@ public final class CommonDistSQLStatementVisitor extends 
CommonDistSQLStatementB
     }
     
     @Override
-    public ASTNode visitEnableInstance(final EnableInstanceContext ctx) {
-        return new 
SetInstanceStatusStatement(ctx.ENABLE().getText().toUpperCase(), new 
IdentifierValue(ctx.ip().getText()).getValue(), ctx.port().getText());
+    public ASTNode visitShowInstance(final ShowInstanceContext ctx) {
+        return new ShowInstanceStatement();
     }
     
     @Override
-    public ASTNode visitShowInstance(final ShowInstanceContext ctx) {
-        return new ShowInstanceStatement();
+    public ASTNode visitEnableInstance(final EnableInstanceContext ctx) {
+        return 
buildSetInstanceStatusStatement(ctx.ENABLE().getText().toUpperCase(), 
ctx.instanceDefination(), ctx.instanceId());
     }
     
     @Override
     public ASTNode visitDisableInstance(final DisableInstanceContext ctx) {
-        return new 
SetInstanceStatusStatement(ctx.DISABLE().getText().toUpperCase(), new 
IdentifierValue(ctx.ip().getText()).getValue(), ctx.port().getText());
+        return 
buildSetInstanceStatusStatement(ctx.DISABLE().getText().toUpperCase(), 
ctx.instanceDefination(), ctx.instanceId());
+    }
+    
+    private SetInstanceStatusStatement buildSetInstanceStatusStatement(final 
String status, final InstanceDefinationContext instanceDefinationContext, final 
InstanceIdContext instanceIdContext) {
+        String ip;
+        String port;
+        if (null != instanceDefinationContext) {
+            ip = getIdentifierValue(instanceDefinationContext.ip());
+            port = getIdentifierValue(instanceDefinationContext.port());
+        } else {
+            ip = getIdentifierValue(instanceIdContext.ip());
+            port = getIdentifierValue(instanceIdContext.port());
+        }
+        return new SetInstanceStatusStatement(status, ip, port);
     }
     
     @Override
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
index fe6cd2d..85c1b77c 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RDLStatement.g4
@@ -76,7 +76,7 @@ shardingTableRuleDefinition
     ;
 
 shardingAutoTableRule
-    : tableName LP resources (COMMA shardingColumn)? (COMMA 
algorithmDefinition)? (COMMA keyGenerateStrategy)? RP
+    : tableName LP resources COMMA shardingColumn COMMA algorithmDefinition 
(COMMA keyGenerateStrategy)? RP
     ;
 
 shardingTableRule
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/RefreshTableMetadataHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/RefreshTableMetadataHandler.java
index f1f8727..8148004 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/RefreshTableMetadataHandler.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/RefreshTableMetadataHandler.java
@@ -42,7 +42,7 @@ public final class RefreshTableMetadataHandler extends 
SchemaRequiredBackendHand
     protected ResponseHeader execute(final String schemaName, final 
RefreshTableMetadataStatement sqlStatement) throws SQLException {
         ContextManager contextManager = 
ProxyContext.getInstance().getContextManager();
         if (sqlStatement.getResourceName().isPresent()) {
-            // TODO  From the specified resource
+            contextManager.reloadMetaData(schemaName, 
sqlStatement.getTableName().get(), sqlStatement.getResourceName().get());
             return new UpdateResponseHeader(sqlStatement);
         }
         if (sqlStatement.getTableName().isPresent()) {

Reply via email to