You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2024/01/18 07:52:12 UTC

(shardingsphere) branch master updated: Remove ConnectionSessionRequiredRALUpdater (#29762)

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 0401e5ea71d Remove ConnectionSessionRequiredRALUpdater (#29762)
0401e5ea71d is described below

commit 0401e5ea71d75fda1742e78847ae3c3c52123252
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jan 18 15:52:03 2024 +0800

    Remove ConnectionSessionRequiredRALUpdater (#29762)
---
 .../type/ral/update/DatabaseRuleRALUpdater.java    |  3 +-
 .../DatabaseTypeAwareQueryableRALUpdater.java      | 19 ++++-----
 .../distsql/ral/RALBackendHandlerFactory.java      |  2 +-
 ...=> UpdatableDatabaseRuleRALBackendHandler.java} | 11 +++--
 .../updatable/RefreshDatabaseMetaDataUpdater.java  | 36 +++++-----------
 .../ral/updatable/RefreshTableMetaDataUpdater.java | 34 ++++++---------
 .../ral/updatable/SetDistVariableUpdater.java      | 22 ++++------
 .../handler/ProxyBackendHandlerFactoryTest.java    |  4 +-
 .../RefreshDatabaseMetaDataUpdaterTest.java        | 49 ----------------------
 .../updatable/RefreshTableMetaDataUpdaterTest.java | 25 +++--------
 ...pdatableDatabaseRuleRALBackendHandlerTest.java} |  6 +--
 .../ral/updatable/SetDistVariableUpdaterTest.java  | 25 +++++------
 12 files changed, 66 insertions(+), 170 deletions(-)

diff --git a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/DatabaseRuleRALUpdater.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/DatabaseRuleRALUpdater.java
index 77772d61511..b0bd4eed241 100644
--- a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/DatabaseRuleRALUpdater.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/DatabaseRuleRALUpdater.java
@@ -38,8 +38,7 @@ public interface DatabaseRuleRALUpdater<T extends SQLStatement> extends TypedSPI
      * @param sqlStatement updatable RAL statement
      * @throws SQLException SQL exception
      */
-    default void executeUpdate(final String databaseName, final T sqlStatement) throws SQLException {
-    }
+    void executeUpdate(String databaseName, T sqlStatement) throws SQLException;
     
     @Override
     Class<T> getType();
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/updater/ConnectionSessionRequiredRALUpdater.java b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/DatabaseTypeAwareQueryableRALUpdater.java
similarity index 57%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/updater/ConnectionSessionRequiredRALUpdater.java
rename to infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/DatabaseTypeAwareQueryableRALUpdater.java
index ed18b21f9eb..1697ca43ed4 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/updater/ConnectionSessionRequiredRALUpdater.java
+++ b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/ral/update/DatabaseTypeAwareQueryableRALUpdater.java
@@ -15,27 +15,22 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.updater;
+package org.apache.shardingsphere.distsql.handler.type.ral.update;
 
-import org.apache.shardingsphere.distsql.handler.type.ral.update.DatabaseRuleRALUpdater;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
-import java.sql.SQLException;
-
 /**
- * Connection session required RAL updater.
+ * Database type aware queryable RAL updater.
  * 
  * @param <T> type of SQL statement
  */
-public interface ConnectionSessionRequiredRALUpdater<T extends SQLStatement> extends DatabaseRuleRALUpdater<T> {
+public interface DatabaseTypeAwareQueryableRALUpdater<T extends SQLStatement> extends DatabaseRuleRALUpdater<T> {
     
     /**
-     * Execute update.
+     * Set database type.
      *
-     * @param connectionSession connection session
-     * @param sqlStatement updatable RAL statement
-     * @throws SQLException SQL exception
+     * @param databaseType database type
      */
-    void executeUpdate(ConnectionSession connectionSession, T sqlStatement) throws SQLException;
+    void setDatabaseType(DatabaseType databaseType);
 }
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
index 1453fa1e2c6..c953fb106c7 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/RALBackendHandlerFactory.java
@@ -51,6 +51,6 @@ public final class RALBackendHandlerFactory {
             }
             return new UpdatableGlobalRuleRALBackendHandler((UpdatableGlobalRuleRALStatement) sqlStatement);
         }
-        return new UpdatableRALBackendHandler<>((UpdatableRALStatement) sqlStatement, connectionSession);
+        return new UpdatableDatabaseRuleRALBackendHandler<>((UpdatableRALStatement) sqlStatement, connectionSession);
     }
 }
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableRALBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableDatabaseRuleRALBackendHandler.java
similarity index 78%
rename from proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableRALBackendHandler.java
rename to proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableDatabaseRuleRALBackendHandler.java
index 215b7c5ab04..2d6701ef149 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableRALBackendHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/UpdatableDatabaseRuleRALBackendHandler.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral;
 
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.distsql.handler.type.ral.update.DatabaseRuleRALUpdater;
+import org.apache.shardingsphere.distsql.handler.type.ral.update.DatabaseTypeAwareQueryableRALUpdater;
 import org.apache.shardingsphere.distsql.statement.ral.UpdatableRALStatement;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.updater.ConnectionSessionRequiredRALUpdater;
 import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
 import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -34,7 +34,7 @@ import java.sql.SQLException;
  * @param <T> type of SQL statement
  */
 @RequiredArgsConstructor
-public final class UpdatableRALBackendHandler<T extends UpdatableRALStatement> implements RALBackendHandler {
+public final class UpdatableDatabaseRuleRALBackendHandler<T extends UpdatableRALStatement> implements RALBackendHandler {
     
     private final UpdatableRALStatement sqlStatement;
     
@@ -44,11 +44,10 @@ public final class UpdatableRALBackendHandler<T extends UpdatableRALStatement> i
     @Override
     public ResponseHeader execute() throws SQLException {
         DatabaseRuleRALUpdater<T> updater = TypedSPILoader.getService(DatabaseRuleRALUpdater.class, sqlStatement.getClass());
-        if (updater instanceof ConnectionSessionRequiredRALUpdater) {
-            ((ConnectionSessionRequiredRALUpdater<T>) updater).executeUpdate(connectionSession, (T) sqlStatement);
-        } else {
-            updater.executeUpdate(connectionSession.getDatabaseName(), (T) sqlStatement);
+        if (updater instanceof DatabaseTypeAwareQueryableRALUpdater) {
+            ((DatabaseTypeAwareQueryableRALUpdater<T>) updater).setDatabaseType(connectionSession.getProtocolType());
         }
+        updater.executeUpdate(connectionSession.getDatabaseName(), (T) sqlStatement);
         return new UpdateResponseHeader(sqlStatement);
     }
 }
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdater.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdater.java
index 498ad1f4d5a..3b6c43e4b89 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdater.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdater.java
@@ -17,48 +17,32 @@
 
 package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
 
-import com.google.common.base.Strings;
+import org.apache.shardingsphere.distsql.handler.type.ral.update.DatabaseRuleRALUpdater;
 import org.apache.shardingsphere.distsql.statement.ral.updatable.RefreshDatabaseMetaDataStatement;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.NoDatabaseSelectedException;
-import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.util.SystemSchemaUtils;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.updater.ConnectionSessionRequiredRALUpdater;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 
 import java.sql.SQLException;
+import java.util.Collections;
 import java.util.Map;
 import java.util.Optional;
 
 /**
  * Refresh database meta data updater.
  */
-public final class RefreshDatabaseMetaDataUpdater implements ConnectionSessionRequiredRALUpdater<RefreshDatabaseMetaDataStatement> {
+public final class RefreshDatabaseMetaDataUpdater implements DatabaseRuleRALUpdater<RefreshDatabaseMetaDataStatement> {
     
     @Override
-    public void executeUpdate(final ConnectionSession connectionSession, final RefreshDatabaseMetaDataStatement sqlStatement) throws SQLException {
+    public void executeUpdate(final String databaseName, final RefreshDatabaseMetaDataStatement sqlStatement) throws SQLException {
         Optional<String> toBeRefreshedDatabaseName = sqlStatement.getDatabaseName();
-        if (toBeRefreshedDatabaseName.isPresent()) {
-            String databaseName = toBeRefreshedDatabaseName.get();
-            ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(databaseName), NoDatabaseSelectedException::new);
-            ShardingSpherePreconditions.checkState(ProxyContext.getInstance().databaseExists(databaseName), () -> new UnknownDatabaseException(databaseName));
-            reloadDatabaseMetaData(databaseName, sqlStatement.isForce());
-            return;
+        Map<String, ShardingSphereDatabase> databases = toBeRefreshedDatabaseName.map(optional -> Collections.singletonMap(optional, ProxyContext.getInstance().getDatabase(optional)))
+                .orElseGet(() -> ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabases());
+        for (ShardingSphereDatabase each : databases.values()) {
+            if (!SystemSchemaUtils.isSystemSchema(each)) {
+                ProxyContext.getInstance().getContextManager().refreshDatabaseMetaData(each.getName(), sqlStatement.isForce());
+            }
         }
-        Map<String, ShardingSphereDatabase> databases = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getDatabases();
-        databases.values().forEach(each -> checkAndRefresh(each, sqlStatement.isForce()));
-    }
-    
-    private void checkAndRefresh(final ShardingSphereDatabase each, final boolean force) {
-        if (!SystemSchemaUtils.isSystemSchema(each)) {
-            reloadDatabaseMetaData(each.getName(), force);
-        }
-    }
-    
-    private void reloadDatabaseMetaData(final String databaseName, final boolean force) {
-        ProxyContext.getInstance().getContextManager().refreshDatabaseMetaData(databaseName, force);
     }
     
     @Override
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdater.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdater.java
index 2277f245767..f1a4b2ac4c7 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdater.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdater.java
@@ -17,34 +17,35 @@
 
 package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
 
-import com.google.common.base.Strings;
+import lombok.Setter;
 import org.apache.shardingsphere.distsql.handler.exception.storageunit.EmptyStorageUnitException;
 import org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
+import org.apache.shardingsphere.distsql.handler.type.ral.update.DatabaseTypeAwareQueryableRALUpdater;
 import org.apache.shardingsphere.distsql.statement.ral.updatable.RefreshTableMetaDataStatement;
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.NoDatabaseSelectedException;
-import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException;
 import org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.updater.ConnectionSessionRequiredRALUpdater;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 
+import java.sql.SQLException;
 import java.util.Collections;
 import java.util.Map;
 
 /**
  * Refresh table meta data handler.
  */
-public final class RefreshTableMetaDataUpdater implements ConnectionSessionRequiredRALUpdater<RefreshTableMetaDataStatement> {
+@Setter
+public final class RefreshTableMetaDataUpdater implements DatabaseTypeAwareQueryableRALUpdater<RefreshTableMetaDataStatement> {
+    
+    private DatabaseType databaseType;
     
     @Override
-    public void executeUpdate(final ConnectionSession connectionSession, final RefreshTableMetaDataStatement sqlStatement) {
-        String databaseName = getDatabaseName(connectionSession);
+    public void executeUpdate(final String databaseName, final RefreshTableMetaDataStatement sqlStatement) throws SQLException {
         ContextManager contextManager = ProxyContext.getInstance().getContextManager();
         checkStorageUnit(databaseName, contextManager.getStorageUnits(databaseName), sqlStatement);
-        String schemaName = getSchemaName(databaseName, sqlStatement, connectionSession);
+        String schemaName = getSchemaName(databaseName, sqlStatement);
         if (sqlStatement.getStorageUnitName().isPresent()) {
             if (sqlStatement.getTableName().isPresent()) {
                 contextManager.reloadTable(databaseName, schemaName, sqlStatement.getStorageUnitName().get(), sqlStatement.getTableName().get());
@@ -69,19 +70,8 @@ public final class RefreshTableMetaDataUpdater implements ConnectionSessionRequi
         }
     }
     
-    private String getDatabaseName(final ConnectionSession connectionSession) {
-        String result = connectionSession.getDatabaseName();
-        if (Strings.isNullOrEmpty(result)) {
-            throw new NoDatabaseSelectedException();
-        }
-        if (!ProxyContext.getInstance().databaseExists(result)) {
-            throw new UnknownDatabaseException(result);
-        }
-        return result;
-    }
-    
-    private String getSchemaName(final String databaseName, final RefreshTableMetaDataStatement sqlStatement, final ConnectionSession connectionSession) {
-        return sqlStatement.getSchemaName().isPresent() ? sqlStatement.getSchemaName().get() : new DatabaseTypeRegistry(connectionSession.getProtocolType()).getDefaultSchemaName(databaseName);
+    private String getSchemaName(final String databaseName, final RefreshTableMetaDataStatement sqlStatement) {
+        return sqlStatement.getSchemaName().isPresent() ? sqlStatement.getSchemaName().get() : new DatabaseTypeRegistry(databaseType).getDefaultSchemaName(databaseName);
     }
     
     @Override
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdater.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdater.java
index b3ccf4a83a5..1dadf0acbfc 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdater.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdater.java
@@ -20,39 +20,36 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
 import ch.qos.logback.classic.Level;
 import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
+import org.apache.shardingsphere.distsql.handler.type.ral.update.DatabaseRuleRALUpdater;
 import org.apache.shardingsphere.distsql.statement.ral.updatable.SetDistVariableStatement;
 import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationPropertyKey;
+import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.props.TypedPropertyKey;
 import org.apache.shardingsphere.infra.props.TypedPropertyValue;
 import org.apache.shardingsphere.infra.props.exception.TypedPropertyValueException;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
 import org.apache.shardingsphere.logging.constant.LoggingConstants;
 import org.apache.shardingsphere.logging.util.LoggingUtils;
-import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.exception.InvalidValueException;
 import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.updater.ConnectionSessionRequiredRALUpdater;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.slf4j.LoggerFactory;
 
+import java.sql.SQLException;
 import java.util.Properties;
 
 /**
  * Set dist variable statement updater.
  */
-public final class SetDistVariableUpdater implements ConnectionSessionRequiredRALUpdater<SetDistVariableStatement> {
+public final class SetDistVariableUpdater implements DatabaseRuleRALUpdater<SetDistVariableStatement> {
     
     @Override
-    public void executeUpdate(final ConnectionSession connectionSession, final SetDistVariableStatement sqlStatement) {
+    public void executeUpdate(final String databaseName, final SetDistVariableStatement sqlStatement) throws SQLException {
         Enum<?> enumType = getEnumType(sqlStatement.getName());
-        if (enumType instanceof TypedPropertyKey) {
-            handleConfigurationProperty((TypedPropertyKey) enumType, sqlStatement.getValue());
-        } else {
-            throw new UnsupportedVariableException(sqlStatement.getName());
-        }
+        ShardingSpherePreconditions.checkState(enumType instanceof TypedPropertyKey, () -> new UnsupportedVariableException(sqlStatement.getName()));
+        handleConfigurationProperty((TypedPropertyKey) enumType, sqlStatement.getValue());
     }
     
     private Enum<?> getEnumType(final String name) {
@@ -68,13 +65,12 @@ public final class SetDistVariableUpdater implements ConnectionSessionRequiredRA
     }
     
     private void handleConfigurationProperty(final TypedPropertyKey propertyKey, final String value) {
-        ContextManager contextManager = ProxyContext.getInstance().getContextManager();
-        MetaDataContexts metaDataContexts = contextManager.getMetaDataContexts();
+        MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
         Properties props = new Properties();
         props.putAll(metaDataContexts.getMetaData().getProps().getProps());
         props.putAll(metaDataContexts.getMetaData().getTemporaryProps().getProps());
         props.put(propertyKey.getKey(), getValue(propertyKey, value));
-        contextManager.getInstanceContext().getModeContextManager().alterProperties(props);
+        ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager().alterProperties(props);
         refreshRootLogger(props);
         syncSQLShowToLoggingRule(propertyKey, metaDataContexts, value);
         syncSQLSimpleToLoggingRule(propertyKey, metaDataContexts, value);
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
index 6aa6e2eb69c..a3519e70174 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
@@ -40,7 +40,7 @@ import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.handler.admin.DatabaseAdminQueryBackendHandler;
 import org.apache.shardingsphere.proxy.backend.handler.data.impl.UnicastDatabaseBackendHandler;
 import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.QueryableRALBackendHandler;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.UpdatableRALBackendHandler;
+import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.UpdatableDatabaseRuleRALBackendHandler;
 import org.apache.shardingsphere.proxy.backend.handler.distsql.rql.RQLBackendHandler;
 import org.apache.shardingsphere.proxy.backend.handler.distsql.rul.SQLRULBackendHandler;
 import org.apache.shardingsphere.proxy.backend.handler.skip.SkipBackendHandler;
@@ -130,7 +130,7 @@ class ProxyBackendHandlerFactoryTest {
     void assertNewInstanceWithDistSQL() throws SQLException {
         String sql = "set dist variable sql_show='true'";
         ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, connectionSession, new HintValueContext());
-        assertThat(actual, instanceOf(UpdatableRALBackendHandler.class));
+        assertThat(actual, instanceOf(UpdatableDatabaseRuleRALBackendHandler.class));
         sql = "show dist variable where name = sql_show";
         actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, connectionSession, new HintValueContext());
         assertThat(actual, instanceOf(QueryableRALBackendHandler.class));
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdaterTest.java
deleted file mode 100644
index 12f05cd87d5..00000000000
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdaterTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
-
-import org.apache.shardingsphere.distsql.statement.ral.updatable.RefreshDatabaseMetaDataStatement;
-import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException;
-import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.test.mock.AutoMockExtension;
-import org.apache.shardingsphere.test.mock.StaticMockSettings;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(AutoMockExtension.class)
-@StaticMockSettings(ProxyContext.class)
-class RefreshDatabaseMetaDataUpdaterTest {
-    
-    @Mock
-    private ConnectionSession connectionSession;
-    
-    @Test
-    void assertExecuteWithNoDatabase() {
-        RefreshDatabaseMetaDataUpdater updater = new RefreshDatabaseMetaDataUpdater();
-        when(ProxyContext.getInstance().getContextManager()).thenReturn(mock(ContextManager.class, RETURNS_DEEP_STUBS));
-        assertThrows(UnknownDatabaseException.class, () -> updater.executeUpdate(connectionSession, new RefreshDatabaseMetaDataStatement("foo", true)));
-    }
-}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdaterTest.java
index 727045e113a..a8607179a90 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdaterTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdaterTest.java
@@ -21,12 +21,10 @@ import org.apache.shardingsphere.distsql.handler.exception.storageunit.EmptyStor
 import org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
 import org.apache.shardingsphere.distsql.statement.ral.updatable.RefreshTableMetaDataStatement;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
-import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.NoDatabaseSelectedException;
-import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.UpdatableRALBackendHandler;
+import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.UpdatableDatabaseRuleRALBackendHandler;
 import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
 import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -52,27 +50,13 @@ import static org.mockito.Mockito.when;
 @MockitoSettings(strictness = Strictness.LENIENT)
 class RefreshTableMetaDataUpdaterTest {
     
-    @Test
-    void assertNoDatabaseSelected() {
-        when(ProxyContext.getInstance().getContextManager()).thenReturn(mock(ContextManager.class, RETURNS_DEEP_STUBS));
-        UpdatableRALBackendHandler<?> backendHandler = new UpdatableRALBackendHandler<>(new RefreshTableMetaDataStatement(), mock(ConnectionSession.class));
-        assertThrows(NoDatabaseSelectedException.class, backendHandler::execute);
-    }
-    
-    @Test
-    void assertUnknownDatabaseException() {
-        when(ProxyContext.getInstance().getContextManager()).thenReturn(mock(ContextManager.class, RETURNS_DEEP_STUBS));
-        UpdatableRALBackendHandler<?> backendHandler = new UpdatableRALBackendHandler<>(new RefreshTableMetaDataStatement(), mockConnectionSession("not_existed_db"));
-        assertThrows(UnknownDatabaseException.class, backendHandler::execute);
-    }
-    
     @Test
     void assertEmptyResource() {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(contextManager.getStorageUnits("foo_db")).thenReturn(Collections.emptyMap());
         when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
         when(ProxyContext.getInstance().databaseExists("foo_db")).thenReturn(true);
-        UpdatableRALBackendHandler<?> backendHandler = new UpdatableRALBackendHandler<>(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db"));
+        UpdatableDatabaseRuleRALBackendHandler<?> backendHandler = new UpdatableDatabaseRuleRALBackendHandler<>(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db"));
         assertThrows(EmptyStorageUnitException.class, backendHandler::execute);
     }
     
@@ -81,7 +65,8 @@ class RefreshTableMetaDataUpdaterTest {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
         when(ProxyContext.getInstance().databaseExists("foo_db")).thenReturn(true);
-        UpdatableRALBackendHandler<?> backendHandler = new UpdatableRALBackendHandler<>(new RefreshTableMetaDataStatement("t_order", "ds_1", null), mockConnectionSession("foo_db"));
+        UpdatableDatabaseRuleRALBackendHandler<?> backendHandler = new UpdatableDatabaseRuleRALBackendHandler<>(
+                new RefreshTableMetaDataStatement("t_order", "ds_1", null), mockConnectionSession("foo_db"));
         assertThrows(MissingRequiredStorageUnitsException.class, backendHandler::execute);
     }
     
@@ -90,7 +75,7 @@ class RefreshTableMetaDataUpdaterTest {
         ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
         when(ProxyContext.getInstance().databaseExists("foo_db")).thenReturn(true);
-        UpdatableRALBackendHandler<?> backendHandler = new UpdatableRALBackendHandler<>(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db"));
+        UpdatableDatabaseRuleRALBackendHandler<?> backendHandler = new UpdatableDatabaseRuleRALBackendHandler<>(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db"));
         ResponseHeader actual = backendHandler.execute();
         assertThat(actual, instanceOf(UpdateResponseHeader.class));
     }
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableRALBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableDatabaseRuleRALBackendHandlerTest.java
similarity index 87%
rename from proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableRALBackendHandlerTest.java
rename to proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableDatabaseRuleRALBackendHandlerTest.java
index 69ee52a6d15..9f4bb09c67d 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableRALBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdatableDatabaseRuleRALBackendHandlerTest.java
@@ -21,7 +21,7 @@ import io.netty.util.DefaultAttributeMap;
 import org.apache.shardingsphere.distsql.statement.ral.updatable.SetDistVariableStatement;
 import org.apache.shardingsphere.infra.database.mysql.type.MySQLDatabaseType;
 import org.apache.shardingsphere.proxy.backend.exception.UnsupportedVariableException;
-import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.UpdatableRALBackendHandler;
+import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.UpdatableDatabaseRuleRALBackendHandler;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.apache.shardingsphere.transaction.api.TransactionType;
 import org.junit.jupiter.api.BeforeEach;
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.mock;
 
-class SetDistVariableUpdatableRALBackendHandlerTest {
+class SetDistVariableUpdatableDatabaseRuleRALBackendHandlerTest {
     
     private ConnectionSession connectionSession;
     
@@ -41,7 +41,7 @@ class SetDistVariableUpdatableRALBackendHandlerTest {
     
     @Test
     void assertNotSupportedVariable() {
-        UpdatableRALBackendHandler<?> handler = new UpdatableRALBackendHandler<>(new SetDistVariableStatement("unsupported", "XXX"), connectionSession);
+        UpdatableDatabaseRuleRALBackendHandler<?> handler = new UpdatableDatabaseRuleRALBackendHandler<>(new SetDistVariableStatement("unsupported", "XXX"), connectionSession);
         assertThrows(UnsupportedVariableException.class, handler::execute);
     }
 }
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdaterTest.java
index 4ff14fd8250..8a7be9cca2b 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdaterTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdaterTest.java
@@ -35,14 +35,14 @@ import org.apache.shardingsphere.mode.manager.standalone.StandaloneModeContextMa
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.exception.InvalidValueException;
-import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.apache.shardingsphere.test.mock.AutoMockExtension;
 import org.apache.shardingsphere.test.mock.StaticMockSettings;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
 import org.slf4j.event.Level;
 
+import java.sql.SQLException;
+
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
@@ -54,52 +54,49 @@ import static org.mockito.Mockito.when;
 @StaticMockSettings(ProxyContext.class)
 class SetDistVariableUpdaterTest {
     
-    @Mock
-    private ConnectionSession connectionSession;
-    
     @Test
-    void assertExecuteWithConfigurationKey() {
+    void assertExecuteWithConfigurationKey() throws SQLException {
         SetDistVariableStatement statement = new SetDistVariableStatement("proxy_frontend_flush_threshold", "1024");
         SetDistVariableUpdater updater = new SetDistVariableUpdater();
         ContextManager contextManager = mockContextManager();
         when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
-        updater.executeUpdate(connectionSession, statement);
+        updater.executeUpdate(null, statement);
         Object actualValue = contextManager.getMetaDataContexts().getMetaData().getProps().getProps().get("proxy-frontend-flush-threshold");
         assertThat(actualValue.toString(), is("1024"));
         assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD), is(1024));
     }
     
     @Test
-    void assertExecuteWithTemporaryConfigurationKey() {
+    void assertExecuteWithTemporaryConfigurationKey() throws SQLException {
         SetDistVariableStatement statement = new SetDistVariableStatement("proxy_meta_data_collector_enabled", "false");
         SetDistVariableUpdater updater = new SetDistVariableUpdater();
         ContextManager contextManager = mockContextManager();
         when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
-        updater.executeUpdate(connectionSession, statement);
+        updater.executeUpdate(null, statement);
         Object actualValue = contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getProps().get("proxy-meta-data-collector-enabled");
         assertThat(actualValue.toString(), is("false"));
         assertThat(contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getValue(TemporaryConfigurationPropertyKey.PROXY_META_DATA_COLLECTOR_ENABLED), is(false));
     }
     
     @Test
-    void assertExecuteWithTypedSPI() {
+    void assertExecuteWithTypedSPI() throws SQLException {
         SetDistVariableStatement statement = new SetDistVariableStatement("proxy_frontend_database_protocol_type", "MySQL");
         SetDistVariableUpdater updater = new SetDistVariableUpdater();
         ContextManager contextManager = mockContextManager();
         when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
-        updater.executeUpdate(connectionSession, statement);
+        updater.executeUpdate(null, statement);
         Object actualValue = contextManager.getMetaDataContexts().getMetaData().getProps().getProps().get("proxy-frontend-database-protocol-type");
         assertThat(actualValue.toString(), is("MySQL"));
         assertInstanceOf(MySQLDatabaseType.class, contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_FRONTEND_DATABASE_PROTOCOL_TYPE));
     }
     
     @Test
-    void assertExecuteWithSystemLogLevel() {
+    void assertExecuteWithSystemLogLevel() throws SQLException {
         SetDistVariableStatement statement = new SetDistVariableStatement("system_log_level", "debug");
         SetDistVariableUpdater updater = new SetDistVariableUpdater();
         ContextManager contextManager = mockContextManager();
         when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
-        updater.executeUpdate(connectionSession, statement);
+        updater.executeUpdate(null, statement);
         Object actualValue = contextManager.getMetaDataContexts().getMetaData().getProps().getProps().get("system-log-level");
         assertThat(actualValue.toString(), is("DEBUG"));
         assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL), is(Level.DEBUG));
@@ -111,7 +108,7 @@ class SetDistVariableUpdaterTest {
         when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
         SetDistVariableStatement statement = new SetDistVariableStatement("system_log_level", "invalid");
         SetDistVariableUpdater updater = new SetDistVariableUpdater();
-        assertThrows(InvalidValueException.class, () -> updater.executeUpdate(connectionSession, statement));
+        assertThrows(InvalidValueException.class, () -> updater.executeUpdate(null, statement));
     }
     
     private ContextManager mockContextManager() {