summaryrefslogtreecommitdiff
path: root/sql/set_var.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@sun.com>2010-03-10 15:04:32 +0400
committerSergey Vojtovich <svoj@sun.com>2010-03-10 15:04:32 +0400
commit405fd822075488597484ef5ce82a8d3296262130 (patch)
treef5d8084d539e0d15f67adc081d76d21e3effc94c /sql/set_var.cc
parent05ff7b65f072d69a67515b8c0c6731f358a846ca (diff)
downloadmariadb-git-405fd822075488597484ef5ce82a8d3296262130.tar.gz
BUG#51342 - more xid crashing
SET autocommit=1 while XA transaction is active may cause various side effects, including memory corruption and server crash. The problem is that SET autocommit=1 and further queries attempt to commit local transaction, whereas XA transaction is still active. As local and XA transactions are mutually exclusive, this patch forbids enabling autocommit mode while XA transaction is active. mysql-test/r/xa.result: A test case for BUG#51342. mysql-test/t/xa.test: A test case for BUG#51342. sql/set_var.cc: Forbid enabling autocommit mode while XA transaction is active.
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r--sql/set_var.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 4871afd2c56..8e032d44a62 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -3065,6 +3065,13 @@ static bool set_option_autocommit(THD *thd, set_var *var)
if ((org_options & OPTION_NOT_AUTOCOMMIT))
{
/* We changed to auto_commit mode */
+ if (thd->transaction.xid_state.xa_state != XA_NOTR)
+ {
+ thd->options= org_options;
+ my_error(ER_XAER_RMFAIL, MYF(0),
+ xa_state_names[thd->transaction.xid_state.xa_state]);
+ return 1;
+ }
thd->options&= ~OPTION_BEGIN;
thd->transaction.all.modified_non_trans_table= FALSE;
thd->server_status|= SERVER_STATUS_AUTOCOMMIT;