diff --git a/mysql-test/r/bug86260.result b/mysql-test/r/bug86260.result new file mode 100644 index 00000000000..1a16005df4d --- /dev/null +++ b/mysql-test/r/bug86260.result @@ -0,0 +1,18 @@ +# +# Bug 86260: Assert on KILL'ing a stored routine invocation +# +CREATE TABLE t1 (a INT); +CREATE FUNCTION f1() RETURNS INT +BEGIN +INSERT INTO t1 VALUES (1); +RETURN 1; +END| +SET DEBUG_SYNC= "sp_before_exec_core SIGNAL sp_ready WAIT_FOR sp_finish"; +SELECT f1(); +SET DEBUG_SYNC= "now WAIT_FOR sp_ready"; +KILL QUERY sp_con_id; +SET DEBUG_SYNC= "now SIGNAL sp_finish"; +ERROR 70100: Query execution was interrupted +SET DEBUG_SYNC= 'RESET'; +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/mysql-test/t/bug86260.test b/mysql-test/t/bug86260.test new file mode 100644 index 00000000000..715663cb38a --- /dev/null +++ b/mysql-test/t/bug86260.test @@ -0,0 +1,44 @@ +--source include/have_debug_sync.inc +--source include/count_sessions.inc + +--echo # +--echo # Bug 86260: Assert on KILL'ing a stored routine invocation +--echo # + +CREATE TABLE t1 (a INT); + +DELIMITER |; + +CREATE FUNCTION f1() RETURNS INT +BEGIN + INSERT INTO t1 VALUES (1); + RETURN 1; +END| + +DELIMITER ;| + +--connect(con1,localhost,root) + +--connection default +--let $sp_con_id= `SELECT CONNECTION_ID()` +SET DEBUG_SYNC= "sp_before_exec_core SIGNAL sp_ready WAIT_FOR sp_finish"; +send SELECT f1(); + +--connection con1 +SET DEBUG_SYNC= "now WAIT_FOR sp_ready"; +--replace_result $sp_con_id sp_con_id +--eval KILL QUERY $sp_con_id +SET DEBUG_SYNC= "now SIGNAL sp_finish"; + +--connection default +--error ER_QUERY_INTERRUPTED +reap; + +disconnect con1; + +SET DEBUG_SYNC= 'RESET'; + +DROP FUNCTION f1; +DROP TABLE t1; + +--source include/wait_until_count_sessions.inc diff --git a/sql/sp_instr.cc b/sql/sp_instr.cc index 2b2599c4d85..4ae6b12713d 100644 --- a/sql/sp_instr.cc +++ b/sql/sp_instr.cc @@ -21,6 +21,7 @@ #include "auth_acls.h" #include "auth_common.h" // check_table_access #include "binlog.h" // mysql_bin_log +#include "debug_sync.h" // DEBUG_SYNC #include "enum_query_type.h" #include "error_handler.h" // Strict_error_handler #include "field.h" @@ -435,6 +436,8 @@ bool sp_lex_instr::reset_lex_and_exec_core(THD *thd, } else { + DEBUG_SYNC(thd, "sp_before_exec_core"); + error= exec_core(thd, nextp); DBUG_PRINT("info",("exec_core returned: %d", error)); }