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

jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 598080b47f7 Fixed the show regions with specified database & grant / 
revoke with ""
598080b47f7 is described below

commit 598080b47f7fd957a76a4f4fa14a8b2370594161
Author: Caideyipi <[email protected]>
AuthorDate: Tue Mar 25 12:11:42 2025 +0800

    Fixed the show regions with specified database & grant / revoke with ""
---
 .../it/db/it/IoTDBAuthenticationTableIT.java       | 90 +++++++++++-----------
 .../relational/it/db/it/IoTDBInsertTableIT.java    | 39 ++++++++++
 .../confignode/manager/PermissionManager.java      |  2 +
 .../persistence/executor/ConfigPlanExecutor.java   | 10 ++-
 .../execution/config/TableConfigTaskVisitor.java   |  6 +-
 .../config/executor/ClusterConfigTaskExecutor.java |  4 +-
 .../db/queryengine/plan/parser/ASTVisitor.java     |  4 +-
 .../plan/relational/sql/ast/ShowRegions.java       | 43 ++++-------
 .../plan/relational/sql/parser/AstBuilder.java     | 54 +++++++------
 .../statement/metadata/ShowRegionStatement.java    | 29 +++----
 10 files changed, 160 insertions(+), 121 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBAuthenticationTableIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBAuthenticationTableIT.java
index 8e357cd388d..78c53614a84 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBAuthenticationTableIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBAuthenticationTableIT.java
@@ -90,8 +90,8 @@ public class IoTDBAuthenticationTableIT {
   public void testInsert() throws IoTDBConnectionException, 
StatementExecutionException {
 
     try (ITableSession sessionRoot = 
EnvFactory.getEnv().getTableSessionConnection()) {
-      sessionRoot.executeNonQueryStatement("CREATE DATABASE IF NOT EXISTS 
test");
-      sessionRoot.executeNonQueryStatement("USE test");
+      sessionRoot.executeNonQueryStatement("CREATE DATABASE IF NOT EXISTS 
\"汉化\"");
+      sessionRoot.executeNonQueryStatement("USE \"汉化\"");
 
       // insert by root
       Tablet tablet =
@@ -119,7 +119,7 @@ public class IoTDBAuthenticationTableIT {
             "803: Access Denied: Cannot grant/revoke privileges of admin 
user", e.getMessage());
       }
       try {
-        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE test 
FROM USER root");
+        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE \"汉化\" 
FROM USER root");
         fail("Should have thrown an exception");
       } catch (StatementExecutionException e) {
         assertEquals(
@@ -137,15 +137,15 @@ public class IoTDBAuthenticationTableIT {
       sessionRoot.executeNonQueryStatement("CREATE USER userA 'userA'");
       sessionRoot.executeNonQueryStatement("CREATE USER userB 'userB'");
       // grant an irrelevant privilege so that the new users can use database
-      sessionRoot.executeNonQueryStatement("GRANT SELECT ON DATABASE test TO 
USER userA");
-      sessionRoot.executeNonQueryStatement("GRANT SELECT ON DATABASE test TO 
USER userB");
+      sessionRoot.executeNonQueryStatement("GRANT SELECT ON DATABASE \"汉化\" TO 
USER userA");
+      sessionRoot.executeNonQueryStatement("GRANT SELECT ON DATABASE \"汉化\" TO 
USER userB");
 
       try (ITableSession sessionA =
               EnvFactory.getEnv().getTableSessionConnection("userA", "userA");
           ITableSession sessionB =
               EnvFactory.getEnv().getTableSessionConnection("userB", "userB")) 
{
-        sessionA.executeNonQueryStatement("USE test");
-        sessionB.executeNonQueryStatement("USE test");
+        sessionA.executeNonQueryStatement("USE \"汉化\"");
+        sessionB.executeNonQueryStatement("USE \"汉化\"");
         // userA no privilege
         try {
           sessionA.executeNonQueryStatement(
@@ -153,7 +153,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -168,7 +168,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -183,22 +183,22 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
         // grant and revoke - database
-        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE test TO 
USER userA");
+        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE \"汉化\" 
TO USER userA");
         sessionA.executeNonQueryStatement(
             "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
-        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE test 
FROM USER userA");
+        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE \"汉化\" 
FROM USER userA");
         try {
           sessionA.executeNonQueryStatement(
               "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -213,28 +213,28 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
         // can write but cannot auto-create
-        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE test TO 
USER userA");
+        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE \"汉化\" 
TO USER userA");
         tablet.setTableName("table2");
         try {
           sessionA.insert(tablet);
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "301: [EXECUTE_STATEMENT_ERROR(301)] Exception occurred: 
insertTablet failed. Access Denied: No permissions for this operation, please 
add privilege CREATE ON test.table2",
+              "301: [EXECUTE_STATEMENT_ERROR(301)] Exception occurred: 
insertTablet failed. Access Denied: No permissions for this operation, please 
add privilege CREATE ON 汉化.table2",
               e.getMessage());
         }
-        sessionRoot.executeNonQueryStatement("GRANT CREATE ON DATABASE test TO 
USER userA");
+        sessionRoot.executeNonQueryStatement("GRANT CREATE ON DATABASE \"汉化\" 
TO USER userA");
         sessionA.insert(tablet);
-        sessionRoot.executeNonQueryStatement("REVOKE CREATE ON DATABASE test 
FROM USER userA");
-        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE test 
FROM USER userA");
+        sessionRoot.executeNonQueryStatement("REVOKE CREATE ON DATABASE \"汉化\" 
FROM USER userA");
+        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE \"汉化\" 
FROM USER userA");
 
         // can write but cannot add column
-        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE test TO 
USER userA");
+        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE \"汉化\" 
TO USER userA");
         tablet =
             new Tablet(
                 "table2",
@@ -265,24 +265,24 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "301: [EXECUTE_STATEMENT_ERROR(301)] Exception occurred: 
insertTablet failed. Access Denied: No permissions for this operation, please 
add privilege ALTER ON test.table2",
+              "301: [EXECUTE_STATEMENT_ERROR(301)] Exception occurred: 
insertTablet failed. Access Denied: No permissions for this operation, please 
add privilege ALTER ON 汉化.table2",
               e.getMessage());
         }
         sessionRoot.executeNonQueryStatement("GRANT ALTER ON TABLE table2 TO 
USER userA");
         sessionA.insert(tablet);
         sessionRoot.executeNonQueryStatement("REVOKE ALTER ON TABLE table2 
FROM USER userA");
-        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE test 
FROM USER userA");
+        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE \"汉化\" 
FROM USER userA");
 
         // grant multiple and revoke one-by-one
         sessionRoot.executeNonQueryStatement("GRANT INSERT ON ANY TO USER 
userA");
-        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE test TO 
USER userA");
+        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE \"汉化\" 
TO USER userA");
         sessionRoot.executeNonQueryStatement("GRANT INSERT ON TABLE table1 TO 
USER userA");
         sessionA.executeNonQueryStatement(
             "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
         sessionRoot.executeNonQueryStatement("REVOKE INSERT ON ANY FROM USER 
userA");
         sessionA.executeNonQueryStatement(
             "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
-        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE test 
FROM USER userA");
+        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE \"汉化\" 
FROM USER userA");
         sessionA.executeNonQueryStatement(
             "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
         sessionRoot.executeNonQueryStatement("REVOKE INSERT ON TABLE table1 
FROM USER userA");
@@ -292,7 +292,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -317,7 +317,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
         // after revoked cannot revoke again
@@ -370,7 +370,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
         // userB can revoke himself
@@ -398,10 +398,10 @@ public class IoTDBAuthenticationTableIT {
           ITableSession sessionD =
               EnvFactory.getEnv().getTableSessionConnection("userD", "userD")) 
{
         // grant an irrelevant privilege so that the new users can use database
-        sessionRoot.executeNonQueryStatement("GRANT SELECT ON DATABASE test TO 
USER userC");
-        sessionRoot.executeNonQueryStatement("GRANT SELECT ON DATABASE test TO 
USER userD");
-        sessionC.executeNonQueryStatement("USE test");
-        sessionD.executeNonQueryStatement("USE test");
+        sessionRoot.executeNonQueryStatement("GRANT SELECT ON DATABASE \"汉化\" 
TO USER userC");
+        sessionRoot.executeNonQueryStatement("GRANT SELECT ON DATABASE \"汉化\" 
TO USER userD");
+        sessionC.executeNonQueryStatement("USE \"汉化\"");
+        sessionD.executeNonQueryStatement("USE \"汉化\"");
         // userC no privilege
         try {
           sessionC.executeNonQueryStatement(
@@ -409,7 +409,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -424,7 +424,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -439,22 +439,22 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
         // grant and revoke - database
-        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE test TO 
ROLE role1");
+        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE \"汉化\" 
TO ROLE role1");
         sessionC.executeNonQueryStatement(
             "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
-        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE test 
FROM ROLE role1");
+        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE \"汉化\" 
FROM ROLE role1");
         try {
           sessionC.executeNonQueryStatement(
               "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -469,20 +469,20 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
         // grant multiple and revoke one-by-one
         sessionRoot.executeNonQueryStatement("GRANT INSERT ON ANY TO ROLE 
role1");
-        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE test TO 
ROLE role1");
+        sessionRoot.executeNonQueryStatement("GRANT INSERT ON DATABASE \"汉化\" 
TO ROLE role1");
         sessionRoot.executeNonQueryStatement("GRANT INSERT ON TABLE table1 TO 
ROLE role1");
         sessionC.executeNonQueryStatement(
             "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
         sessionRoot.executeNonQueryStatement("REVOKE INSERT ON ANY FROM ROLE 
role1");
         sessionC.executeNonQueryStatement(
             "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
-        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE test 
FROM ROLE role1");
+        sessionRoot.executeNonQueryStatement("REVOKE INSERT ON DATABASE \"汉化\" 
FROM ROLE role1");
         sessionC.executeNonQueryStatement(
             "INSERT INTO table1 (time, id, attr, measurement) VALUES (1, 
'id2', 'attr2', 0.2)");
         sessionRoot.executeNonQueryStatement("REVOKE INSERT ON TABLE table1 
FROM ROLE role1");
@@ -492,7 +492,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -517,7 +517,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
         // after revoked cannot revoke again
@@ -554,7 +554,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
 
@@ -571,7 +571,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
         // userD can revoke himself
@@ -594,7 +594,7 @@ public class IoTDBAuthenticationTableIT {
           fail("Should have thrown an exception");
         } catch (StatementExecutionException e) {
           assertEquals(
-              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON test.table1",
+              "803: Access Denied: No permissions for this operation, please 
add privilege INSERT ON 汉化.table1",
               e.getMessage());
         }
       }
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
index 8e65a3f6d60..6dbb5f11633 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
@@ -59,6 +59,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import static 
org.apache.iotdb.commons.schema.column.ColumnHeaderConstant.showRegionColumnHeaders;
 import static 
org.apache.iotdb.db.it.utils.TestUtils.assertTableNonQueryTestFail;
 import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest;
 import static org.junit.Assert.assertEquals;
@@ -111,6 +112,44 @@ public class IoTDBInsertTableIT {
     }
   }
 
+  @Test
+  public void testShowRegion() {
+    try (final Connection connection =
+            EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+        final Statement statement = connection.createStatement()) {
+      statement.execute("use \"test\"");
+      statement.execute("create table sg2 (tag1 string tag, s1 int32 field)");
+      statement.execute("insert into sg2(tag1,time,s1) values('d1',1,2)");
+      statement.execute("flush");
+      statement.execute("insert into sg2(tag1,time,s1) values('d1',2,2)");
+      statement.execute("insert into sg2(tag1,time,s1) 
values('d1',604800001,2)");
+      statement.execute("flush");
+
+      // Test show regions in table model
+      try (final ResultSet resultSet = statement.executeQuery("show regions")) 
{
+        final ResultSetMetaData metaData = resultSet.getMetaData();
+        assertEquals(showRegionColumnHeaders.size(), 
metaData.getColumnCount());
+        for (int i = 0; i < showRegionColumnHeaders.size(); i++) {
+          assertEquals(
+              showRegionColumnHeaders.get(i).getColumnName(), 
metaData.getColumnName(i + 1));
+        }
+        assertTrue(resultSet.next());
+      }
+
+      try (final ResultSet resultSet = statement.executeQuery("show regions 
from test")) {
+        final ResultSetMetaData metaData = resultSet.getMetaData();
+        assertEquals(showRegionColumnHeaders.size(), 
metaData.getColumnCount());
+        for (int i = 0; i < showRegionColumnHeaders.size(); i++) {
+          assertEquals(
+              showRegionColumnHeaders.get(i).getColumnName(), 
metaData.getColumnName(i + 1));
+        }
+        assertTrue(resultSet.next());
+      }
+    } catch (final Exception e) {
+      fail(e.getMessage());
+    }
+  }
+
   @Test
   public void testInsertTimeAtAnyIndex() throws SQLException {
     try (Connection connection = 
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/PermissionManager.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/PermissionManager.java
index f17a63cfa82..adbb41cf9ea 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/PermissionManager.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/PermissionManager.java
@@ -65,7 +65,9 @@ public class PermissionManager {
     LOGGER.info("Auth: run auth plan: {}", authorPlan.toString());
     try {
       if (authorPlan.getAuthorType() == ConfigPhysicalPlanType.CreateUser
+          || authorPlan.getAuthorType() == ConfigPhysicalPlanType.RCreateUser
           || authorPlan.getAuthorType() == ConfigPhysicalPlanType.CreateRole
+          || authorPlan.getAuthorType() == ConfigPhysicalPlanType.RCreateRole
           || authorPlan.getAuthorType() == 
ConfigPhysicalPlanType.CreateUserWithRawPassword) {
         tsStatus =
             getConsensusManager()
diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
index 3915ae24a3c..ab93cdd7c74 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/executor/ConfigPlanExecutor.java
@@ -813,9 +813,15 @@ public class ConfigPlanExecutor {
     final GetRegionInfoListPlan getRegionInfoListPlan = 
(GetRegionInfoListPlan) req;
     final TShowRegionReq showRegionReq = 
getRegionInfoListPlan.getShowRegionReq();
     if (showRegionReq != null && showRegionReq.isSetDatabases()) {
-      final List<String> storageGroups = showRegionReq.getDatabases();
+      final List<String> databases = showRegionReq.getDatabases();
       final List<String> matchedStorageGroups =
-          clusterSchemaInfo.getMatchedDatabaseSchemasByName(storageGroups, 
false).values().stream()
+          clusterSchemaInfo
+              .getMatchedDatabaseSchemasByName(
+                  databases,
+                  ((GetRegionInfoListPlan) 
req).getShowRegionReq().isSetIsTableModel()
+                      && ((GetRegionInfoListPlan) 
req).getShowRegionReq().isIsTableModel())
+              .values()
+              .stream()
               .map(TDatabaseSchema::getName)
               .collect(Collectors.toList());
       if (!matchedStorageGroups.isEmpty()) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
index 14d30af6340..a90ed1e7b46 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
@@ -23,6 +23,7 @@ import org.apache.iotdb.common.rpc.thrift.Model;
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.exception.auth.AccessDeniedException;
 import org.apache.iotdb.commons.executable.ExecutableManager;
+import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.pipe.agent.plugin.builtin.BuiltinPipePlugin;
 import org.apache.iotdb.commons.pipe.config.constant.PipeConnectorConstant;
 import org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant;
@@ -379,7 +380,10 @@ public class TableConfigTaskVisitor extends 
AstVisitor<IConfigTask, MPPQueryCont
     // corresponding tree-model variant and execute that.
     final ShowRegionStatement treeStatement = new ShowRegionStatement();
     treeStatement.setRegionType(showRegions.getRegionType());
-    treeStatement.setStorageGroups(showRegions.getDatabases());
+    treeStatement.setDatabases(
+        Objects.nonNull(showRegions.getDatabase())
+            ? Collections.singletonList(new PartialPath(new String[] 
{showRegions.getDatabase()}))
+            : null);
     treeStatement.setNodeIds(showRegions.getNodeIds());
     return new ShowRegionTask(treeStatement, true);
   }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index a005875d349..299b8d80420 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -1545,11 +1545,11 @@ public class ClusterConfigTaskExecutor implements 
IConfigTaskExecutor {
     TShowRegionResp showRegionResp = new TShowRegionResp();
     final TShowRegionReq showRegionReq = new 
TShowRegionReq().setIsTableModel(isTableModel);
     showRegionReq.setConsensusGroupType(showRegionStatement.getRegionType());
-    if (showRegionStatement.getStorageGroups() == null) {
+    if (showRegionStatement.getDatabases() == null) {
       showRegionReq.setDatabases(null);
     } else {
       showRegionReq.setDatabases(
-          showRegionStatement.getStorageGroups().stream()
+          showRegionStatement.getDatabases().stream()
               .map(PartialPath::getFullPath)
               .collect(Collectors.toList()));
     }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
index 1ae9fc34961..af5afd4c0c9 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
@@ -3531,9 +3531,9 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
           storageGroups.add(parsePrefixPath(prefixPathContext));
         }
       }
-      showRegionStatement.setStorageGroups(storageGroups);
+      showRegionStatement.setDatabases(storageGroups);
     } else {
-      showRegionStatement.setStorageGroups(null);
+      showRegionStatement.setDatabases(null);
     }
 
     if (ctx.ON() != null) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowRegions.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowRegions.java
index 475dcdb6057..facfcb9554a 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowRegions.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowRegions.java
@@ -20,7 +20,6 @@
 package org.apache.iotdb.db.queryengine.plan.relational.sql.ast;
 
 import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
-import org.apache.iotdb.commons.path.PartialPath;
 
 import com.google.common.collect.ImmutableList;
 
@@ -28,39 +27,27 @@ import java.util.List;
 import java.util.Objects;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
-import static java.util.Objects.requireNonNull;
 
 public class ShowRegions extends Statement {
 
   private final TConsensusGroupType regionType;
-  private final List<PartialPath> databases;
+  private final String database;
   private final List<Integer> nodeIds;
 
   public ShowRegions(
-      TConsensusGroupType regionType, List<PartialPath> databases, 
List<Integer> nodeIds) {
+      final TConsensusGroupType regionType, final String database, final 
List<Integer> nodeIds) {
     super(null);
     this.regionType = regionType;
-    this.databases = databases;
+    this.database = database;
     this.nodeIds = nodeIds;
   }
 
-  public ShowRegions(
-      NodeLocation location,
-      TConsensusGroupType regionType,
-      List<PartialPath> storageGroups,
-      List<Integer> nodeIds) {
-    super(requireNonNull(location, "location is null"));
-    this.regionType = regionType;
-    this.databases = requireNonNull(storageGroups, "databases is null");
-    this.nodeIds = requireNonNull(nodeIds, "nodeIds is null");
-  }
-
   public TConsensusGroupType getRegionType() {
     return regionType;
   }
 
-  public List<PartialPath> getDatabases() {
-    return databases;
+  public String getDatabase() {
+    return database;
   }
 
   public List<Integer> getNodeIds() {
@@ -68,7 +55,7 @@ public class ShowRegions extends Statement {
   }
 
   @Override
-  public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
+  public <R, C> R accept(final AstVisitor<R, C> visitor, final C context) {
     return visitor.visitShowRegions(this, context);
   }
 
@@ -78,25 +65,29 @@ public class ShowRegions extends Statement {
   }
 
   @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-    ShowRegions that = (ShowRegions) o;
+  public boolean equals(final Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    final ShowRegions that = (ShowRegions) o;
     return regionType == that.regionType
-        && Objects.equals(databases, that.databases)
+        && Objects.equals(database, that.database)
         && Objects.equals(nodeIds, that.nodeIds);
   }
 
   @Override
   public int hashCode() {
-    return Objects.hash(regionType, databases, nodeIds);
+    return Objects.hash(regionType, database, nodeIds);
   }
 
   @Override
   public String toString() {
     return toStringHelper(this)
         .add("regionType", regionType)
-        .add("databases", databases)
+        .add("database", database)
         .add("nodeIds", nodeIds)
         .toString();
   }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
index 86ffbcec7d5..3a4e247ce58 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
@@ -22,7 +22,6 @@ package 
org.apache.iotdb.db.queryengine.plan.relational.sql.parser;
 import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
 import org.apache.iotdb.commons.auth.entity.PrivilegeType;
 import org.apache.iotdb.commons.cluster.NodeStatus;
-import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.schema.cache.CacheClearOptions;
 import org.apache.iotdb.commons.schema.table.InformationSchema;
@@ -1110,21 +1109,12 @@ public class AstBuilder extends 
RelationalSqlBaseVisitor<Node> {
     } else if (ctx.SCHEMA() != null) {
       regionType = TConsensusGroupType.SchemaRegion;
     }
-    List<PartialPath> databases = null;
-    if (ctx.identifier() != null) {
-      try {
-        // When using the table model, only single level databases are allowed 
to be used.
-        // Therefore, the "root." prefix is omitted from the query syntax, but 
we need to
-        // add it back before querying the server.
-        databases =
-            Collections.singletonList(new PartialPath("root." + 
ctx.identifier().getText()));
-      } catch (IllegalPathException e) {
-        throw new RuntimeException(e);
-      }
-    }
-    // TODO: This will be left untouched for now, well add filtering later on.
-    List<Integer> nodeIds = null;
-    return new ShowRegions(regionType, databases, nodeIds);
+    return new ShowRegions(
+        regionType,
+        Objects.nonNull(ctx.identifier())
+            ? ((Identifier) visit(ctx.identifier())).getValue()
+            : null,
+        null);
   }
 
   @Override
@@ -1586,7 +1576,7 @@ public class AstBuilder extends 
RelationalSqlBaseVisitor<Node> {
             throw new SemanticException("Database is not set yet.");
           }
         }
-        String obj = ctx.privilegeObjectScope().objectName.getText();
+        String obj = ((Identifier) 
(visit(ctx.privilegeObjectScope().objectName))).getValue();
         return new RelationalAuthorStatement(
             toUser
                 ? toTable ? AuthorRType.GRANT_USER_TB : 
AuthorRType.GRANT_USER_DB
@@ -1599,8 +1589,14 @@ public class AstBuilder extends 
RelationalSqlBaseVisitor<Node> {
             grantOption,
             null);
       } else if (ctx.privilegeObjectScope().objectScope() != null) {
-        String db = 
ctx.privilegeObjectScope().objectScope().dbname.getText().toLowerCase();
-        String tb = 
ctx.privilegeObjectScope().objectScope().tbname.getText().toLowerCase();
+        String db =
+            ((Identifier) 
(visit(ctx.privilegeObjectScope().objectScope().dbname)))
+                .getValue()
+                .toLowerCase();
+        String tb =
+            ((Identifier) 
(visit(ctx.privilegeObjectScope().objectScope().tbname)))
+                .getValue()
+                .toLowerCase();
         return new RelationalAuthorStatement(
             toUser ? AuthorRType.GRANT_USER_TB : AuthorRType.GRANT_ROLE_TB,
             toUser ? name : "",
@@ -1663,14 +1659,26 @@ public class AstBuilder extends 
RelationalSqlBaseVisitor<Node> {
           if (databaseName == null) {
             throw new SemanticException("Database is not set yet.");
           }
-          tableName = 
ctx.privilegeObjectScope().objectName.getText().toLowerCase();
+          tableName =
+              ((Identifier) (visit(ctx.privilegeObjectScope().objectName)))
+                  .getValue()
+                  .toLowerCase();
         } else {
-          databaseName = 
ctx.privilegeObjectScope().objectName.getText().toLowerCase();
+          databaseName =
+              ((Identifier) (visit(ctx.privilegeObjectScope().objectName)))
+                  .getValue()
+                  .toLowerCase();
         }
       } else if (ctx.privilegeObjectScope().objectScope() != null) {
         fromTable = true;
-        databaseName = 
ctx.privilegeObjectScope().objectScope().dbname.getText().toLowerCase();
-        tableName = 
ctx.privilegeObjectScope().objectScope().tbname.getText().toLowerCase();
+        databaseName =
+            ((Identifier) 
(visit(ctx.privilegeObjectScope().objectScope().dbname)))
+                .getValue()
+                .toLowerCase();
+        tableName =
+            ((Identifier) 
(visit(ctx.privilegeObjectScope().objectScope().tbname)))
+                .getValue()
+                .toLowerCase();
       }
 
       // The REVOKE ALL command can revoke privileges for users, databases, 
and tables.
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/ShowRegionStatement.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/ShowRegionStatement.java
index 78438d8fcfd..f5065ef83bc 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/ShowRegionStatement.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/ShowRegionStatement.java
@@ -32,40 +32,29 @@ import java.util.List;
 public class ShowRegionStatement extends ShowStatement implements 
IConfigStatement {
 
   private TConsensusGroupType regionType;
-  private List<PartialPath> storageGroups;
+  private List<PartialPath> databases;
 
   private List<Integer> nodeIds;
 
   public ShowRegionStatement() {}
 
-  public ShowRegionStatement(TConsensusGroupType regionType) {
-    this.regionType = regionType;
-  }
-
-  public ShowRegionStatement(
-      TConsensusGroupType regionType, List<PartialPath> storageGroups, 
List<Integer> nodeIds) {
-    this.regionType = regionType;
-    this.storageGroups = storageGroups;
-    this.nodeIds = nodeIds;
-  }
-
-  public List<PartialPath> getStorageGroups() {
-    return storageGroups;
+  public List<PartialPath> getDatabases() {
+    return databases;
   }
 
-  public void setStorageGroups(List<PartialPath> storageGroups) {
-    this.storageGroups = storageGroups;
+  public void setDatabases(final List<PartialPath> databases) {
+    this.databases = databases;
   }
 
   public TConsensusGroupType getRegionType() {
     return regionType;
   }
 
-  public void setRegionType(TConsensusGroupType regionType) {
+  public void setRegionType(final TConsensusGroupType regionType) {
     this.regionType = regionType;
   }
 
-  public void setNodeIds(List<Integer> nodeIds) {
+  public void setNodeIds(final List<Integer> nodeIds) {
     this.nodeIds = nodeIds;
   }
 
@@ -74,7 +63,7 @@ public class ShowRegionStatement extends ShowStatement 
implements IConfigStateme
   }
 
   @Override
-  public TSStatus checkPermissionBeforeProcess(String userName) {
+  public TSStatus checkPermissionBeforeProcess(final String userName) {
     return AuthorityChecker.checkSuperUserOrMaintain(userName);
   }
 
@@ -84,7 +73,7 @@ public class ShowRegionStatement extends ShowStatement 
implements IConfigStateme
   }
 
   @Override
-  public <R, C> R accept(StatementVisitor<R, C> visitor, C context) {
+  public <R, C> R accept(final StatementVisitor<R, C> visitor, final C 
context) {
     return visitor.visitShowRegion(this, context);
   }
 }


Reply via email to