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

zhonghongsheng 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 583a85e8faf Refactor DatabaseRuleDefinitionExecuteEngine for drop rule 
(#29905)
583a85e8faf is described below

commit 583a85e8fafbd9bf7908f396abd3f213948cd875
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Jan 29 18:20:43 2024 +0800

    Refactor DatabaseRuleDefinitionExecuteEngine for drop rule (#29905)
    
    * Refactor ImportMetaDataExecutorTest
    
    * Refactor DatabaseRuleDefinitionExecuteEngine for drop rule
    
    * Refactor DatabaseRuleDefinitionExecuteEngine for drop rule
    
    * Refactor DatabaseRuleDefinitionExecuteEngine for drop rule
    
    * Refactor DatabaseRuleDefinitionExecuteEngine for drop rule
    
    * Refactor DatabaseRuleDefinitionExecuteEngine for drop rule
---
 .../update/DropBroadcastTableRuleExecutor.java     | 17 +++++-----------
 .../update/DropBroadcastTableRuleExecutorTest.java |  6 ------
 .../handler/update/DropEncryptRuleExecutor.java    | 10 +++++-----
 .../update/DropEncryptRuleExecutorTest.java        |  5 -----
 .../handler/update/DropMaskRuleExecutor.java       | 10 +++++-----
 .../handler/update/DropMaskRuleExecutorTest.java   |  5 -----
 .../CreateReadwriteSplittingRuleExecutor.java      |  3 +--
 .../update/DropReadwriteSplittingRuleExecutor.java | 14 +++++--------
 .../DropReadwriteSplittingRuleExecutorTest.java    |  5 -----
 .../update/DropDefaultShadowAlgorithmExecutor.java | 19 ++++++++----------
 .../update/DropShadowAlgorithmExecutor.java        | 10 +++++-----
 .../handler/update/DropShadowRuleExecutor.java     | 19 ++++++------------
 .../update/DropShadowAlgorithmExecutorTest.java    |  7 -------
 .../distsql/update/DropShadowRuleExecutorTest.java |  5 -----
 .../CreateShardingTableReferenceRuleExecutor.java  |  7 ++-----
 .../DropDefaultShardingStrategyExecutor.java       | 17 +++++-----------
 .../update/DropShardingAlgorithmExecutor.java      | 15 ++++----------
 .../update/DropShardingAuditorExecutor.java        | 22 +++++++++------------
 .../update/DropShardingKeyGeneratorExecutor.java   | 22 +++++++++------------
 .../update/DropShardingTableReferenceExecutor.java | 15 ++++++--------
 .../update/DropShardingTableRuleExecutor.java      | 23 ++++++++--------------
 .../DropDefaultShardingStrategyExecutorTest.java   |  5 -----
 .../update/DropShardingAlgorithmExecutorTest.java  | 11 -----------
 .../DropShardingTableReferenceExecutorTest.java    |  5 -----
 .../update/DropShardingTableRuleExecutorTest.java  | 12 -----------
 .../DatabaseRuleDefinitionExecuteEngine.java       | 13 ++++++++----
 .../ral/updatable/ImportMetaDataExecutorTest.java  |  9 ++++++---
 27 files changed, 98 insertions(+), 213 deletions(-)

diff --git 
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
 
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
index dcc6f177322..54af6295ba4 100644
--- 
a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
+++ 
b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutor.java
@@ -21,9 +21,10 @@ import lombok.Setter;
 import 
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
 import 
org.apache.shardingsphere.broadcast.distsql.statement.DropBroadcastTableRuleStatement;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 
 import java.util.Collection;
 import java.util.HashSet;
@@ -32,6 +33,7 @@ import java.util.stream.Collectors;
 /**
  * Drop broadcast table rule executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Broadcast")
 @Setter
 public final class DropBroadcastTableRuleExecutor implements 
DatabaseRuleDropExecutor<DropBroadcastTableRuleStatement, 
BroadcastRuleConfiguration> {
     
@@ -39,21 +41,12 @@ public final class DropBroadcastTableRuleExecutor 
implements DatabaseRuleDropExe
     
     @Override
     public void checkBeforeUpdate(final DropBroadcastTableRuleStatement 
sqlStatement, final BroadcastRuleConfiguration currentRuleConfig) {
-        if (!isExistRuleConfig(currentRuleConfig) && 
sqlStatement.isIfExists()) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkBroadcastTableRuleExist(sqlStatement, currentRuleConfig);
         }
-        checkCurrentRuleConfiguration(currentRuleConfig);
-        checkBroadcastTableRuleExist(sqlStatement, currentRuleConfig);
-    }
-    
-    private void checkCurrentRuleConfiguration(final 
BroadcastRuleConfiguration currentRuleConfig) {
-        ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new 
MissingRequiredRuleException("Broadcast", database.getName()));
     }
     
     private void checkBroadcastTableRuleExist(final 
DropBroadcastTableRuleStatement sqlStatement, final BroadcastRuleConfiguration 
currentRuleConfig) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
         Collection<String> currentRules = currentRuleConfig.getTables();
         Collection<String> notExistRules = 
sqlStatement.getTables().stream().filter(each -> 
!containsIgnoreCase(currentRules, each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistRules.isEmpty(), () -> 
new MissingRequiredRuleException("Broadcast", database.getName(), 
notExistRules));
diff --git 
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutorTest.java
 
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutorTest.java
index bd5257ff80f..3ae7e25a9ca 100644
--- 
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutorTest.java
+++ 
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/DropBroadcastTableRuleExecutorTest.java
@@ -44,12 +44,6 @@ class DropBroadcastTableRuleExecutorTest {
         executor.setDatabase(database);
     }
     
-    @Test
-    void assertCheckSQLStatementWithoutCurrentRule() {
-        DropBroadcastTableRuleStatement sqlStatement = new 
DropBroadcastTableRuleStatement(false, Collections.singleton("t_address"));
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(sqlStatement, null));
-    }
-    
     @Test
     void assertCheckSQLStatementWithoutToBeDroppedRule() {
         DropBroadcastTableRuleStatement sqlStatement = new 
DropBroadcastTableRuleStatement(false, Collections.singleton("t_address"));
diff --git 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutor.java
 
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutor.java
index 024d899915b..77b230a44e5 100644
--- 
a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutor.java
+++ 
b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutor.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.encrypt.distsql.handler.update;
 
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
 import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration;
@@ -39,6 +40,7 @@ import java.util.stream.Collectors;
 /**
  * Drop encrypt rule executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Encrypt")
 @Setter
 public final class DropEncryptRuleExecutor implements 
DatabaseRuleDropExecutor<DropEncryptRuleStatement, EncryptRuleConfiguration> {
     
@@ -46,14 +48,12 @@ public final class DropEncryptRuleExecutor implements 
DatabaseRuleDropExecutor<D
     
     @Override
     public void checkBeforeUpdate(final DropEncryptRuleStatement sqlStatement, 
final EncryptRuleConfiguration currentRuleConfig) {
-        checkToBeDroppedEncryptTableNames(sqlStatement, currentRuleConfig);
+        if (!sqlStatement.isIfExists()) {
+            checkToBeDroppedEncryptTableNames(sqlStatement, currentRuleConfig);
+        }
     }
     
     private void checkToBeDroppedEncryptTableNames(final 
DropEncryptRuleStatement sqlStatement, final EncryptRuleConfiguration 
currentRuleConfig) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
-        
ShardingSpherePreconditions.checkState(isExistRuleConfig(currentRuleConfig), () 
-> new MissingRequiredRuleException("Encrypt", database.getName()));
         Collection<String> currentEncryptTableNames = 
currentRuleConfig.getTables().stream().map(EncryptTableRuleConfiguration::getName).collect(Collectors.toList());
         Collection<String> notExistedTableNames = 
sqlStatement.getTables().stream().filter(each -> 
!currentEncryptTableNames.contains(each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(), 
() -> new MissingRequiredRuleException("Encrypt", database.getName(), 
notExistedTableNames));
diff --git 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
index 055f460ebea..05a32c3a6ed 100644
--- 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
+++ 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
@@ -52,11 +52,6 @@ class DropEncryptRuleExecutorTest {
         executor.setDatabase(mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS));
     }
     
-    @Test
-    void assertCheckSQLStatementWithoutCurrentRule() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(createSQLStatement("t_encrypt"), null));
-    }
-    
     @Test
     void assertCheckSQLStatementWithoutToBeDroppedRule() {
         assertThrows(MissingRequiredRuleException.class,
diff --git 
a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutor.java
 
b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutor.java
index 0358af84f04..b4aafe2abbf 100644
--- 
a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutor.java
+++ 
b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutor.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.mask.distsql.handler.update;
 
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -39,6 +40,7 @@ import java.util.stream.Collectors;
 /**
  * Drop mask rule statement executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Mask")
 @Setter
 public final class DropMaskRuleExecutor implements 
DatabaseRuleDropExecutor<DropMaskRuleStatement, MaskRuleConfiguration> {
     
@@ -46,14 +48,12 @@ public final class DropMaskRuleExecutor implements 
DatabaseRuleDropExecutor<Drop
     
     @Override
     public void checkBeforeUpdate(final DropMaskRuleStatement sqlStatement, 
final MaskRuleConfiguration currentRuleConfig) {
-        checkToBeDroppedMaskTableNames(sqlStatement, currentRuleConfig);
+        if (!sqlStatement.isIfExists()) {
+            checkToBeDroppedMaskTableNames(sqlStatement, currentRuleConfig);
+        }
     }
     
     private void checkToBeDroppedMaskTableNames(final DropMaskRuleStatement 
sqlStatement, final MaskRuleConfiguration currentRuleConfig) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
-        
ShardingSpherePreconditions.checkState(isExistRuleConfig(currentRuleConfig), () 
-> new MissingRequiredRuleException("Mask", database.getName()));
         Collection<String> currentMaskTableNames = 
currentRuleConfig.getTables().stream().map(MaskTableRuleConfiguration::getName).collect(Collectors.toList());
         Collection<String> notExistedTableNames = 
sqlStatement.getTables().stream().filter(each -> 
!currentMaskTableNames.contains(each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(), 
() -> new MissingRequiredRuleException("Mask", database.getName(), 
notExistedTableNames));
diff --git 
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
 
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
index 9b885f01260..ac0bcdfc4bb 100644
--- 
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
+++ 
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
@@ -47,11 +47,6 @@ class DropMaskRuleExecutorTest {
         executor.setDatabase(mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS));
     }
     
-    @Test
-    void assertCheckSQLStatementWithoutCurrentRule() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(createSQLStatement(false, "t_mask"), null));
-    }
-    
     @Test
     void assertCheckSQLStatementWithoutToBeDroppedRule() {
         assertThrows(MissingRequiredRuleException.class,
diff --git 
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutor.java
 
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutor.java
index e081fd9349e..04b186e1939 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutor.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleExecutor.java
@@ -45,8 +45,7 @@ public final class CreateReadwriteSplittingRuleExecutor 
implements DatabaseRuleC
     }
     
     @Override
-    public ReadwriteSplittingRuleConfiguration 
buildToBeCreatedRuleConfiguration(
-                                                                               
  final CreateReadwriteSplittingRuleStatement sqlStatement,
+    public ReadwriteSplittingRuleConfiguration 
buildToBeCreatedRuleConfiguration(final CreateReadwriteSplittingRuleStatement 
sqlStatement,
                                                                                
  final ReadwriteSplittingRuleConfiguration currentRuleConfig) {
         Collection<ReadwriteSplittingRuleSegment> segments = 
sqlStatement.getRules();
         if (sqlStatement.isIfNotExists()) {
diff --git 
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutor.java
 
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutor.java
index 1c09590a32e..9266471e314 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutor.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutor.java
@@ -20,17 +20,17 @@ package 
org.apache.shardingsphere.readwritesplitting.distsql.handler.update;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.RuleInUsedException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.datanode.DataNode;
+import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
-import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.StaticDataSourceContainedRule;
 import 
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
 import 
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
-import 
org.apache.shardingsphere.readwritesplitting.distsql.handler.checker.ReadwriteSplittingRuleStatementChecker;
 import 
org.apache.shardingsphere.readwritesplitting.distsql.statement.DropReadwriteSplittingRuleStatement;
 import 
org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule;
 import org.apache.shardingsphere.single.rule.SingleRule;
@@ -46,6 +46,7 @@ import java.util.stream.Collectors;
 /**
  * Drop readwrite-splitting rule executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Readwrite-splitting")
 @Setter
 public final class DropReadwriteSplittingRuleExecutor implements 
DatabaseRuleDropExecutor<DropReadwriteSplittingRuleStatement, 
ReadwriteSplittingRuleConfiguration> {
     
@@ -53,18 +54,13 @@ public final class DropReadwriteSplittingRuleExecutor 
implements DatabaseRuleDro
     
     @Override
     public void checkBeforeUpdate(final DropReadwriteSplittingRuleStatement 
sqlStatement, final ReadwriteSplittingRuleConfiguration currentRuleConfig) {
-        if (!isExistRuleConfig(currentRuleConfig) && 
sqlStatement.isIfExists()) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkToBeDroppedRuleNames(sqlStatement, currentRuleConfig);
         }
-        
ReadwriteSplittingRuleStatementChecker.checkRuleConfigurationExist(database, 
currentRuleConfig);
-        checkToBeDroppedRuleNames(sqlStatement, currentRuleConfig);
         checkToBeDroppedInUsed(sqlStatement);
     }
     
     private void checkToBeDroppedRuleNames(final 
DropReadwriteSplittingRuleStatement sqlStatement, final 
ReadwriteSplittingRuleConfiguration currentRuleConfig) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
         Collection<String> currentRuleNames = 
currentRuleConfig.getDataSources().stream().map(ReadwriteSplittingDataSourceRuleConfiguration::getName).collect(Collectors.toList());
         Collection<String> notExistedRuleNames = 
sqlStatement.getNames().stream().filter(each -> 
!currentRuleNames.contains(each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), 
() -> new MissingRequiredRuleException("Readwrite-splitting", 
database.getName(), sqlStatement.getNames()));
diff --git 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutorTest.java
 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutorTest.java
index 49d0e31c2af..4cbebd7d3e9 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutorTest.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/DropReadwriteSplittingRuleExecutorTest.java
@@ -63,11 +63,6 @@ class DropReadwriteSplittingRuleExecutorTest {
         executor.setDatabase(database);
     }
     
-    @Test
-    void assertCheckSQLStatementWithoutCurrentRule() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(createSQLStatement(), null));
-    }
-    
     @Test
     void assertCheckSQLStatementWithoutToBeDroppedRule() throws 
RuleDefinitionViolationException {
         assertThrows(MissingRequiredRuleException.class,
diff --git 
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
 
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
index 768478172c5..1b96dede62b 100644
--- 
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
+++ 
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropDefaultShadowAlgorithmExecutor.java
@@ -19,11 +19,11 @@ package 
org.apache.shardingsphere.shadow.distsql.handler.update;
 
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
-import 
org.apache.shardingsphere.shadow.distsql.handler.checker.ShadowRuleStatementChecker;
 import 
org.apache.shardingsphere.shadow.distsql.statement.DropDefaultShadowAlgorithmStatement;
 
 import java.util.Collections;
@@ -31,6 +31,7 @@ import java.util.Collections;
 /**
  * Drop default shadow algorithm executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Shadow")
 @Setter
 public final class DropDefaultShadowAlgorithmExecutor implements 
DatabaseRuleDropExecutor<DropDefaultShadowAlgorithmStatement, 
ShadowRuleConfiguration> {
     
@@ -38,18 +39,14 @@ public final class DropDefaultShadowAlgorithmExecutor 
implements DatabaseRuleDro
     
     @Override
     public void checkBeforeUpdate(final DropDefaultShadowAlgorithmStatement 
sqlStatement, final ShadowRuleConfiguration currentRuleConfig) {
-        if (sqlStatement.isIfExists() && 
!isExistRuleConfig(currentRuleConfig)) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkAlgorithm(currentRuleConfig);
         }
-        
ShadowRuleStatementChecker.checkRuleConfigurationExists(database.getName(), 
currentRuleConfig);
-        checkAlgorithm(sqlStatement, currentRuleConfig);
     }
     
-    private void checkAlgorithm(final DropDefaultShadowAlgorithmStatement 
sqlStatement, final ShadowRuleConfiguration currentRuleConfig) {
-        if (!sqlStatement.isIfExists()) {
-            
ShardingSpherePreconditions.checkNotNull(currentRuleConfig.getDefaultShadowAlgorithmName(),
-                    () -> new MissingRequiredAlgorithmException("shadow", 
database.getName(), Collections.singleton("default")));
-        }
+    private void checkAlgorithm(final ShadowRuleConfiguration 
currentRuleConfig) {
+        ShardingSpherePreconditions.checkNotNull(
+                currentRuleConfig.getDefaultShadowAlgorithmName(), () -> new 
MissingRequiredAlgorithmException("shadow", database.getName(), 
Collections.singleton("default")));
     }
     
     @Override
diff --git 
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
 
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
index 11bc70b89fd..b2918d9e362 100644
--- 
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
+++ 
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowAlgorithmExecutor.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.shadow.distsql.handler.update;
 
 import lombok.Setter;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.DistSQLException;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
@@ -40,6 +41,7 @@ import java.util.stream.Collectors;
 /**
  * Drop shadow algorithm executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Shadow")
 @Setter
 public final class DropShadowAlgorithmExecutor implements 
DatabaseRuleDropExecutor<DropShadowAlgorithmStatement, ShadowRuleConfiguration> 
{
     
@@ -47,11 +49,9 @@ public final class DropShadowAlgorithmExecutor implements 
DatabaseRuleDropExecut
     
     @Override
     public void checkBeforeUpdate(final DropShadowAlgorithmStatement 
sqlStatement, final ShadowRuleConfiguration currentRuleConfig) {
-        if (sqlStatement.isIfExists() && 
!isExistRuleConfig(currentRuleConfig)) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkAlgorithm(sqlStatement, currentRuleConfig);
         }
-        
ShadowRuleStatementChecker.checkRuleConfigurationExists(database.getName(), 
currentRuleConfig);
-        checkAlgorithm(sqlStatement, currentRuleConfig);
     }
     
     private void checkAlgorithm(final DropShadowAlgorithmStatement 
sqlStatement, final ShadowRuleConfiguration currentRuleConfig) {
@@ -62,7 +62,7 @@ public final class DropShadowAlgorithmExecutor implements 
DatabaseRuleDropExecut
             ShadowRuleStatementChecker.checkExisted(
                     requiredAlgorithms, currentAlgorithms, 
notExistedAlgorithms -> new MissingRequiredAlgorithmException("shadow", 
database.getName(), notExistedAlgorithms));
         }
-        checkAlgorithmInUsed(requiredAlgorithms, 
getAlgorithmInUse(currentRuleConfig), identical -> new 
AlgorithmInUsedException("Sharding", database.getName(), identical));
+        checkAlgorithmInUsed(requiredAlgorithms, 
getAlgorithmInUse(currentRuleConfig), identical -> new 
AlgorithmInUsedException("Shadow", database.getName(), identical));
         
ShardingSpherePreconditions.checkState(!requiredAlgorithms.contains(defaultShadowAlgorithmName),
                 () -> new AlgorithmInUsedException("Shadow", 
database.getName(), Collections.singleton(defaultShadowAlgorithmName)));
     }
diff --git 
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutor.java
 
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutor.java
index 1fe73bedcdd..d8e0a5d6897 100644
--- 
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutor.java
+++ 
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleExecutor.java
@@ -19,8 +19,8 @@ package 
org.apache.shardingsphere.shadow.distsql.handler.update;
 
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
-import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
@@ -40,6 +40,7 @@ import java.util.stream.Collectors;
 /**
  * Drop shadow rule executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Shadow")
 @Setter
 public final class DropShadowRuleExecutor implements 
DatabaseRuleDropExecutor<DropShadowRuleStatement, ShadowRuleConfiguration> {
     
@@ -47,22 +48,14 @@ public final class DropShadowRuleExecutor implements 
DatabaseRuleDropExecutor<Dr
     
     @Override
     public void checkBeforeUpdate(final DropShadowRuleStatement sqlStatement, 
final ShadowRuleConfiguration currentRuleConfig) {
-        if (sqlStatement.isIfExists() && 
!isExistRuleConfig(currentRuleConfig)) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkRuleExisted(sqlStatement, currentRuleConfig);
         }
-        checkConfigurationExisted(currentRuleConfig);
-        checkRuleExisted(sqlStatement, currentRuleConfig);
-    }
-    
-    private void checkConfigurationExisted(final ShadowRuleConfiguration 
currentRuleConfig) {
-        ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new 
MissingRequiredRuleException("Shadow", database.getName()));
     }
     
     private void checkRuleExisted(final DropShadowRuleStatement sqlStatement, 
final ShadowRuleConfiguration currentRuleConfig) {
-        if (!sqlStatement.isIfExists()) {
-            ShadowRuleStatementChecker.checkExisted(sqlStatement.getNames(), 
getDataSourceNames(currentRuleConfig),
-                    notExistedRuleNames -> new 
MissingRequiredRuleException("Shadow", database.getName(), 
notExistedRuleNames));
-        }
+        ShadowRuleStatementChecker.checkExisted(sqlStatement.getNames(), 
getDataSourceNames(currentRuleConfig),
+                notExistedRuleNames -> new 
MissingRequiredRuleException("Shadow", database.getName(), 
notExistedRuleNames));
     }
     
     private Collection<String> getDataSourceNames(final 
ShadowRuleConfiguration currentRuleConfig) {
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmExecutorTest.java
index 47d568358da..d994a43d84c 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowAlgorithmExecutorTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.shadow.distsql.update;
 
-import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
@@ -28,7 +27,6 @@ import org.junit.jupiter.api.Test;
 
 import java.util.Arrays;
 
-import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
@@ -42,11 +40,6 @@ class DropShadowAlgorithmExecutorTest {
         executor.setDatabase(mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS));
     }
     
-    @Test
-    void assertExecuteWithoutAlgorithmNameInMetaData() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(createSQLStatement("ruleSegment"), null));
-    }
-    
     @Test
     void assertExecuteWithIfExists() {
         DropShadowAlgorithmStatement sqlStatement = createSQLStatement(true, 
"ruleSegment");
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleExecutorTest.java
index c52c941574e..5625bc296a7 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/DropShadowRuleExecutorTest.java
@@ -49,11 +49,6 @@ class DropShadowRuleExecutorTest {
         executor.setDatabase(mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS));
     }
     
-    @Test
-    void assertCheckWithNullConfiguration() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(createSQLStatement("anyRuleName"), null));
-    }
-    
     @Test
     void assertCheckWithRuleNotExisted() {
         assertThrows(MissingRequiredRuleException.class,
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
index bf524fdf15c..a127753850c 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableReferenceRuleExecutor.java
@@ -21,6 +21,7 @@ import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.InvalidRuleConfigurationException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleCreateExecutor;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
@@ -41,6 +42,7 @@ import java.util.stream.Collectors;
 /**
  * Create sharding table reference rule executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Sharding")
 @Setter
 public final class CreateShardingTableReferenceRuleExecutor implements 
DatabaseRuleCreateExecutor<CreateShardingTableReferenceRuleStatement, 
ShardingRuleConfiguration> {
     
@@ -48,7 +50,6 @@ public final class CreateShardingTableReferenceRuleExecutor 
implements DatabaseR
     
     @Override
     public void checkBeforeUpdate(final 
CreateShardingTableReferenceRuleStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
-        checkCurrentRuleConfiguration(currentRuleConfig);
         if (!sqlStatement.isIfNotExists()) {
             checkDuplicatedRuleNames(sqlStatement, currentRuleConfig);
         }
@@ -57,10 +58,6 @@ public final class CreateShardingTableReferenceRuleExecutor 
implements DatabaseR
         checkShardingTableReferenceRulesValid(sqlStatement, currentRuleConfig);
     }
     
-    private void checkCurrentRuleConfiguration(final ShardingRuleConfiguration 
currentRuleConfig) {
-        ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new 
MissingRequiredRuleException("Sharding", database.getName()));
-    }
-    
     private void checkDuplicatedRuleNames(final 
CreateShardingTableReferenceRuleStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
         Collection<String> duplicatedRuleNames = 
getDuplicatedRuleNames(sqlStatement, currentRuleConfig);
         ShardingSpherePreconditions.checkState(duplicatedRuleNames.isEmpty(), 
() -> new DuplicateRuleException("sharding table reference", 
database.getName(), duplicatedRuleNames));
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
index 39f51fd3a9a..a116be695b2 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropDefaultShardingStrategyExecutor.java
@@ -19,9 +19,10 @@ package 
org.apache.shardingsphere.sharding.distsql.handler.update;
 
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.distsql.handler.enums.ShardingStrategyLevelType;
@@ -32,6 +33,7 @@ import java.util.Optional;
 /**
  * Drop default sharding strategy executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Sharding")
 @Setter
 public final class DropDefaultShardingStrategyExecutor implements 
DatabaseRuleDropExecutor<DropDefaultShardingStrategyStatement, 
ShardingRuleConfiguration> {
     
@@ -39,21 +41,12 @@ public final class DropDefaultShardingStrategyExecutor 
implements DatabaseRuleDr
     
     @Override
     public void checkBeforeUpdate(final DropDefaultShardingStrategyStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
-        if (!isExistRuleConfig(currentRuleConfig) && 
sqlStatement.isIfExists()) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkExist(sqlStatement, currentRuleConfig);
         }
-        checkCurrentRuleConfiguration(currentRuleConfig);
-        checkExist(sqlStatement, currentRuleConfig);
-    }
-    
-    private void checkCurrentRuleConfiguration(final ShardingRuleConfiguration 
currentRuleConfig) {
-        ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new 
MissingRequiredRuleException("Sharding", database.getName()));
     }
     
     private void checkExist(final DropDefaultShardingStrategyStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
         Optional<ShardingStrategyConfiguration> strategyConfig = 
getStrategyConfiguration(currentRuleConfig, sqlStatement.getDefaultType());
         ShardingSpherePreconditions.checkState(strategyConfig.isPresent(), () 
-> new MissingRequiredRuleException(
                 String.format("Default sharding %s strategy", 
sqlStatement.getDefaultType().toLowerCase()), database.getName()));
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
index 05fc9fc40ee..5161fceda02 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAlgorithmExecutor.java
@@ -20,6 +20,7 @@ package 
org.apache.shardingsphere.sharding.distsql.handler.update;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
@@ -34,6 +35,7 @@ import java.util.stream.Collectors;
 /**
  * Drop sharding algorithm executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Sharding")
 @Setter
 public final class DropShardingAlgorithmExecutor implements 
DatabaseRuleDropExecutor<DropShardingAlgorithmStatement, 
ShardingRuleConfiguration> {
     
@@ -41,22 +43,13 @@ public final class DropShardingAlgorithmExecutor implements 
DatabaseRuleDropExec
     
     @Override
     public void checkBeforeUpdate(final DropShardingAlgorithmStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
-        if (null == currentRuleConfig && sqlStatement.isIfExists()) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkToBeDroppedShardingAlgorithms(sqlStatement, 
currentRuleConfig);
         }
-        checkCurrentRuleConfiguration(currentRuleConfig);
-        checkToBeDroppedShardingAlgorithms(sqlStatement, currentRuleConfig);
         checkShardingAlgorithmsInUsed(sqlStatement, currentRuleConfig);
     }
     
-    private void checkCurrentRuleConfiguration(final ShardingRuleConfiguration 
currentRuleConfig) {
-        ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new 
MissingRequiredAlgorithmException("Sharding", database.getName()));
-    }
-    
     private void checkToBeDroppedShardingAlgorithms(final 
DropShardingAlgorithmStatement sqlStatement, final ShardingRuleConfiguration 
currentRuleConfig) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
         Collection<String> currentShardingAlgorithms = 
getCurrentShardingAlgorithms(currentRuleConfig);
         Collection<String> notExistedAlgorithms = 
sqlStatement.getNames().stream().filter(each -> 
!currentShardingAlgorithms.contains(each)).collect(Collectors.toList());
         if (!notExistedAlgorithms.isEmpty()) {
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
index 958c9f61e60..8d1b8a8de49 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingAuditorExecutor.java
@@ -20,6 +20,7 @@ package 
org.apache.shardingsphere.sharding.distsql.handler.update;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -29,12 +30,12 @@ import 
org.apache.shardingsphere.sharding.distsql.statement.DropShardingAuditorS
 
 import java.util.Collection;
 import java.util.LinkedHashSet;
-import java.util.LinkedList;
 import java.util.stream.Collectors;
 
 /**
  * Drop sharding auditor statement executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Sharding auditor")
 @Setter
 public final class DropShardingAuditorExecutor implements 
DatabaseRuleDropExecutor<DropShardingAuditorStatement, 
ShardingRuleConfiguration> {
     
@@ -42,25 +43,20 @@ public final class DropShardingAuditorExecutor implements 
DatabaseRuleDropExecut
     
     @Override
     public void checkBeforeUpdate(final DropShardingAuditorStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
-        if (null == currentRuleConfig && sqlStatement.isIfExists()) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkExist(sqlStatement, currentRuleConfig);
         }
-        Collection<String> auditorNames = new 
LinkedList<>(sqlStatement.getNames());
-        checkExist(auditorNames, currentRuleConfig, sqlStatement);
-        checkInUsed(auditorNames, currentRuleConfig);
+        checkInUsed(sqlStatement, currentRuleConfig);
     }
     
-    private void checkExist(final Collection<String> auditorNames, final 
ShardingRuleConfiguration currentRuleConfig, final DropShardingAuditorStatement 
sqlStatement) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
-        Collection<String> notExistAuditors = 
auditorNames.stream().filter(each -> 
!currentRuleConfig.getAuditors().containsKey(each)).collect(Collectors.toList());
+    private void checkExist(final DropShardingAuditorStatement sqlStatement, 
final ShardingRuleConfiguration currentRuleConfig) {
+        Collection<String> notExistAuditors = 
sqlStatement.getNames().stream().filter(each -> 
!currentRuleConfig.getAuditors().containsKey(each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistAuditors.isEmpty(), () 
-> new MissingRequiredAlgorithmException("Sharding auditor", 
database.getName(), notExistAuditors));
     }
     
-    private void checkInUsed(final Collection<String> auditorNames, final 
ShardingRuleConfiguration currentRuleConfig) {
+    private void checkInUsed(final DropShardingAuditorStatement sqlStatement, 
final ShardingRuleConfiguration currentRuleConfig) {
         Collection<String> usedAuditors = getUsedAuditors(currentRuleConfig);
-        Collection<String> inUsedNames = 
auditorNames.stream().filter(usedAuditors::contains).collect(Collectors.toList());
+        Collection<String> inUsedNames = 
sqlStatement.getNames().stream().filter(usedAuditors::contains).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(inUsedNames.isEmpty(), () -> 
new AlgorithmInUsedException("Sharding auditor", database.getName(), 
inUsedNames));
     }
     
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
index ad232fc837f..99d9d36095f 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingKeyGeneratorExecutor.java
@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.AlgorithmInUsedException;
 import 
org.apache.shardingsphere.distsql.handler.exception.algorithm.MissingRequiredAlgorithmException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -30,12 +31,12 @@ import 
org.apache.shardingsphere.sharding.distsql.statement.DropShardingKeyGener
 
 import java.util.Collection;
 import java.util.LinkedHashSet;
-import java.util.LinkedList;
 import java.util.stream.Collectors;
 
 /**
  * Drop sharding key generator executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Key generator")
 @Setter
 public final class DropShardingKeyGeneratorExecutor implements 
DatabaseRuleDropExecutor<DropShardingKeyGeneratorStatement, 
ShardingRuleConfiguration> {
     
@@ -43,25 +44,20 @@ public final class DropShardingKeyGeneratorExecutor 
implements DatabaseRuleDropE
     
     @Override
     public void checkBeforeUpdate(final DropShardingKeyGeneratorStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
-        if (null == currentRuleConfig && sqlStatement.isIfExists()) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkExist(sqlStatement, currentRuleConfig);
         }
-        Collection<String> keyGeneratorNames = new 
LinkedList<>(sqlStatement.getNames());
-        checkExist(keyGeneratorNames, currentRuleConfig, sqlStatement);
-        checkInUsed(keyGeneratorNames, currentRuleConfig);
+        checkInUsed(sqlStatement, currentRuleConfig);
     }
     
-    private void checkExist(final Collection<String> keyGeneratorNames, final 
ShardingRuleConfiguration currentRuleConfig, final 
DropShardingKeyGeneratorStatement sqlStatement) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
-        Collection<String> notExistKeyGenerators = 
keyGeneratorNames.stream().filter(each -> 
!currentRuleConfig.getKeyGenerators().containsKey(each)).collect(Collectors.toList());
+    private void checkExist(final DropShardingKeyGeneratorStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
+        Collection<String> notExistKeyGenerators = 
sqlStatement.getNames().stream().filter(each -> 
!currentRuleConfig.getKeyGenerators().containsKey(each)).collect(Collectors.toList());
         
ShardingSpherePreconditions.checkState(notExistKeyGenerators.isEmpty(), () -> 
new MissingRequiredAlgorithmException("Key generator", database.getName(), 
notExistKeyGenerators));
     }
     
-    private void checkInUsed(final Collection<String> keyGeneratorNames, final 
ShardingRuleConfiguration currentRuleConfig) {
+    private void checkInUsed(final DropShardingKeyGeneratorStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
         Collection<String> usedKeyGenerators = 
getUsedKeyGenerators(currentRuleConfig);
-        Collection<String> inUsedNames = 
keyGeneratorNames.stream().filter(usedKeyGenerators::contains).collect(Collectors.toList());
+        Collection<String> inUsedNames = 
sqlStatement.getNames().stream().filter(usedKeyGenerators::contains).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(inUsedNames.isEmpty(), () -> 
new AlgorithmInUsedException("Key generator", database.getName(), inUsedNames));
     }
     
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
index 5e6d17fbed3..dbfc3afbbb9 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableReferenceExecutor.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.sharding.distsql.handler.update;
 
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -32,6 +33,7 @@ import java.util.stream.Collectors;
 /**
  * Drop sharding table reference executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Sharding")
 @Setter
 public final class DropShardingTableReferenceExecutor implements 
DatabaseRuleDropExecutor<DropShardingTableReferenceRuleStatement, 
ShardingRuleConfiguration> {
     
@@ -39,22 +41,17 @@ public final class DropShardingTableReferenceExecutor 
implements DatabaseRuleDro
     
     @Override
     public void checkBeforeUpdate(final 
DropShardingTableReferenceRuleStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
-        if (!isExistRuleConfig(currentRuleConfig) && 
sqlStatement.isIfExists()) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkCurrentRuleConfiguration(currentRuleConfig);
+            checkToBeDroppedShardingTableReferenceRules(sqlStatement, 
currentRuleConfig);
         }
-        checkCurrentRuleConfiguration(currentRuleConfig);
-        checkToBeDroppedShardingTableReferenceRules(sqlStatement, 
currentRuleConfig);
     }
     
     private void checkCurrentRuleConfiguration(final ShardingRuleConfiguration 
currentRuleConfig) {
-        ShardingSpherePreconditions.checkState(null != currentRuleConfig && 
!currentRuleConfig.getBindingTableGroups().isEmpty(),
-                () -> new MissingRequiredRuleException("Sharding table 
reference", database.getName()));
+        
ShardingSpherePreconditions.checkState(!currentRuleConfig.getBindingTableGroups().isEmpty(),
 () -> new MissingRequiredRuleException("Sharding table reference", 
database.getName()));
     }
     
     private void checkToBeDroppedShardingTableReferenceRules(final 
DropShardingTableReferenceRuleStatement sqlStatement, final 
ShardingRuleConfiguration currentRuleConfig) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
         Collection<String> currentRuleNames = 
getCurrentShardingTableReferenceRuleNames(currentRuleConfig);
         Collection<String> notExistedRuleNames = 
sqlStatement.getNames().stream().filter(each -> 
!containsIgnoreCase(currentRuleNames, each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistedRuleNames.isEmpty(), 
() -> new MissingRequiredRuleException("Sharding table reference", 
database.getName(), notExistedRuleNames));
diff --git 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
index a10d2d33771..219b308875f 100644
--- 
a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
+++ 
b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/update/DropShardingTableRuleExecutor.java
@@ -21,6 +21,7 @@ import com.google.common.base.Splitter;
 import lombok.Setter;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.RuleInUsedException;
+import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrentRuleRequired;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -39,6 +40,7 @@ import java.util.stream.Collectors;
 /**
  * Drop sharding table rule executor.
  */
+@DistSQLExecutorCurrentRuleRequired("Sharding")
 @Setter
 public final class DropShardingTableRuleExecutor implements 
DatabaseRuleDropExecutor<DropShardingTableRuleStatement, 
ShardingRuleConfiguration> {
     
@@ -46,32 +48,23 @@ public final class DropShardingTableRuleExecutor implements 
DatabaseRuleDropExec
     
     @Override
     public void checkBeforeUpdate(final DropShardingTableRuleStatement 
sqlStatement, final ShardingRuleConfiguration currentRuleConfig) {
-        if (!isExistRuleConfig(currentRuleConfig) && 
sqlStatement.isIfExists()) {
-            return;
+        if (!sqlStatement.isIfExists()) {
+            checkToBeDroppedShardingTableNames(sqlStatement, 
currentRuleConfig);
         }
-        checkCurrentRuleConfiguration(currentRuleConfig);
-        checkToBeDroppedShardingTableNames(sqlStatement, currentRuleConfig);
         checkBindingTables(sqlStatement, currentRuleConfig);
     }
     
-    private void checkCurrentRuleConfiguration(final ShardingRuleConfiguration 
currentRuleConfig) {
-        ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new 
MissingRequiredRuleException("Sharding", database.getName()));
-    }
-    
-    private Collection<String> getToBeDroppedShardingTableNames(final 
DropShardingTableRuleStatement sqlStatement) {
-        return sqlStatement.getTableNames().stream().map(each -> 
each.getIdentifier().getValue()).collect(Collectors.toList());
-    }
-    
     private void checkToBeDroppedShardingTableNames(final 
DropShardingTableRuleStatement sqlStatement, final ShardingRuleConfiguration 
currentRuleConfig) {
-        if (sqlStatement.isIfExists()) {
-            return;
-        }
         Collection<String> currentShardingTableNames = 
getCurrentShardingTableNames(currentRuleConfig);
         Collection<String> notExistedTableNames =
                 
getToBeDroppedShardingTableNames(sqlStatement).stream().filter(each -> 
!containsIgnoreCase(currentShardingTableNames, 
each)).collect(Collectors.toList());
         ShardingSpherePreconditions.checkState(notExistedTableNames.isEmpty(), 
() -> new MissingRequiredRuleException("sharding", database.getName(), 
notExistedTableNames));
     }
     
+    private Collection<String> getToBeDroppedShardingTableNames(final 
DropShardingTableRuleStatement sqlStatement) {
+        return sqlStatement.getTableNames().stream().map(each -> 
each.getIdentifier().getValue()).collect(Collectors.toList());
+    }
+    
     private boolean containsIgnoreCase(final Collection<String> collection, 
final String str) {
         return collection.stream().anyMatch(each -> 
each.equalsIgnoreCase(str));
     }
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropDefaultShardingStrategyExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropDefaultShardingStrategyExecutorTest.java
index 188821aba6b..6691b7baa73 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropDefaultShardingStrategyExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropDefaultShardingStrategyExecutorTest.java
@@ -49,11 +49,6 @@ class DropDefaultShardingStrategyExecutorTest {
         executor.setDatabase(mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS));
     }
     
-    @Test
-    void assertCheckSQLStatementWithoutCurrentRule() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(new DropDefaultShardingStrategyStatement(false, 
"TABLE"), null));
-    }
-    
     @Test
     void assertCheckSQLStatementWithoutExistedAlgorithm() {
         assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(createSQLStatement("table"), new 
ShardingRuleConfiguration()));
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmExecutorTest.java
index a35a25e6595..7eb2e6e7b70 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAlgorithmExecutorTest.java
@@ -53,17 +53,6 @@ class DropShardingAlgorithmExecutorTest {
         executor.setDatabase(mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS));
     }
     
-    @Test
-    void assertCheckSQLStatementWithoutCurrentRule() throws 
RuleDefinitionViolationException {
-        assertThrows(MissingRequiredAlgorithmException.class, () -> 
executor.checkBeforeUpdate(new DropShardingAlgorithmStatement(false, 
Collections.emptyList()), null));
-    }
-    
-    @Test
-    void assertCheckSQLStatementWithoutCurrentRuleWithIfExists() throws 
RuleDefinitionViolationException {
-        DropShardingAlgorithmStatement dropShardingAlgorithmStatement = new 
DropShardingAlgorithmStatement(true, Collections.emptyList());
-        executor.checkBeforeUpdate(dropShardingAlgorithmStatement, null);
-    }
-    
     @Test
     void assertCheckSQLStatementWithoutExistedAlgorithm() throws 
RuleDefinitionViolationException {
         assertThrows(MissingRequiredAlgorithmException.class, () -> 
executor.checkBeforeUpdate(createSQLStatement("t_order"), new 
ShardingRuleConfiguration()));
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableReferenceExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableReferenceExecutorTest.java
index 61576549a2e..de355304a87 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableReferenceExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableReferenceExecutorTest.java
@@ -48,11 +48,6 @@ class DropShardingTableReferenceExecutorTest {
         executor.setDatabase(mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS));
     }
     
-    @Test
-    void assertCheckWithoutCurrentRule() {
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(new DropShardingTableReferenceRuleStatement(false, 
Collections.singleton("notExisted")), null));
-    }
-    
     @Test
     void assertCheckWithNotExistedShardingTableReferenceRule() {
         assertThrows(MissingRequiredRuleException.class,
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleExecutorTest.java
index c5b7970f511..aaa55c452b0 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingTableRuleExecutorTest.java
@@ -59,21 +59,9 @@ class DropShardingTableRuleExecutorTest {
         executor.setDatabase(mock(ShardingSphereDatabase.class, 
Answers.RETURNS_DEEP_STUBS));
     }
     
-    @Test
-    void assertCheckSQLStatementWithoutCurrentRule() throws 
RuleDefinitionViolationException {
-        assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(new DropShardingTableRuleStatement(false, 
Collections.emptyList()), null));
-    }
-    
     @Test
     void assertCheckSQLStatementWithoutExistedTableRule() throws 
RuleDefinitionViolationException {
         assertThrows(MissingRequiredRuleException.class, () -> 
executor.checkBeforeUpdate(createSQLStatement("t_order"), new 
ShardingRuleConfiguration()));
-        
-    }
-    
-    @Test
-    void assertCheckSQLStatementIfExistsWithNullCurrentRuleConfiguration() 
throws RuleDefinitionViolationException {
-        DropShardingTableRuleStatement statement = new 
DropShardingTableRuleStatement(true, Collections.singleton(new 
TableNameSegment(0, 3, new IdentifierValue("t_order_if_exists"))));
-        executor.checkBeforeUpdate(statement, null);
     }
     
     @Test
diff --git 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleDefinitionExecuteEngine.java
 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleDefinitionExecuteEngine.java
index 6899c31026c..3508cf048d8 100644
--- 
a/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleDefinitionExecuteEngine.java
+++ 
b/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/type/rdl/rule/engine/database/DatabaseRuleDefinitionExecuteEngine.java
@@ -23,6 +23,7 @@ import 
org.apache.shardingsphere.distsql.handler.required.DistSQLExecutorCurrent
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDefinitionExecutor;
 import 
org.apache.shardingsphere.distsql.handler.type.rdl.rule.spi.database.DatabaseRuleDropExecutor;
 import 
org.apache.shardingsphere.distsql.statement.rdl.rule.RuleDefinitionStatement;
+import 
org.apache.shardingsphere.distsql.statement.rdl.rule.type.DropRuleStatement;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -62,13 +63,17 @@ public final class DatabaseRuleDefinitionExecuteEngine {
     
     @SuppressWarnings("unchecked")
     private void checkBeforeUpdate(final RuleConfiguration currentRuleConfig) {
-        DistSQLExecutorCurrentRuleRequired currentRuleRequired = 
executor.getClass().getAnnotation(DistSQLExecutorCurrentRuleRequired.class);
-        if (null != currentRuleRequired) {
-            ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> 
new MissingRequiredRuleException(currentRuleRequired.value(), 
database.getName()));
-        }
+        
Optional.ofNullable(executor.getClass().getAnnotation(DistSQLExecutorCurrentRuleRequired.class)).ifPresent(optional
 -> checkCurrentRule(currentRuleConfig, optional));
         executor.checkBeforeUpdate(sqlStatement, currentRuleConfig);
     }
     
+    private void checkCurrentRule(final RuleConfiguration currentRuleConfig, 
final DistSQLExecutorCurrentRuleRequired currentRuleRequired) {
+        if (sqlStatement instanceof DropRuleStatement && ((DropRuleStatement) 
sqlStatement).isIfExists()) {
+            return;
+        }
+        ShardingSpherePreconditions.checkNotNull(currentRuleConfig, () -> new 
MissingRequiredRuleException(currentRuleRequired.value(), database.getName()));
+    }
+    
     private Optional<RuleConfiguration> findCurrentRuleConfiguration(final 
ShardingSphereDatabase database, final Class<? extends RuleConfiguration> 
ruleConfigClass) {
         return 
database.getRuleMetaData().getConfigurations().stream().filter(each -> 
ruleConfigClass.isAssignableFrom(each.getClass())).findFirst();
     }
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportMetaDataExecutorTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportMetaDataExecutorTest.java
index c48786f307c..1772c3f1b80 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportMetaDataExecutorTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportMetaDataExecutorTest.java
@@ -79,21 +79,24 @@ class ImportMetaDataExecutorTest {
     @Test
     void assertCheckImportEmptyMetaData() {
         init(null);
+        ContextManager contextManager = mock(ContextManager.class, 
RETURNS_DEEP_STUBS);
         assertThrows(MissingRequiredDataSourcesException.class, () -> 
executor.executeUpdate(
-                new ImportMetaDataStatement(null, 
Objects.requireNonNull(ImportMetaDataExecutorTest.class.getResource(featureMap.get(EMPTY))).getPath()),
 mock(ContextManager.class)));
+                new ImportMetaDataStatement(null, 
Objects.requireNonNull(ImportMetaDataExecutorTest.class.getResource(featureMap.get(EMPTY))).getPath()),
 contextManager));
     }
     
     @Test
     void assertImportMetaDataFromJsonValue() {
         init(EMPTY);
-        assertThrows(NullPointerException.class, () -> 
executor.executeUpdate(new ImportMetaDataStatement(METADATA_VALUE, null), 
mock(ContextManager.class)));
+        ContextManager contextManager = mock(ContextManager.class, 
RETURNS_DEEP_STUBS);
+        assertThrows(NullPointerException.class, () -> 
executor.executeUpdate(new ImportMetaDataStatement(METADATA_VALUE, null), 
contextManager));
     }
     
     @Test
     void assertImportExistedMetaDataFromFile() {
         init(EMPTY);
+        ContextManager contextManager = mock(ContextManager.class, 
RETURNS_DEEP_STUBS);
         assertThrows(UnsupportedSQLOperationException.class, () -> 
executor.executeUpdate(
-                new ImportMetaDataStatement(null, 
Objects.requireNonNull(ImportMetaDataExecutorTest.class.getResource(featureMap.get(EMPTY))).getPath()),
 mock(ContextManager.class)));
+                new ImportMetaDataStatement(null, 
Objects.requireNonNull(ImportMetaDataExecutorTest.class.getResource(featureMap.get(EMPTY))).getPath()),
 contextManager));
     }
     
     private void init(final String feature) {

Reply via email to