From 76fe59ea1372e324411db3d302a18ff7137b22eb Mon Sep 17 00:00:00 2001 From: jiangML <1060319118@qq.com> Date: Mon, 13 Nov 2023 17:48:29 +0800 Subject: [PATCH] Add check the storage unit is not empty when create broadcast table rule --- .../update/CreateBroadcastTableRuleStatementUpdater.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdater.java b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdater.java index 30eee07bc4cef..820d305d1c833 100644 --- a/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdater.java +++ b/features/broadcast/distsql/handler/src/main/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleStatementUpdater.java @@ -20,9 +20,10 @@ import org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration; import org.apache.shardingsphere.broadcast.distsql.statement.CreateBroadcastTableRuleStatement; import org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException; +import org.apache.shardingsphere.distsql.handler.exception.storageunit.EmptyStorageUnitException; import org.apache.shardingsphere.distsql.handler.update.RuleDefinitionCreateUpdater; -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.LinkedHashSet; @@ -34,6 +35,7 @@ public final class CreateBroadcastTableRuleStatementUpdater implements RuleDefin @Override public void checkSQLStatement(final ShardingSphereDatabase database, final CreateBroadcastTableRuleStatement sqlStatement, final BroadcastRuleConfiguration currentRuleConfig) { + ShardingSpherePreconditions.checkState(!database.getResourceMetaData().getStorageUnits().isEmpty(), () -> new EmptyStorageUnitException(database.getName())); if (!sqlStatement.isIfNotExists()) { checkDuplicate(sqlStatement, currentRuleConfig); }