1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# Test creating a barrier with a number
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connect (con3,localhost,root,,);
connect (con4,localhost,root,,);
connect (con5,localhost,root,,);
# The default connection will own everything.
connection default;
set @count_barrier= "count_barrier";
set @barrier_limit= 6;
SELECT create_barrier(@count_barrier, @barrier_limit);
SELECT if ((SESSION_ID = CONNECTION_ID()), "YES", "NO"), GENERATION, if ((WAITER_LIMIT = @barrier_limit), "YES", "NO") from DATA_DICTIONARY.USER_DEFINED_BARRIERS WHERE USER_BARRIER_NAME=@count_barrier ORDER BY USER_BARRIER_NAME;
connection con1;
set @count_barrier= "count_barrier";
send SELECT wait(@count_barrier), "con1";
connection con2;
set @count_barrier= "count_barrier";
send SELECT wait(@count_barrier), "con2";
connection con3;
set @count_barrier= "count_barrier";
send SELECT wait(@count_barrier), "con3";
connection con4;
set @count_barrier= "count_barrier";
send SELECT wait(@count_barrier), "con4";
# We don't budge until we know everyone is in place.
connection con5;
set @count_barrier= "count_barrier";
SELECT WAIT_UNTIL(@count_barrier, 4);
SELECT USERNAME, INFO FROM DATA_DICTIONARY.PROCESSLIST ORDER BY ID;
SELECT signal(@count_barrier);
|