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 19connection default; 20begin; 21--eval select * from $table for update; 22 23connection $con_aux; 24begin; 25--send_eval $statement; 26 27--enable_result_log 28--enable_query_log 29 30connection 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. 34let $wait_condition= 35 select count(*) = 1 from information_schema.processlist 36 where state in ("Sending data","statistics", "preparing", "updating", 37 "executing", "Searching rows for update") and 38 info = "$wait_statement"; 39--source include/wait_condition.inc 40 41--disable_result_log 42--disable_query_log 43 44rollback; 45 46connection $con_aux; 47--reap 48rollback; 49 50connection default; 51--enable_result_log 52--enable_query_log 53 54if ($success) 55{ 56--echo Success: '$statement' takes shared row locks on '$table'. 57} 58 59if (!$success) 60{ 61--echo Error: '$statement' hasn't taken shared row locks on '$table'! 62} 63