diff --git a/mysql-test/r/xa.result b/mysql-test/r/xa.result index 92f52b402ec..a597806d897 100644 --- a/mysql-test/r/xa.result +++ b/mysql-test/r/xa.result @@ -81,3 +81,11 @@ xa rollback 'a'; xa start 'a'; xa end 'a'; xa rollback 'a'; +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test index a0d5aa60641..7b1c6a268d5 100644 --- a/mysql-test/t/xa.test +++ b/mysql-test/t/xa.test @@ -135,6 +135,20 @@ xa start 'a'; xa end 'a'; xa rollback 'a'; +# +# Bug#45548: XA transaction without access to InnoDB tables crashes the server +# + +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; + +xa start 'a'; +xa end 'a'; +xa prepare 'a'; +xa commit 'a'; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc diff --git a/sql/handler.cc b/sql/handler.cc index 7e584b8fcf3..e65ceba4181 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1242,9 +1242,10 @@ int ha_commit_one_phase(THD *thd, bool all) #endif thd->variables.tx_isolation=thd->session_tx_isolation; } - if (is_real_trans) - thd->transaction.cleanup(); } + /* Free resources and perform other cleanup even for 'empty' transactions. */ + if (is_real_trans) + thd->transaction.cleanup(); #endif /* USING_TRANSACTIONS */ DBUG_RETURN(error); }