diff options
author | Sergey Vojtovich <svoj@sun.com> | 2010-03-10 16:26:39 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@sun.com> | 2010-03-10 16:26:39 +0400 |
commit | 680cc263ec23264c4a659dfd3c8c9a541670ffa4 (patch) | |
tree | 5f4671ae771c04d2e81f96f1379732be95dcb817 | |
parent | e48779e92911bcc9f68777ce35e7bd981e7f3c27 (diff) | |
parent | 992f6754ac9a4af9b2ceb1f3fe81df44283e369b (diff) | |
download | mariadb-git-680cc263ec23264c4a659dfd3c8c9a541670ffa4.tar.gz |
Merge fix for BUG51342 to 5.1-bugteam.
-rw-r--r-- | mysql-test/r/xa.result | 17 | ||||
-rw-r--r-- | mysql-test/t/xa.test | 16 | ||||
-rw-r--r-- | sql/set_var.cc | 7 |
3 files changed, 40 insertions, 0 deletions
diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result index d23c8e672b0..7cbd951242e 100644 --- a/mysql-test/r/xa.result +++ b/mysql-test/r/xa.result @@ -74,6 +74,23 @@ ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was det xa rollback 'a','c'; xa start 'a','c'; drop table t1; +# +# BUG#51342 - more xid crashing +# +CREATE TABLE t1(a INT) ENGINE=InnoDB; +XA START 'x'; +SET SESSION autocommit=0; +INSERT INTO t1 VALUES(1); +SET SESSION autocommit=1; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state +SELECT @@autocommit; +@@autocommit +0 +INSERT INTO t1 VALUES(1); +XA END 'x'; +XA COMMIT 'x' ONE PHASE; +DROP TABLE t1; +SET SESSION autocommit=DEFAULT; End of 5.0 tests xa start 'a'; xa end 'a'; diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test index f84d822170f..9eeb3017881 100644 --- a/mysql-test/t/xa.test +++ b/mysql-test/t/xa.test @@ -122,6 +122,22 @@ xa start 'a','c'; --connection default drop table t1; +--echo # +--echo # BUG#51342 - more xid crashing +--echo # +CREATE TABLE t1(a INT) ENGINE=InnoDB; +XA START 'x'; +SET SESSION autocommit=0; +INSERT INTO t1 VALUES(1); +--error ER_XAER_RMFAIL +SET SESSION autocommit=1; +SELECT @@autocommit; +INSERT INTO t1 VALUES(1); +XA END 'x'; +XA COMMIT 'x' ONE PHASE; +DROP TABLE t1; +SET SESSION autocommit=DEFAULT; + --echo End of 5.0 tests # diff --git a/sql/set_var.cc b/sql/set_var.cc index 2c00d76b0f1..0a9541b9f2c 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -3078,6 +3078,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&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG); thd->transaction.all.modified_non_trans_table= FALSE; thd->server_status|= SERVER_STATUS_AUTOCOMMIT; |