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

zhangliang 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 eff2920c4c4 Optimize handling of autocommit in transactions (#35437)
eff2920c4c4 is described below

commit eff2920c4c459ca561950dc769b9126ff4203790
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Fri May 16 18:20:25 2025 +0800

    Optimize handling of autocommit in transactions (#35437)
    
    - Remove MySQL-specific logic for setting autocommit
    - Implement generic solution for handling autocommit in nested transactions
    - Use dialect-specific transaction option to determine if autocommit is 
supported in nested transactions
---
 .../proxy/backend/handler/tcl/TCLBackendHandler.java        | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandler.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandler.java
index 5c3bf278f2a..e81cf47185e 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandler.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandler.java
@@ -33,7 +33,6 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.Rollbac
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.SavepointStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.SetAutoCommitStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.TCLStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.mysql.tcl.MySQLSetAutoCommitStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.opengauss.tcl.OpenGaussCommitStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.opengauss.tcl.OpenGaussRollbackStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.postgresql.tcl.PostgreSQLCommitStatement;
@@ -139,16 +138,10 @@ public final class TCLBackendHandler implements 
ProxyBackendHandler {
     }
     
     private void handleSetAutoCommit() throws SQLException {
-        if (tclStatement instanceof MySQLSetAutoCommitStatement) {
-            handleMySQLSetAutoCommit();
-        }
-        connectionSession.setAutoCommit(((SetAutoCommitStatement) 
tclStatement).isAutoCommit());
-    }
-    
-    private void handleMySQLSetAutoCommit() throws SQLException {
-        MySQLSetAutoCommitStatement statement = (MySQLSetAutoCommitStatement) 
tclStatement;
-        if (statement.isAutoCommit() && 
connectionSession.getTransactionStatus().isInTransaction()) {
+        if 
(dialectDatabaseMetaData.getTransactionOption().isSupportAutoCommitInNestedTransaction()
 && connectionSession.getTransactionStatus().isInTransaction()
+                && ((SetAutoCommitStatement) tclStatement).isAutoCommit()) {
             backendTransactionManager.commit();
         }
+        connectionSession.setAutoCommit(((SetAutoCommitStatement) 
tclStatement).isAutoCommit());
     }
 }

Reply via email to