mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / include / check_no_row_lock.inc
blobc08e7f35b1000073f67ee478a853bde7b7c4a704
2 # SUMMARY
3 #   Check if statement affecting or reading table '$table' doesn't
4 #   take any kind of locks on its rows.
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.
11 # EXAMPLE
12 #    innodb_mysql_lock2.test
14 --disable_result_log
15 --disable_query_log
17 connection default;
18 begin;
19 --eval select * from $table for update;
21 connection $con_aux;
22 begin;
23 --send_eval $statement;
25 --enable_result_log
26 --enable_query_log
28 connection default;
29 # Wait until statement is successfully executed while
30 # all rows in table are X-locked. This means that it
31 # does not acquire any row locks.
32 # We use wait_condition.inc instead of simply reaping 
33 # statement here in order to avoid deadlocks if test
34 # fails and to time out gracefully instead.
35 let $wait_condition=
36   select count(*) = 0 from information_schema.processlist
37   where info = "$statement";
38 --source include/wait_condition.inc
40 --disable_result_log
41 --disable_query_log
43 if ($success)
45 # Apparently statement was successfully executed and thus it
46 # has not required any row locks.
47 # To be safe against wait_condition.inc succeeding due to
48 # races let us first reap the statement being checked to
49 # ensure that it has been successfully executed.
50 connection $con_aux;
51 --reap
52 rollback;
53 connection default;
54 rollback;
55 --echo Success: '$statement' doesn't take row locks on '$table'.
57 if (!$success)
59 # Waiting has timed out. Apparently statement was blocked on
60 # some row lock. So to be able to continue we need to unlock
61 # rows first.
62 rollback;
63 connection $con_aux;
64 --reap
65 rollback;
66 connection default;
67 --echo Error: '$statement' takes some row locks on '$table'!
70 --enable_result_log
71 --enable_query_log