MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
kill_query.inc
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;
40 disable_query_log;
41 disable_result_log;
42 connection master;
43 
44 # kill the query that is waiting
45 eval kill query $connection_id;
46 
47 if ($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
54 connection $connection_name;
55 error 0, 1317, 1307, 1306, 1334, 1305, 1034;
56 reap;
57 
58 connection master;
59 
60 if ($debug_lock)
61 {
62  # get lock again to make the next query wait
63  eval SELECT GET_LOCK($debug_lock, 10);
64 }
65 
66 connection $connection_name;
67 enable_query_log;
68 enable_result_log;