diff --git a/mysql-test/r/kill_processlist-6619.result b/mysql-test/r/kill_processlist-6619.result index 588c8e6d139..8cb9fe7270c 100644 --- a/mysql-test/r/kill_processlist-6619.result +++ b/mysql-test/r/kill_processlist-6619.result @@ -3,10 +3,12 @@ SHOW PROCESSLIST; Id User Host db Command Time State Info Progress # root # test Sleep # # NULL 0.000 # root # test Query # # SHOW PROCESSLIST 0.000 +SET DEBUG_SYNC='before_execute_sql_command WAIT_FOR go'; +SHOW PROCESSLIST; connection default; KILL QUERY con_id; +SET DEBUG_SYNC='now SIGNAL go'; connection con1; -SHOW PROCESSLIST; ERROR 70100: Query execution was interrupted SHOW PROCESSLIST; Id User Host db Command Time State Info Progress diff --git a/mysql-test/r/kill_query-6728.result b/mysql-test/r/kill_query-6728.result new file mode 100644 index 00000000000..6638edebeea --- /dev/null +++ b/mysql-test/r/kill_query-6728.result @@ -0,0 +1,7 @@ +connect con1,localhost,root,,; +connection default; +kill query id; +connection con1; +select count(*) > 0 from mysql.user; +count(*) > 0 +1 diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 6d6fd2e43d6..880c424391e 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -1456,12 +1456,6 @@ GRANT PROCESS ON *.* TO test_u@localhost; SHOW ENGINE MYISAM MUTEX; SHOW ENGINE MYISAM STATUS; DROP USER test_u@localhost; -# -# Bug #48985: show create table crashes if previous access to the table -# was killed -# -SHOW CREATE TABLE non_existent; -ERROR 70100: Query execution was interrupted End of 5.1 tests # # Bug#52593 SHOW CREATE TABLE is blocked if table is locked diff --git a/mysql-test/t/kill_processlist-6619.test b/mysql-test/t/kill_processlist-6619.test index 2333f02eac6..472d2d57fb2 100644 --- a/mysql-test/t/kill_processlist-6619.test +++ b/mysql-test/t/kill_processlist-6619.test @@ -2,16 +2,21 @@ # MDEV-6619 SHOW PROCESSLIST returns empty result set after KILL QUERY # --source include/not_embedded.inc +--source include/have_debug_sync.inc + --enable_connect_log --connect (con1,localhost,root,,) --let $con_id = `SELECT CONNECTION_ID()` --replace_column 1 # 3 # 6 # 7 # SHOW PROCESSLIST; +SET DEBUG_SYNC='before_execute_sql_command WAIT_FOR go'; +send SHOW PROCESSLIST; --connection default --replace_result $con_id con_id eval KILL QUERY $con_id; +SET DEBUG_SYNC='now SIGNAL go'; --connection con1 --error ER_QUERY_INTERRUPTED -SHOW PROCESSLIST; +reap; --replace_column 1 # 3 # 6 # 7 # SHOW PROCESSLIST; diff --git a/mysql-test/t/kill_query-6728.test b/mysql-test/t/kill_query-6728.test new file mode 100644 index 00000000000..485256a65b6 --- /dev/null +++ b/mysql-test/t/kill_query-6728.test @@ -0,0 +1,14 @@ +# +# MDEV-6728 KILL QUERY executed on an idle connection can interrupt the next query +# +--enable_connect_log +--connect (con1,localhost,root,,) +let $id=`select connection_id()`; + +--connection default +--replace_result $id id +eval kill query $id; + +--connection con1 +select count(*) > 0 from mysql.user; + diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 14d50709921..c43193d1b57 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -1210,33 +1210,8 @@ disconnect conn1; connection default; DROP USER test_u@localhost; - ---echo # ---echo # Bug #48985: show create table crashes if previous access to the table ---echo # was killed ---echo # - -connect(con1,localhost,root,,); -CONNECTION con1; -LET $ID= `SELECT connection_id()`; - -CONNECTION default; ---disable_query_log -eval KILL QUERY $ID; ---enable_query_log - -CONNECTION con1; ---error ER_QUERY_INTERRUPTED -SHOW CREATE TABLE non_existent; - -DISCONNECT con1; ---source include/wait_until_disconnected.inc -CONNECTION default; - - --echo End of 5.1 tests - --echo # --echo # Bug#52593 SHOW CREATE TABLE is blocked if table is locked --echo # for write by another connection diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index dee6a7ee8f2..42a3dd193c4 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -374,6 +374,9 @@ CREATE VIEW v1 AS SELECT f1('a') FROM t1; --send SELECT * FROM v1 --connection default +let $wait_condition= + select count(*) = 2 from information_schema.processlist where state = "User sleep"; +--source include/wait_condition.inc --disable_query_log --eval KILL QUERY $ID_2 --eval KILL QUERY $ID_1 diff --git a/sql/sql_class.h b/sql/sql_class.h index 4ec16bff33d..5d64837a2c1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3229,6 +3229,14 @@ public: mysql_mutex_unlock(&LOCK_thd_data); } } + inline void reset_kill_query() + { + if (killed < KILL_CONNECTION) + { + reset_killed(); + mysys_var->abort= 0; + } + } inline void send_kill_message() const { int err= killed_errno(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3e200c6a000..88dc862df3e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1124,6 +1124,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->enable_slow_log= TRUE; thd->query_plan_flags= QPLAN_INIT; thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */ + thd->reset_kill_query(); DEBUG_SYNC(thd,"dispatch_command_before_set_time"); @@ -5111,11 +5112,7 @@ finish: if (! thd->get_stmt_da()->is_set()) thd->send_kill_message(); } - if (thd->killed < KILL_CONNECTION) - { - thd->reset_killed(); - thd->mysys_var->abort= 0; - } + thd->reset_kill_query(); } if (thd->is_error() || (thd->variables.option_bits & OPTION_MASTER_SQL_ERROR)) trans_rollback_stmt(thd);