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

panjuan 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 2af401f  Update RQL syntax `show schema resources [from schemaName]`. 
(#13027)
2af401f is described below

commit 2af401f76b4f57aee34a03f8b3067e45489a90b2
Author: Raigor <[email protected]>
AuthorDate: Thu Oct 14 13:00:05 2021 +0800

    Update RQL syntax `show schema resources [from schemaName]`. (#13027)
    
    * Update RQL syntax `show resources info [from schemaName]`.
    
    * Update RQL syntax `show schema resources [from schemaName]`.
---
 .../content/features/dist-sql/syntax/rql/rql-resource.cn.md         | 4 ++--
 .../content/features/dist-sql/syntax/rql/rql-resource.en.md         | 4 ++--
 .../src/main/antlr4/imports/Keyword.g4                              | 4 ++++
 .../src/main/antlr4/imports/RQLStatement.g4                         | 2 +-
 .../distsql/parser/core/common/CommonDistSQLStatementVisitor.java   | 2 +-
 .../src/test/resources/cases/rdl/rdl-integration-test-cases.xml     | 6 +++---
 .../src/test/resources/cases/rql/rql-integration-test-cases.xml     | 2 +-
 7 files changed, 14 insertions(+), 10 deletions(-)

diff --git 
a/docs/document/content/features/dist-sql/syntax/rql/rql-resource.cn.md 
b/docs/document/content/features/dist-sql/syntax/rql/rql-resource.cn.md
index 0d03b0f..3216efc 100644
--- a/docs/document/content/features/dist-sql/syntax/rql/rql-resource.cn.md
+++ b/docs/document/content/features/dist-sql/syntax/rql/rql-resource.cn.md
@@ -6,7 +6,7 @@ weight = 1
 ## 定义
 
 ```sql
-SHOW RESOURCES FROM schemaName
+SHOW SCHEMA RESOURCES [FROM schemaName]
 ```
 
 ## 说明
@@ -23,7 +23,7 @@ SHOW RESOURCES FROM schemaName
 ## 示例
 
 ```sql
-mysql> show resources from sharding_db;
+mysql> show schema resources;
 
+------+-------+-----------+------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | name | type  | host      | port | db   | attribute                           
                                                                                
                                                                                
|
 
+------+-------+-----------+------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
diff --git 
a/docs/document/content/features/dist-sql/syntax/rql/rql-resource.en.md 
b/docs/document/content/features/dist-sql/syntax/rql/rql-resource.en.md
index 4c8c28b..84e65d0 100644
--- a/docs/document/content/features/dist-sql/syntax/rql/rql-resource.en.md
+++ b/docs/document/content/features/dist-sql/syntax/rql/rql-resource.en.md
@@ -6,7 +6,7 @@ weight = 1
 ## Definition
 
 ```sql
-SHOW RESOURCES FROM schemaName
+SHOW SCHEMA RESOURCES [FROM schemaName]
 ```
 
 ## Description
@@ -23,7 +23,7 @@ SHOW RESOURCES FROM schemaName
 ## Example
 
 ```sql
-mysql> show resources from sharding_db;
+mysql> show schema resources;
 
+------+-------+-----------+------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 | name | type  | host      | port | db   | attribute                           
                                                                                
                                                                                
|
 
+------+-------+-----------+------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
index eca6f46..3b26900 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
@@ -119,6 +119,10 @@ IGNORE
     : I G N O R E
     ;
 
+SCHEMA
+    : S C H E M A
+    ;
+
 SINGLE
     : S I N G L E
     ;
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RQLStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RQLStatement.g4
index e6550c9..8b085f3 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RQLStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RQLStatement.g4
@@ -20,7 +20,7 @@ grammar RQLStatement;
 import Keyword, Literals, Symbol;
 
 showResources
-    : SHOW RESOURCES FROM schemaName
+    : SHOW SCHEMA RESOURCES (FROM schemaName)?
     ;
 
 schemaName
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
index e247885..214bdd9 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
@@ -115,7 +115,7 @@ public final class CommonDistSQLStatementVisitor extends 
CommonDistSQLStatementB
     
     @Override
     public ASTNode visitShowResources(final ShowResourcesContext ctx) {
-        return new ShowResourcesStatement((SchemaSegment) 
visit(ctx.schemaName()));
+        return new ShowResourcesStatement(null == ctx.schemaName() ? null : 
(SchemaSegment) visit(ctx.schemaName()));
     }
     
     @Override
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/rdl-integration-test-cases.xml
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/rdl-integration-test-cases.xml
index 724b54e..89f4453 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/rdl-integration-test-cases.xml
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/rdl-integration-test-cases.xml
@@ -16,7 +16,7 @@
   -->
 <integration-test-cases>
     <!--FIXME! IP CANNOT CONNECT-->
-    <test-case sql="SHOW RESOURCES" db-types="PostgreSQL">
+    <test-case sql="SHOW SCHEMA RESOURCES" db-types="PostgreSQL">
         <assertion expected-data-file="alter_resource.xml">
             <initial-sql sql="ALTER RESOURCE rdl_test_0 
(URL=&quot;jdbc:mysql://mysql.empty_rules.host:3306/rdl_test_0?serverTimezone=UTC&amp;useSSL=false&amp;characterEncoding=utf-8&quot;,
 USER=root, PASSWORD=root,
             
PROPERTIES(&quot;maxPoolSize&quot;=10,&quot;maxPoolSize&quot;=10,&quot;connectionTimeoutMilliseconds&quot;=3000,&quot;idleTimeoutMilliseconds&quot;=6000,&quot;maxLifetimeMilliseconds&quot;=180000));"/>
@@ -25,7 +25,7 @@
         </assertion>
     </test-case>
     
-    <test-case sql="SHOW RESOURCES">
+    <test-case sql="SHOW SCHEMA RESOURCES">
         <assertion expected-data-file="drop_resource.xml">
             <initial-sql sql="DROP RESOURCE rdl_test_0;"/>
             <destroy-sql sql="ADD RESOURCE rdl_test_0 
(URL=&quot;jdbc:mysql://mysql.empty_rules.host:3306/rdl_test_0?serverTimezone=UTC&amp;useSSL=false&amp;characterEncoding=utf-8&quot;,
 USER=root, PASSWORD=root,
@@ -34,7 +34,7 @@
     </test-case>
     
     <!--FIXME! IP CANNOT CONNECT-->
-    <test-case sql="SHOW RESOURCES" db-types="PostgreSQL">
+    <test-case sql="SHOW SCHEMA RESOURCES" db-types="PostgreSQL">
         <assertion expected-data-file="add_resource.xml">
             <initial-sql sql="ADD RESOURCE
                 rdl_test_1 (HOST=&quot;mysql.empty_rules.host&quot;, 
PORT=3306, DB=rdl_test_1, USER=root, PASSWORD=root,
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rql/rql-integration-test-cases.xml
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rql/rql-integration-test-cases.xml
index 597551b..b9de828 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rql/rql-integration-test-cases.xml
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rql/rql-integration-test-cases.xml
@@ -15,7 +15,7 @@
   ~ limitations under the License.
   -->
 <integration-test-cases>
-    <test-case sql="SHOW RESOURCES">
+    <test-case sql="SHOW SCHEMA RESOURCES">
         <assertion expected-data-file="show_resources.xml" />
     </test-case>
     

Reply via email to