3 #   Check if statement reading table '$table' allows concurrent 
    7 #   $table         Table in which concurrent inserts should be allowed. 
    8 #   $con_aux1      Name of the first auxiliary connection to be used by this 
   10 #   $con_aux2      Name of the second auxiliary connection to be used by this 
   12 #   $statement     Statement to be checked. 
   13 #   $restore_table Table which might be modified by statement to be checked 
   14 #                  and thus needs backing up before its execution and 
   15 #                  restoring after it (can be empty). 
   23 # Reset DEBUG_SYNC facility for safety. 
   24 set debug_sync= 
"RESET";
 
   28 --eval create temporary 
table t_backup select * from $restore_table;
 
   32 set debug_sync=
'after_lock_tables_takes_lock SIGNAL parked WAIT_FOR go';
 
   33 --send_eval $statement;
 
   36 set debug_sync=
'now WAIT_FOR parked';
 
   37 --send_eval insert into $table (
i) values (0);
 
   42 # Wait until concurrent insert is successfully executed while 
   43 # statement being checked has its tables locked. 
   44 # We use wait_condition.inc instead of simply reaping  
   45 # concurrent insert here in order to avoid deadlocks if test 
   46 # fails and to time out gracefully instead. 
   48   select count(*) = 0 from information_schema.processlist
 
   49   where info = 
"insert into $table (i) values (0)";
 
   50 --source include/wait_condition.inc
 
   57 # Apparently concurrent insert was successfully executed. 
   58 # To be safe against wait_condition.inc succeeding due to 
   59 # races let us first reap concurrent insert to ensure that 
   60 # it has really been successfully executed. 
   64 set debug_sync= 
'now SIGNAL go';
 
   68 --echo Success: 
'$statement' allows concurrent inserts into 
'$table'.
 
   72 # Waiting has timed out. Apparently concurrent insert was blocked. 
   73 # So to be able to continue we need to end our statement first. 
   74 set debug_sync= 
'now SIGNAL go';
 
   80 --echo Error: 
'$statement' doesn
't allow concurrent inserts into '$table
'! 
   83 --eval delete from $table where i = 0; 
   87 --eval truncate table $restore_table; 
   88 --eval insert into $restore_table select * from t_backup; 
   89 drop temporary table t_backup; 
   92 # Clean-up. Reset DEBUG_SYNC facility after use. 
   93 set debug_sync= "RESET";