Skip to content

Commit

Permalink
MDEV-6601 Assertion `!thd->in_active_multi_stmt_transa ction() || thd…
Browse files Browse the repository at this point in the history
…->in_multi_stmt_transaction_mode()' failed on executing a stored procedure with commit

Don't restore the whole of thd->server_status after a routine invocation,
only restore SERVER_STATUS_CURSOR_EXISTS and SERVER_STATUS_LAST_ROW_SENT,
as --ps --embedded needs.
In particular, don't restore SERVER_STATUS_IN_TRANS.
  • Loading branch information
Sergei Golubchik committed Aug 25, 2014
1 parent 5569132 commit dd25e7f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions mysql-test/r/sp-bugs.result
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,9 @@ END $$
CALL test_5531(1);
DROP PROCEDURE test_5531;
DROP TABLE t1;
create procedure sp() begin
commit;
end|
start transaction;
call sp();
drop procedure sp;
13 changes: 13 additions & 0 deletions mysql-test/t/sp-bugs.test
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,16 @@ DELIMITER ;$$
CALL test_5531(1);
DROP PROCEDURE test_5531;
DROP TABLE t1;

#
# MDEV-6601 Assertion `!thd->in_active_multi_stmt_transa ction() || thd->in_multi_stmt_transaction_mode()' failed on executing a stored procedure with commit
#
delimiter |;
create procedure sp() begin
commit;
end|
delimiter ;|
start transaction;
call sp();
drop procedure sp;

6 changes: 4 additions & 2 deletions sql/sp_head.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,8 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
Item_change_list old_change_list;
String old_packet;
uint old_server_status;
const uint status_backup_mask= SERVER_STATUS_CURSOR_EXISTS |
SERVER_STATUS_LAST_ROW_SENT;
Reprepare_observer *save_reprepare_observer= thd->m_reprepare_observer;
Object_creation_ctx *saved_creation_ctx;
Warning_info *saved_warning_info;
Expand Down Expand Up @@ -1358,7 +1360,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
It is probably safe to use same thd->convert_buff everywhere.
*/
old_packet.swap(thd->packet);
old_server_status= thd->server_status;
old_server_status= thd->server_status & status_backup_mask;

/*
Switch to per-instruction arena here. We can do it since we cleanup
Expand Down Expand Up @@ -1488,7 +1490,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
thd->spcont->pop_all_cursors(); // To avoid memory leaks after an error

/* Restore all saved */
thd->server_status= old_server_status;
thd->server_status= (thd->server_status & ~status_backup_mask) | old_server_status;
old_packet.swap(thd->packet);
DBUG_ASSERT(thd->change_list.is_empty());
old_change_list.move_elements_to(&thd->change_list);
Expand Down

0 comments on commit dd25e7f

Please sign in to comment.