1# ==== Purpose ====
2#
3# Kill a query in the master connection, and then try to reap the
4# result of the killed query.
5#
6# ==== Usage ====
7#
8# The following variables should be set before sourcing this file.
9#
10# $debug_lock: name of the debug user lock, if set, will release/lock
11#              the specified debug lock accordingly, and before
12#              sourcing this, connection 'master' should get the user
13#              lock and run a query in another thread, which will
14#              block before creating statement event.
15#
16# $connection_name: name of the connection that is waiting for the
17#                   lock, this can not be 'master'
18#
19# $connection_id: id of the connection that is waiting for the lock
20#
21# Example:
22# let $debug_lock=;
23# connection master1;
24# let $connection_name= master1;
25# let $connection_id= `SELECT CONNECTION_ID()`;
26# send CREATE TABLE t1;
27# source kill_query.inc;
28#
29# let $debug_lock= "debug_lock.before_query_log_event";
30# connection master;
31# eval SELECT GET_LOCK($debug_lock, 10);
32# connection master1;
33# let $connection_name= master1;
34# let $connection_id= `SELECT CONNECTION_ID()`;
35# send CREATE TABLE t1;
36# source kill_query.inc;
37
38
39--echo source include/kill_query.inc;
40disable_query_log;
41disable_result_log;
42connection master;
43
44# kill the query that is waiting
45eval kill query $connection_id;
46
47if ($debug_lock)
48{
49  # release the lock to allow binlog continue
50  eval SELECT RELEASE_LOCK($debug_lock);
51}
52
53# reap the result of the waiting query
54connection $connection_name;
55error 0, 1317, 1307, 1306, 1334, 1305, 1034;
56reap;
57
58connection master;
59
60if ($debug_lock)
61{
62  # get lock again to make the next query wait
63  eval SELECT GET_LOCK($debug_lock, 10);
64}
65
66connection $connection_name;
67enable_query_log;
68enable_result_log;
69