Skip to content

Commit

Permalink
Fixed bug in trans_check() where on error we gave wrong return value
Browse files Browse the repository at this point in the history
  • Loading branch information
montywi committed Jun 14, 2020
1 parent 56045ef commit 7f941c4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sql/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ void trans_reset_one_shot_chistics(THD *thd)
thd->tx_read_only= thd->variables.tx_read_only;
}

/* Conditions under which the transaction state must not change. */

/*
Conditions under which the transaction state must not change
@result TRUE Transaction can not commit
@result FALSE Transaction can commit
*/

static bool trans_check(THD *thd)
{
DBUG_ENTER("trans_check");
Expand All @@ -72,8 +79,11 @@ static bool trans_check(THD *thd)
DBUG_ASSERT(thd->transaction->stmt.is_empty());

if (unlikely(thd->in_sub_stmt))
{
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
if (!thd->transaction->xid_state.is_explicit_XA())
DBUG_RETURN(TRUE);
}
if (likely(!thd->transaction->xid_state.is_explicit_XA()))
DBUG_RETURN(FALSE);

thd->transaction->xid_state.er_xaer_rmfail();
Expand Down

0 comments on commit 7f941c4

Please sign in to comment.