summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/perfschema/t/trigger_table_io.test
blob: 2b374c79d1523e7c250e9e8e007445ad87e389c8 (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
# Tests for PERFORMANCE_SCHEMA table io

--source include/not_embedded.inc
--source include/have_perfschema.inc
--source ../include/table_io_setup_helper.inc

let $engine_type= MyISAM;

--disable_warnings
drop table if exists test.t1;
drop table if exists test.t2;
--enable_warnings

eval create table test.t1 (a int, v int) engine = $engine_type;
eval create table test.t2 (b int, v int) engine = $engine_type;

create trigger t1_bi before insert on t1
for each row insert into test.t2 set b = new.a, v = 0;

create trigger t1_ai after insert on t1
for each row update test.t2 set v = 1 where b = new.a;

create trigger t1_bu before update on t1
for each row update test.t2 set v = 3 where b = old.a;

create trigger t1_au after update on t1
for each row update test.t2 set v = 4 where b = new.a;

create trigger t1_bd before delete on t1
for each row delete from test.t2 where b = old.a;

create trigger t1_ad after delete on t1
for each row insert into test.t2 set b = old.a, v = 99;

# Start recording events
update performance_schema.setup_consumers set enabled = 'YES';

# Code to test

--disable_ps2_protocol
insert into marker set a = 1;
insert into t1 set a = 1, v = 10;
insert into marker set a = 1;
insert into t1 set a = 2, v = 20;
insert into marker set a = 1;
select * from t1;
insert into marker set a = 1;
select * from t2;
insert into marker set a = 1;
update t1 set v = v + 100;
insert into marker set a = 1;
select * from t1;
insert into marker set a = 1;
select * from t2;
insert into marker set a = 1;
delete from t1 where a = 1;
insert into marker set a = 1;
select * from t1;
insert into marker set a = 1;
select * from t2;
insert into marker set a = 1;
delete from t1 where a = 2;
insert into marker set a = 1;
select * from t1;
insert into marker set a = 1;
select * from t2;
--enable_ps2_protocol

# Stop recording events + pull results
--source ../include/table_io_result_helper.inc

# Cleanup
drop table test.t1;
drop table test.t2;
--source ../include/table_io_cleanup_helper.inc