diff --git a/mysql-test/r/create_or_replace.result b/mysql-test/r/create_or_replace.result index a2f06c38cb5..ff8170b7309 100644 --- a/mysql-test/r/create_or_replace.result +++ b/mysql-test/r/create_or_replace.result @@ -436,7 +436,9 @@ CREATE OR REPLACE TEMPORARY TABLE tmp LIKE t1; LOCK TABLE t1 WRITE; CREATE OR REPLACE TABLE t1 LIKE tmp; KILL QUERY con_id; +ERROR 70100: Query execution was interrupted CREATE OR REPLACE TABLE t1 (a int); KILL QUERY con_id; +ERROR 70100: Query execution was interrupted drop table t1; DROP TABLE t2; diff --git a/mysql-test/t/create_or_replace.test b/mysql-test/t/create_or_replace.test index 2bdd23c21f6..9e37950dbef 100644 --- a/mysql-test/t/create_or_replace.test +++ b/mysql-test/t/create_or_replace.test @@ -346,20 +346,26 @@ LOCK TABLE t1 WRITE; --let $con_id = `SELECT CONNECTION_ID()` --send CREATE OR REPLACE TABLE t1 LIKE tmp --connection default +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist + WHERE state= 'Waiting for table metadata lock'; +--source include/wait_condition.inc --replace_result $con_id con_id --eval KILL QUERY $con_id --connection con1 ---error 0,ER_QUERY_INTERRUPTED +--error ER_QUERY_INTERRUPTED --reap --send CREATE OR REPLACE TABLE t1 (a int) --connection default +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist + WHERE state= 'Waiting for table metadata lock'; +--source include/wait_condition.inc --replace_result $con_id con_id --eval KILL QUERY $con_id --connection con1 ---error 0,ER_QUERY_INTERRUPTED +--error ER_QUERY_INTERRUPTED --reap --disconnect con1 --connection default diff --git a/sql/item_func.cc b/sql/item_func.cc index 098845d372e..de05ee358a2 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4179,9 +4179,10 @@ void mysql_ull_set_explicit_lock_duration(THD *thd) When MDL detects a lock wait timeout, it pushes an error into the statement diagnostics area. For GET_LOCK(), lock wait timeout is not an error, - but a special return value (0). NULL is returned in - case of error. - Capture and suppress lock wait timeout. + but a special return value (0). + Similarly, killing get_lock wait is not an error either, + but a return value NULL. + Capture and suppress lock wait timeouts and kills. */ class Lock_wait_timeout_handler: public Internal_error_handler @@ -4200,7 +4201,7 @@ public: bool Lock_wait_timeout_handler:: -handle_condition(THD * /* thd */, uint sql_errno, +handle_condition(THD *thd, uint sql_errno, const char * /* sqlstate */, Sql_condition::enum_warning_level /* level */, const char *message, @@ -4211,6 +4212,9 @@ handle_condition(THD * /* thd */, uint sql_errno, m_lock_wait_timeout= true; return true; /* condition handled */ } + if (thd->is_killed()) + return true; + return false; } diff --git a/sql/mdl.cc b/sql/mdl.cc index 2c2d64e96b2..b94a3710fd1 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -2413,6 +2413,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout) my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); break; case MDL_wait::KILLED: + get_thd()->send_kill_message(); break; default: DBUG_ASSERT(0);