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

duanzhengqiang 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 1874db06fb2 Fix the issue that cursor is not rewritten (#31192)
1874db06fb2 is described below

commit 1874db06fb20a4e31828ad9e7a28af264d88aca1
Author: ZhangCheng <[email protected]>
AuthorDate: Fri May 10 12:40:10 2024 +0800

    Fix the issue that cursor is not rewritten (#31192)
    
    * Fix the issue that cursor is not rewritten
    
    * Fix the issue that cursor is not rewritten
---
 .github/workflows/resources/filter/filters.yml                     | 1 +
 .../rewrite/context/ShardingSQLRewriteContextDecorator.java        | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/resources/filter/filters.yml 
b/.github/workflows/resources/filter/filters.yml
index bd1e45014be..4953976e0e4 100644
--- a/.github/workflows/resources/filter/filters.yml
+++ b/.github/workflows/resources/filter/filters.yml
@@ -60,3 +60,4 @@ transaction:
   - 'test/e2e/fixture/**'
   - 'test/e2e/env/**'
   - 'test/e2e/operation/transaction/**'
+  - 'features/sharding/**/src/main/**'
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 5e84a146a88..aab576a563d 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
@@ -22,6 +22,7 @@ import 
org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.ddl.AlterIndexStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.ddl.DropIndexStatementContext;
+import org.apache.shardingsphere.infra.binder.context.type.CursorAvailable;
 import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
@@ -46,7 +47,7 @@ public final class ShardingSQLRewriteContextDecorator 
implements SQLRewriteConte
     @Override
     public void decorate(final ShardingRule shardingRule, final 
ConfigurationProperties props, final SQLRewriteContext sqlRewriteContext, final 
RouteContext routeContext) {
         SQLStatementContext sqlStatementContext = 
sqlRewriteContext.getSqlStatementContext();
-        if (!isAlterOrDropIndexStatement(sqlStatementContext) && 
!containsShardingTable(shardingRule, sqlStatementContext)) {
+        if (!isAlterOrDropIndexStatement(sqlStatementContext) && 
!isCursorAvailableStatement(sqlStatementContext) && 
!containsShardingTable(shardingRule, sqlStatementContext)) {
             return;
         }
         if (!sqlRewriteContext.getParameters().isEmpty()) {
@@ -61,6 +62,10 @@ public final class ShardingSQLRewriteContextDecorator 
implements SQLRewriteConte
         return sqlStatementContext instanceof AlterIndexStatementContext || 
sqlStatementContext instanceof DropIndexStatementContext;
     }
     
+    private boolean isCursorAvailableStatement(final SQLStatementContext 
sqlStatementContext) {
+        return sqlStatementContext instanceof CursorAvailable;
+    }
+    
     private boolean containsShardingTable(final ShardingRule shardingRule, 
final SQLStatementContext sqlStatementContext) {
         Collection<SimpleTableSegment> tableSegments =
                 sqlStatementContext instanceof TableAvailable ? 
((TableAvailable) sqlStatementContext).getAllTables() : 
sqlStatementContext.getTablesContext().getSimpleTableSegments();

Reply via email to