1 # This test doesn't work with the embedded version as this code
2 # assumes that one query is running while we are doing queries on
4 # This would work if mysqltest run would be threaded and handle each
5 # connection in a separate thread.
7 -- source include/not_embedded.inc
9 # Disable concurrent inserts to avoid test failures when reading the
10 # connection id which was inserted into a table by another thread.
11 set @old_concurrent_insert= @@global.concurrent_insert;
12 set @@global.concurrent_insert= 0;
14 connect (con1, localhost, root,,);
15 connect (con2, localhost, root,,);
20 drop table if exists t1, t2, t3;
24 create table t1 (kill_id int);
25 insert into t1 values(connection_id());
29 select ((@id := kill_id) - kill_id) from t1;
37 # One of the following statements should fail
46 # this should work, and we should have a new connection_id()
47 select ((@id := kill_id) - kill_id) from t1;
48 select @id != connection_id();
50 #make sure the server is still alive
56 --error ER_NOT_SUPPORTED_YET
57 kill (select count(*) from mysql.user);
60 # BUG#14851: killing long running subquery processed via a temporary table.
62 create table t1 (id int primary key);
63 create table t2 (id int unsigned not null);
65 connect (conn1, localhost, root,,);
73 eval insert into t1 values ($1);
79 insert into t2 select id from t1;
81 create table t3 (kill_id int);
82 insert into t3 values(connection_id());
84 connect (conn2, localhost, root,,);
89 # This is a very long running query. If this test start failing, it may
90 # be necessary to change to an even longer query.
91 send select id from t1 where id in (select distinct a.id from t2 a, t2 b, t2 c, t2 d group by a.id, b.id, c.id, d.id having a.id between 10 and 20);
95 select ((@id := kill_id) - kill_id) from t3;
105 drop table t1, t2, t3;
110 # test of blocking of sending ERROR after OK or EOF
113 select get_lock("a", 10);
115 let $ID= `select connection_id()`;
116 send select get_lock("a", 10);
126 select RELEASE_LOCK("a");
129 # Bug#27563: Stored functions and triggers wasn't throwing an error when killed.
131 create table t1(f1 int);
133 create function bug27563() returns int(11)
136 declare continue handler for sqlstate '70100' set @a:= 'killed';
137 declare continue handler for sqlexception set @a:= 'exception';
138 set @a= get_lock("lock27563", 10);
142 # Test stored functions
145 select get_lock("lock27563",10);
147 let $ID= `select connection_id()`;
148 send insert into t1 values (bug27563());
162 insert into t1 values(0);
164 send update t1 set f1= bug27563();
178 insert into t1 values(1);
180 send delete from t1 where bug27563() is null;
195 send select * from t1 where f1= bug27563();
209 create procedure proc27563()
211 declare continue handler for sqlstate '70100' set @a:= 'killed';
212 declare continue handler for sqlexception set @a:= 'exception';
213 select get_lock("lock27563",10);
214 select "shouldn't be selected";
217 send call proc27563();
230 create table t2 (f2 int);
232 create trigger trg27563 before insert on t1 for each row
234 declare continue handler for sqlstate '70100' set @a:= 'killed';
235 declare continue handler for sqlexception set @a:= 'exception';
236 set @a:= get_lock("lock27563",10);
237 insert into t2 values(1);
240 send insert into t1 values(2),(3);
255 select release_lock("lock27563");
257 drop function bug27563;
258 drop procedure proc27563;
261 # Bug#28598: mysqld crash when killing a long-running explain query.
265 let $ID= `select connection_id()`;
271 eval CREATE TABLE t$i (a$i int, KEY(a$i));
272 eval INSERT INTO t$i VALUES (1),(2),(3),(4),(5),(6),(7);
275 set session optimizer_search_depth=0;
286 let $from=$comma$t$from;
287 let $where=a$i=$a $and $where;
291 let $from=FROM $t$from;
292 let $where=WHERE $where;
298 eval PREPARE stmt FROM 'EXPLAIN SELECT * $from $where';
313 ###########################################################################
316 --echo # Bug#19723: kill of active connection yields different error code
317 --echo # depending on platform.
321 --echo # Connection: con2.
324 KILL CONNECTION_ID();
326 --echo # CR_SERVER_LOST, CR_SERVER_GONE_ERROR, depending on the timing
327 --echo # of close of the connection socket
332 ###########################################################################
334 # Restore global concurrent_insert value. Keep in the end of the test file.
335 set @@global.concurrent_insert= @old_concurrent_insert;