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 2021/10/22 15:11:16 UTC
[GitHub] [shardingsphere] zhfeng edited a comment on pull request #13187: support XA transaction for proxy #12771
zhfeng edited a comment on pull request #13187:
URL: https://github.com/apache/shardingsphere/pull/13187#issuecomment-949700678
Refer to the javadoc about ```Connection::setAutoCommit(boolean)``` https://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setAutoCommit(boolean)
```
NOTE: If this method is called during a transaction and the auto-commit mode is changed, the transaction is committed. If setAutoCommit is called and the auto-commit mode is not changed, the call is a no-op.
Throws:
SQLException - if a database access error occurs, setAutoCommit(true) is called while participating in a distributed transaction, or this method is called on a closed connection.
```
Then I propose the following changes with ```TransactionBackendHandlerFactory```
```
if (tclStatement instanceof SetAutoCommitStatement) {
if (backendConnection.getTransactionStatus(). isInXA()) {
throw new SQLException("can not setAutoCommit in a distributed transaction");
}
if (((SetAutoCommitStatement) tclStatement).isAutoCommit()) {
return backendConnection.getTransactionStatus().isInTransaction()
? new TransactionBackendHandler(tclStatement, TransactionOperationType.COMMIT, backendConnection) : new SkipBackendHandler(tclStatement);
}
return new SkipBackendHandler(tclStatement);
}
if (tclStatement instanceof XAStatement) {
// if it is xa_start backendConnection.getTransactionStatus().setInXA(true);
// if it is xa_commit or xa_rollback backendConnection.getTransactionStatus().setInXA(false);
}
```
any thought ?
--
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