MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
check_shared_row_lock.inc
1 #
2 # SUMMARY
3 # Check if statement reading table '$table' takes shared locks
4 # on some of its rows.
5 #
6 # PARAMETERS
7 # $table Table for which presence of row locks should be checked.
8 # $con_aux Name of auxiliary connection to be used by this script.
9 # $statement Statement to be checked.
10 # $wait_statement Sub-statement which is supposed to acquire locks (should
11 # be the same as $statement for ordinary statements).
12 #
13 # EXAMPLE
14 # innodb_mysql_lock2.test
15 #
16 --disable_result_log
17 --disable_query_log
18 
19 connection default;
20 begin;
21 --eval select * from $table for update;
22 
23 connection $con_aux;
24 begin;
25 --send_eval $statement;
26 
27 --enable_result_log
28 --enable_query_log
29 
30 connection default;
31 # Wait until statement is successfully blocked because
32 # all rows in table are X-locked. This means that at
33 # least it acquires S-locks on some of rows.
34 let $wait_condition=
35  select count(*) = 1 from information_schema.processlist
36  where state in ("Sending data","statistics", "preparing") and
37  info = "$wait_statement";
38 --source include/wait_condition.inc
39 
40 --disable_result_log
41 --disable_query_log
42 
43 rollback;
44 
45 connection $con_aux;
46 --reap
47 rollback;
48 
49 connection default;
50 --enable_result_log
51 --enable_query_log
52 
53 if ($success)
54 {
55 --echo Success: '$statement' takes shared row locks on '$table'.
56 }
57 
58 if (!$success)
59 {
60 --echo Error: '$statement' hasn't taken shared row locks on '$table'!
61 }