1source include/master-slave.inc;
2
3CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
4
5create table t1(n int);
6# Use of get_lock gives a warning for unsafeness if binlog_format=statement
7--disable_warnings
8insert into t1 values(get_lock("lock",2));
9--enable_warnings
10dirty_close master;
11connection master1;
12select get_lock("lock",2);
13
14select release_lock("lock");
15#ignore
16disable_query_log;
17let $1=2000;
18while ($1)
19{
20  do get_lock("lock",2);
21  do release_lock("lock");
22  dec $1;
23}
24enable_query_log;
25sync_slave_with_master;
26select get_lock("lock",3);
27select * from t1;
28# There is no point in testing REPLICATIION of the IS_*_LOCK
29# functions; slave does not run with the same concurrency context as
30# master (generally in slave we can't know that on master this lock
31# was already held by another connection and so that the the
32# get_lock() we're replicating timed out on master hence returned 0,
33# or that the is_free_lock() we're playing returned 0 etc.
34# But here all we do is test these functions outside of replication.
35select is_free_lock("lock"), is_used_lock("lock") = connection_id();
36explain extended select is_free_lock("lock"), is_used_lock("lock");
37# Check lock functions
38select is_free_lock("lock2");
39select is_free_lock(NULL);
40connection master1;
41drop table t1;
42sync_slave_with_master;
43
44
45--source include/rpl_end.inc
46
47# End of 4.1 tests
48