summaryrefslogtreecommitdiff
path: root/mysql-test/suite/perfschema/t/stage_mdl_procedure.test
blob: 7d9dc6d80eb01742f8ede1a0670f39355459a80b (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Tests for the performance schema
#

--source ../include/stage_setup.inc

connect (con1, localhost, user1, , );

--disable_warnings
drop function if exists test.f1;
drop procedure if exists test.p1;
--enable_warnings

delimiter $$;

create function test.f1() returns int
begin
  call test.p1();
  return 1;
end
$$

delimiter ;$$

create procedure test.p1()
begin end;

begin;
# The procedure is in a sub statement,
# so that the current transaction keeps a reference to it.
select test.f1();

connect (con2, localhost, user2, , );

# Will wait on con1, "Waiting for stored procedure metadata lock"
--send
drop procedure test.p1;

--connection default

# user1: Wait for the statement to complete
let $wait_condition=
  select count(*) = 1 from performance_schema.threads
  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
  and PROCESSLIST_COMMAND = 'Sleep';
--source include/wait_condition.inc

# user2: Wait for the drop procedure to block
let $wait_condition=
  select count(*) = 1 from performance_schema.threads
  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
  and PROCESSLIST_STATE = 'Waiting for stored procedure metadata lock';
--source include/wait_condition.inc

call dump_one_thread('user1');
call dump_one_thread('user2');

--connection con1
select test.f1();
commit;

--disconnect con1

--connection con2
--reap

--disconnect con2

--connection default

# Wait for the disconnect to complete
let $wait_condition=
  select count(*) = 0 from performance_schema.threads
  where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
--source include/wait_condition.inc

drop function test.f1;

--source ../include/stage_cleanup.inc