3 # Check that a statement is compatible with FLUSH TABLES WITH READ LOCK.
6 # $con_aux1 Name of the 1st aux connection to be used by this script.
7 # $con_aux2 Name of the 2nd aux connection to be used by this script.
8 # $statement The statement to be checked.
9 # $cleanup_stmt The statement to be run in order to revert effects of
10 # the statement to be checked.
11 # $skip_3rd_chk Skip the 3rd stage of checking. The purpose of the third
12 # stage is to check that metadata locks taken by this
13 # statement are compatible with metadata locks taken
17 # flush_read_lock.test
22 # Reset DEBUG_SYNC facility for safety.
23 set debug_sync=
"RESET";
26 # First, check that the statement can be run under FTWRL.
28 flush tables with read lock;
29 --disable_abort_on_error
31 --enable_abort_on_error
32 let $err= $mysql_errno;
35 --echo Success: Was able
to run '$statement' under FTWRL.
44 --echo Error: Wasn
't able to run '$statement
' under FTWRL!
49 # Then check that this statement won't be blocked by FTWRL
50 # that is active in another connection.
53 flush tables with read lock;
56 --send_eval $statement;
63 select count(*) = 0 from information_schema.processlist
64 where info =
"$statement";
65 --source include/wait_condition.inc
71 --echo Success: Was able
to run '$statement' with FTWRL active in another connection.
74 # Apparently statement was successfully executed and so
75 # was not blocked by FTWRL.
76 # To be safe against wait_condition.inc succeeding due to
77 # races let us first reap the statement being checked to
78 # ensure that it has been successfully executed.
88 --echo Error: Wasn
't able to run '$statement
' with FTWRL active in another connection!
102 # Finally, let us check that FTWRL will succeed if this statement
103 # is active but has already closed its tables.
106 set debug_sync='execute_command_after_close_tables SIGNAL parked WAIT_FOR go
';
107 --send_eval $statement;
109 connection $con_aux1;
110 set debug_sync="now WAIT_FOR parked";
111 --send flush tables with read lock
113 connection $con_aux2;
117 select count(*) = 0 from information_schema.processlist
118 where info = "flush tables with read lock";
119 --source include/wait_condition.inc
125 --echo Success: Was able to run FTWRL while '$statement
' was active in another connection.
126 connection $con_aux1;
127 # Apparently FTWRL was successfully executed and so was not blocked by
128 # the statement being checked. To be safe against wait_condition.inc
129 # succeeding due to races let us first reap the FTWRL to ensure that it
130 # has been successfully executed.
133 set debug_sync="now SIGNAL go";
139 --echo Error: Wasn't able
to run FTWRL
while '$statement' was active in another connection!
140 set debug_sync=
"now SIGNAL go";
143 connection $con_aux1;
149 set debug_sync=
"RESET";
152 --eval $cleanup_stmt;