FlyingZC commented on code in PR #22029:
URL: https://github.com/apache/shardingsphere/pull/22029#discussion_r1019775675


##########
proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/ProxySQLExecutor.java:
##########
@@ -143,16 +134,40 @@ private boolean isPostgreSQLOrOpenGaussStatement(final 
SQLStatement sqlStatement
      * @throws SQLException SQL exception
      */
     public List<ExecuteResult> execute(final ExecutionContext 
executionContext) throws SQLException {
+        return needAutoTransaction(executionContext) ? 
doExecuteWithinTransaction(executionContext) : doExecute(executionContext);
+    }
+    
+    private boolean needAutoTransaction(final ExecutionContext 
executionContext) {
+        TransactionStatus transactionStatus = 
backendConnection.getConnectionSession().getTransactionStatus();
+        SQLStatement sqlStatement = 
executionContext.getSqlStatementContext().getSqlStatement();
+        return TransactionType.XA == transactionStatus.getTransactionType() && 
!transactionStatus.isInTransaction() && sqlStatement instanceof DMLStatement
+                && !(sqlStatement instanceof SelectStatement) && 
executionContext.getExecutionUnits().size() > 1;
+    }
+    
+    private List<ExecuteResult> doExecuteWithinTransaction(final 
ExecutionContext executionContext) throws SQLException {
+        List<ExecuteResult> result;
+        JDBCBackendTransactionManager transactionManager = new 
JDBCBackendTransactionManager(backendConnection);

Review Comment:
   The `JDBCBackendTransactionManager` just only holds the 
`ShardingSphereTransactionManagerEngine` object, which has been created in the 
rule in advance.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to