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

zhaojinchao 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 e9dcbc55d8a Fix sharding sql rewrite error (#29089)
e9dcbc55d8a is described below

commit e9dcbc55d8afff50838b729b6683c20278ba3328
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Mon Nov 20 14:04:45 2023 +0800

    Fix sharding sql rewrite error (#29089)
---
 .../rewrite/context/ShardingSQLRewriteContextDecorator.java | 13 -------------
 1 file changed, 13 deletions(-)

diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java
index 14ecbe37376..9872d5a4ea8 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecorator.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.sharding.rewrite.context;
 
 import lombok.Setter;
-import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
 import 
org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContextDecorator;
@@ -39,9 +38,6 @@ public final class ShardingSQLRewriteContextDecorator 
implements SQLRewriteConte
     
     @Override
     public void decorate(final ShardingRule shardingRule, final 
ConfigurationProperties props, final SQLRewriteContext sqlRewriteContext, final 
RouteContext routeContext) {
-        if (!containsShardingTable(shardingRule, 
sqlRewriteContext.getSqlStatementContext())) {
-            return;
-        }
         if (!sqlRewriteContext.getParameters().isEmpty()) {
             Collection<ParameterRewriter> parameterRewriters =
                     new ShardingParameterRewriterBuilder(shardingRule, 
routeContext, sqlRewriteContext.getDatabase().getSchemas(), 
sqlRewriteContext.getSqlStatementContext()).getParameterRewriters();
@@ -50,15 +46,6 @@ public final class ShardingSQLRewriteContextDecorator 
implements SQLRewriteConte
         sqlRewriteContext.addSQLTokenGenerators(new 
ShardingTokenGenerateBuilder(shardingRule, routeContext, 
sqlRewriteContext.getSqlStatementContext()).getSQLTokenGenerators());
     }
     
-    private boolean containsShardingTable(final ShardingRule shardingRule, 
final SQLStatementContext sqlStatementContext) {
-        for (String each : 
sqlStatementContext.getTablesContext().getTableNames()) {
-            if (shardingRule.findTableRule(each).isPresent()) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
     private void rewriteParameters(final SQLRewriteContext sqlRewriteContext, 
final Collection<ParameterRewriter> parameterRewriters) {
         for (ParameterRewriter each : parameterRewriters) {
             each.rewrite(sqlRewriteContext.getParameterBuilder(), 
sqlRewriteContext.getSqlStatementContext(), sqlRewriteContext.getParameters());

Reply via email to