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 2022/11/11 02:23:45 UTC

[GitHub] [shardingsphere] FlyingZC commented on a diff in pull request #22029: Automatically start a xa transaction if needed(#20234)

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


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

Review Comment:
   Yes, BASE transaction also supports this feature.



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org