Skip to content

Commit

Permalink
Merge pull request #60338 from PapaToemmsn/test-transaction-fixes
Browse files Browse the repository at this point in the history
fix for #57598 (ROLLBACK should be no-op...)
  • Loading branch information
tavplubix committed Mar 19, 2024
2 parents 7348760 + fbc8a19 commit dd50091
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Interpreters/InterpreterTransactionControlQuery.cpp
Expand Up @@ -52,7 +52,12 @@ BlockIO InterpreterTransactionControlQuery::executeCommit(ContextMutablePtr sess
{
auto txn = session_context->getCurrentTransaction();
if (!txn)
throw Exception(ErrorCodes::INVALID_TRANSACTION, "There is no current transaction");
{
if (session_context->getClientInfo().interface == ClientInfo::Interface::MYSQL)
return {};
else
throw Exception(ErrorCodes::INVALID_TRANSACTION, "There is no current transaction");
}
if (txn->getState() != MergeTreeTransaction::RUNNING)
throw Exception(ErrorCodes::INVALID_TRANSACTION, "Transaction is not in RUNNING state");

Expand Down Expand Up @@ -111,7 +116,12 @@ BlockIO InterpreterTransactionControlQuery::executeRollback(ContextMutablePtr se
{
auto txn = session_context->getCurrentTransaction();
if (!txn)
throw Exception(ErrorCodes::INVALID_TRANSACTION, "There is no current transaction");
{
if (session_context->getClientInfo().interface == ClientInfo::Interface::MYSQL)
return {};
else
throw Exception(ErrorCodes::INVALID_TRANSACTION, "There is no current transaction");
}
if (txn->getState() == MergeTreeTransaction::COMMITTED)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Transaction is in COMMITTED state");
if (txn->getState() == MergeTreeTransaction::COMMITTING)
Expand Down
@@ -0,0 +1,2 @@
1
1
10 changes: 10 additions & 0 deletions tests/queries/0_stateless/02989_mysql_transaction_test.sh
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Tags: no-fasttest
# Tag no-fasttest: requires mysql client

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh

${MYSQL_CLIENT} --verbose --execute "COMMIT;" | grep -c "COMMIT"
${MYSQL_CLIENT} --verbose --execute "ROLLBACK;" | grep -c "ROLLBACK"

0 comments on commit dd50091

Please sign in to comment.