Skip to content

Commit 7f941c4

Browse files
committed
Fixed bug in trans_check() where on error we gave wrong return value
1 parent 56045ef commit 7f941c4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

sql/transaction.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ void trans_reset_one_shot_chistics(THD *thd)
6060
thd->tx_read_only= thd->variables.tx_read_only;
6161
}
6262

63-
/* Conditions under which the transaction state must not change. */
63+
64+
/*
65+
Conditions under which the transaction state must not change
66+
67+
@result TRUE Transaction can not commit
68+
@result FALSE Transaction can commit
69+
*/
70+
6471
static bool trans_check(THD *thd)
6572
{
6673
DBUG_ENTER("trans_check");
@@ -72,8 +79,11 @@ static bool trans_check(THD *thd)
7279
DBUG_ASSERT(thd->transaction->stmt.is_empty());
7380

7481
if (unlikely(thd->in_sub_stmt))
82+
{
7583
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
76-
if (!thd->transaction->xid_state.is_explicit_XA())
84+
DBUG_RETURN(TRUE);
85+
}
86+
if (likely(!thd->transaction->xid_state.is_explicit_XA()))
7787
DBUG_RETURN(FALSE);
7888

7989
thd->transaction->xid_state.er_xaer_rmfail();

0 commit comments

Comments
 (0)