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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
--source include/not_embedded.inc
--source include/have_perfschema.inc
--disable_warnings
drop table if exists test.setup_objects;
--enable_warnings
# Make sure only table io / table lock is instrumented and timed
update performance_schema.setup_instruments set enabled='NO';
update performance_schema.setup_instruments set enabled='YES', timed='YES'
where name in ('wait/io/table/sql/handler', 'wait/lock/table/sql/handler');
# Remove noise from previous tests
truncate table performance_schema.events_waits_history_long;
# Save the setup
create table test.setup_objects as select * from performance_schema.setup_objects;
truncate table performance_schema.setup_objects;
insert into performance_schema.setup_objects
values ('TABLE', 'db1', 't1', 'YES', 'YES');
insert into performance_schema.setup_objects
values ('TABLE', 'db1', 't2', 'YES', 'NO');
insert into performance_schema.setup_objects
values ('TABLE', 'db1', '%', 'YES', 'YES');
insert into performance_schema.setup_objects
values ('TABLE', 'db2', 't1', 'YES', 'YES');
insert into performance_schema.setup_objects
values ('TABLE', 'db2', 't2', 'YES', 'NO');
insert into performance_schema.setup_objects
values ('TABLE', 'db3', 't1', 'YES', 'YES');
insert into performance_schema.setup_objects
values ('TABLE', 'db3', 't2', 'NO', 'NO');
insert into performance_schema.setup_objects
values ('TABLE', 'db3', '%', 'NO', 'YES');
insert into performance_schema.setup_objects
values ('TABLE', 'db4', 't1', 'NO', 'YES');
insert into performance_schema.setup_objects
values ('TABLE', 'db4', '%', 'YES', 'NO');
# Also test insert of invalid enum values
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
--error ER_NO_REFERENCED_ROW_2
insert into performance_schema.setup_objects
values ('SOMETHING', 'bad1', 'bad1', 'YES', 'NO');
show warnings;
--error ER_NO_REFERENCED_ROW_2
insert into performance_schema.setup_objects
values ('TABLE', 'bad2', 'bad2', 'MAYBE', 'NO');
show warnings;
--error ER_NO_REFERENCED_ROW_2
insert into performance_schema.setup_objects
values ('TABLE', 'bad3', 'bad3', 'YES', 'MAYBE NOT');
show warnings;
select * from performance_schema.setup_objects
order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
# Also test update of invalid enum values
# Note: do not use SHOW WARNINGS in the test,
# because error messages such as:
# "Data truncated for column 'OBJECT_TYPE' at row <N>"
# do not always use the same row number <N>.
# ER_WRONG_PERFSCHEMA_USAGE because of privileges, expected.
--error ER_WRONG_PERFSCHEMA_USAGE
update performance_schema.setup_objects
set OBJECT_TYPE='SOMETHING' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
--error ER_NO_REFERENCED_ROW_2
update performance_schema.setup_objects
set ENABLED='MAYBE' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
--error ER_NO_REFERENCED_ROW_2
update performance_schema.setup_objects
set TIMED='MAYBE NOT' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
select * from performance_schema.setup_objects
order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
SET sql_mode = default;
--disable_warnings
drop database if exists db1;
drop database if exists db2;
drop database if exists db3;
drop database if exists db4;
drop database if exists db5;
--enable_warnings
create database db1;
create database db2;
create database db3;
create database db4;
create database db5;
create table db1.t1(a int);
create table db1.t2(a int);
create table db1.t3(a int);
create table db1.t4(a int);
create table db1.t5(a int);
create table db2.t1(a int);
create table db2.t2(a int);
create table db2.t3(a int);
create table db2.t4(a int);
create table db2.t5(a int);
create table db3.t1(a int);
create table db3.t2(a int);
create table db3.t3(a int);
create table db3.t4(a int);
create table db3.t5(a int);
create table db4.t1(a int);
create table db4.t2(a int);
create table db4.t3(a int);
create table db4.t4(a int);
create table db4.t5(a int);
create table db5.t1(a int);
select * from db1.t1;
select * from db1.t2;
select * from db1.t3;
select * from db1.t4;
select * from db1.t5;
select * from db2.t1;
select * from db2.t2;
select * from db2.t3;
select * from db2.t4;
select * from db2.t5;
select * from db3.t1;
select * from db3.t2;
select * from db3.t3;
select * from db3.t4;
select * from db3.t5;
select * from db4.t1;
select * from db4.t2;
select * from db4.t3;
select * from db4.t4;
select * from db4.t5;
select * from db5.t1;
create table db5.t2(a int);
select * from db3.t2;
# Verify what is instrumented
select distinct OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
from performance_schema.events_waits_history_long
where OBJECT_SCHEMA like "db%"
group by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
order by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA;
# Verify what is instrumented and timed
select distinct OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
from performance_schema.events_waits_history_long
where OBJECT_SCHEMA like "db%" and TIMER_END is not NULL
group by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
order by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA;
update performance_schema.setup_objects
set timed='YES' where OBJECT_SCHEMA = '%';
create table db5.t3(a int);
select * from db3.t3;
truncate table performance_schema.setup_objects;
select count(*) from performance_schema.setup_objects;
drop database db1;
drop database db2;
drop database db3;
drop database db4;
drop database db5;
# Restore the setup
truncate table performance_schema.setup_objects;
insert into performance_schema.setup_objects select * from test.setup_objects;
drop table test.setup_objects;
update performance_schema.setup_instruments set enabled='YES', timed='YES';
|