You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/05/26 04:11:32 UTC
[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #10465: checked binding table rule
menghaoranss commented on a change in pull request #10465:
URL: https://github.com/apache/shardingsphere/pull/10465#discussion_r639387119
##########
File path: shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropShardingTableRuleBackendHandler.java
##########
@@ -49,24 +49,23 @@ public DropShardingTableRuleBackendHandler(final DropShardingTableRuleStatement
@Override
public ResponseHeader execute(final String schemaName, final DropShardingTableRuleStatement sqlStatement) {
Collection<String> tableNames = sqlStatement.getTableNames().stream().map(each -> each.getIdentifier().getValue()).collect(Collectors.toList());
- ShardingRuleConfiguration shardingRuleConfiguration = check(schemaName, tableNames);
- drop(shardingRuleConfiguration, tableNames);
+ Optional<ShardingRuleConfiguration> shardingRuleConfiguration = getShardingRuleConfiguration(schemaName);
+ check(schemaName, shardingRuleConfiguration, tableNames);
+ drop(shardingRuleConfiguration.get(), tableNames);
post(schemaName);
return new UpdateResponseHeader(sqlStatement);
}
- private ShardingRuleConfiguration check(final String schemaName, final Collection<String> tableNames) {
- Optional<ShardingRuleConfiguration> shardingRuleConfiguration = getShardingRuleConfiguration(schemaName);
+ private void check(final String schemaName, final Optional<ShardingRuleConfiguration> shardingRuleConfiguration, final Collection<String> tableNames) {
if (!shardingRuleConfiguration.isPresent()) {
throw new ShardingTableRuleNotExistedException(schemaName, tableNames);
}
Collection<String> shardingTableNames = getShardingTables(shardingRuleConfiguration.get());
- Collection<String> notExistedTableNames = tableNames.stream().filter(each -> !shardingTableNames.contains(each)).collect(Collectors.toList());
- if (!notExistedTableNames.isEmpty()) {
- throw new ShardingTableRuleNotExistedException(schemaName, notExistedTableNames);
+ Collection<String> bindingTables = getBindingTables(shardingRuleConfiguration.get());
+ Collection<String> notSatisfiedTableNames = tableNames.stream().filter(each -> !shardingTableNames.contains(each) || bindingTables.contains(each)).collect(Collectors.toList());
Review comment:
2. Check whether the dropped table rules exist in the binding table rule
3. throw ShardingTableRulesInUsedException if exist
please check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org