Debian Codegraph @

mysql-test/suite/perfschema/t/ortho_iter.test

raw
1 # Tests for PERFORMANCE_SCHEMA
2 # Verify the orthogonality of iterators (table*::rnd_next()),
3 # for every table and instruments.
4
5 --source include/not_embedded.inc
6 --source include/no_valgrind_without_big.inc
7 --source include/have_perfschema.inc
8
9 --disable_warnings
10 drop procedure if exists check_instrument;
11 --enable_warnings
12
13 # reset counters
14 truncate table performance_schema.events_statements_summary_by_digest;
15 flush global status;
16
17 # Print known global memory instruments (PSI_FLAG_GLOBAL),
18 # see maintenance of count_global_expected below.
19
20 # --echo "Known PSI_FLAG_GLOBAL memory instruments"
21 # select name from performance_schema.setup_instruments
22 # where (name like "memory/%")
23 # and (name not like "memory/performance_schema/%")
24 # and (name not in
25 # (select event_name from
26 # performance_schema.memory_summary_by_account_by_event_name));
27
28 --enable_prepare_warnings
29
30 delimiter $;
31 create procedure check_instrument(in instr_name varchar(128))
32 begin
33 declare save_count_expected integer;
34 declare count_expected integer;
35 declare count_builtin_expected integer;
36 declare count_global_expected integer;
37 declare is_wait integer;
38 declare is_wait_file integer;
39 declare is_wait_socket integer;
40 declare is_stage integer;
41 declare is_statement integer;
42 declare is_transaction integer;
43 declare is_memory integer;
44 declare is_wait_table integer;
45 declare is_wait_file_table integer;
46 declare is_wait_socket_table integer;
47 declare is_stage_table integer;
48 declare is_statement_table integer;
49 declare is_transaction_table integer;
50 declare is_memory_table integer;
51 declare is_memory_global_table integer;
52 declare pfs_table_name varchar(64);
53 declare msg varchar(512);
54 declare msg_detail varchar(512);
55 declare cmd_1 varchar(512);
56 declare cmd_2 varchar(512);
57 declare done integer default 0;
58 declare dbg integer default 0;
59
60 declare pfs_cursor CURSOR FOR
61 select table_name from information_schema.tables
62 where table_schema= 'performance_schema'
63 and table_name like "%_by_event_name%"
64 order by table_name;
65
66 declare continue handler for sqlstate '02000'
67 set done = 1;
68
69 select (instr_name like "wait/%") or (instr_name like "idle") into is_wait;
70 select (instr_name like "wait/io/file/%") into is_wait_file;
71 select (instr_name like "wait/io/socket/%") into is_wait_socket;
72 select (instr_name like "stage/%") into is_stage;
73 select (instr_name like "statement/%") into is_statement;
74 select (instr_name like "memory/%") into is_memory;
75 select (instr_name like "transaction") into is_transaction;
76
77 select instr_name, is_wait, is_wait_file, is_wait_socket, is_stage, is_statement, is_memory, is_transaction;
78
79 select count(name)
80 from performance_schema.setup_instruments
81 where (name like (concat(instr_name, "%")))
82 and (not name like "%/abstract/%")
83 and (not name like "memory/performance_schema/%")
84 into save_count_expected;
85
86 select count(name)
87 from performance_schema.setup_instruments
88 where (name like (concat(instr_name, "%")))
89 and (name like "memory/performance_schema/%")
90 into count_builtin_expected;
91
92 select count(name)
93 from performance_schema.setup_instruments
94 where (name like (concat(instr_name, "%")))
95 and (name in (
96 "memory/sql/buffered_logs",
97 "memory/sql/sql_acl_mem",
98 "memory/sql/sql_acl_memex",
99 "memory/sql/acl_cache",
100 "memory/sql/TABLE_SHARE::mem_root",
101 "memory/sql/TABLE",
102 "memory/sql/Query_cache",
103 "memory/sql/native_functions",
104 "memory/sql/Event_basic::mem_root",
105 "memory/sql/root",
106 "memory/sql/load_env_plugins",
107 "memory/sql/plugin_ref",
108 "memory/sql/plugin_mem_root",
109 "memory/sql/plugin_bookmark",
110 "memory/csv/TINA_SHARE",
111 "memory/sql/tz_storage",
112 "memory/sql/servers_cache",
113 "memory/sql/udf_mem"
114 ))
115 into count_global_expected;
116
117 set cmd_1= "select count(*) from (select distinct event_name from performance_schema.";
118 set cmd_2= concat(" where event_name like \"",
119 instr_name,
120 "%\") t into @count_actual");
121
122 open pfs_cursor;
123 repeat
124 fetch pfs_cursor into pfs_table_name;
125 if not done then
126 select (pfs_table_name like "%waits%") into is_wait_table;
127 select (pfs_table_name like "file_summary%") into is_wait_file_table;
128 select (pfs_table_name like "socket_summary%") into is_wait_socket_table;
129 select (pfs_table_name like "%stages%") into is_stage_table;
130 select (pfs_table_name like "%statements%") into is_statement_table;
131 select (pfs_table_name like "%memory%") into is_memory_table;
132 select (pfs_table_name like "memory_summary_global_by_event_name") into is_memory_global_table;
133 select (pfs_table_name like "%transaction%") into is_transaction_table;
134
135 set count_expected = save_count_expected;
136
137 if is_memory_global_table
138 then
139 set count_expected = save_count_expected + count_builtin_expected;
140 end if;
141
142 if is_memory_table = 1 and is_memory_global_table = 0
143 then
144 set count_expected = save_count_expected - count_global_expected;
145 end if;
146
147 select concat("Checking table ", pfs_table_name, " ...") as status;
148 select concat(cmd_1, pfs_table_name, cmd_2) into @cmd;
149 if dbg = 1
150 then
151 select @cmd;
152 end if;
153 prepare stmt from @cmd;
154 execute stmt;
155 drop prepare stmt;
156 set msg_detail= concat("table ", pfs_table_name,
157 ", instruments ", count_expected,
158 ", found ", @count_actual);
159
160 if is_wait = 1
161 then
162 if is_wait_table = 1 and @count_actual <> count_expected
163 then
164 set msg= concat("Missing wait events: ", msg_detail);
165 signal sqlstate '05000' set message_text= msg;
166 end if;
167
168 if is_wait_table = 0
169 and is_wait_file_table = 0
170 and is_wait_socket_table = 0
171 and @count_actual <> 0
172 then
173 set msg= concat("Unexpected wait events: ", msg_detail);
174 signal sqlstate '05000' set message_text= msg;
175 end if;
176 end if;
177
178 if is_wait_file = 1
179 then
180 if is_wait_file_table = 1 and @count_actual <> count_expected
181 then
182 set msg= concat("Missing wait/io/file events: ", msg_detail);
183 signal sqlstate '05000' set message_text= msg;
184 end if;
185
186 if is_wait_table = 0 and is_wait_file_table = 0 and @count_actual <> 0
187 then
188 set msg= concat("Unexpected wait/io/file events: ", msg_detail);
189 signal sqlstate '05000' set message_text= msg;
190 end if;
191 end if;
192
193 if is_wait_socket = 1
194 then
195 if is_wait_socket_table = 1 and @count_actual <> count_expected
196 then
197 set msg= concat("Missing wait/io/socket events: ", msg_detail);
198 signal sqlstate '05000' set message_text= msg;
199 end if;
200
201 if is_wait_table = 0 and is_wait_socket_table = 0 and @count_actual <> 0
202 then
203 set msg= concat("Unexpected wait/io/socket events: ", msg_detail);
204 signal sqlstate '05000' set message_text= msg;
205 end if;
206 end if;
207
208 if is_stage = 1
209 then
210 if is_stage_table = 1 and @count_actual <> count_expected
211 then
212 set msg= concat("Missing stage events: ", msg_detail);
213 signal sqlstate '05000' set message_text= msg;
214 end if;
215
216 if is_stage_table = 0 and @count_actual <> 0
217 then
218 set msg= concat("Unexpected stage events: ", msg_detail);
219 signal sqlstate '05000' set message_text= msg;
220 end if;
221 end if;
222
223 if is_statement = 1
224 then
225 if is_statement_table = 1 and @count_actual <> count_expected
226 then
227 set msg= concat("Missing statement events: ", msg_detail);
228 signal sqlstate '05000' set message_text= msg;
229 end if;
230
231 if is_statement_table = 0 and @count_actual <> 0
232 then
233 set msg= concat("Unexpected statement events: ", msg_detail);
234 signal sqlstate '05000' set message_text= msg;
235 end if;
236 end if;
237
238 if is_memory = 1
239 then
240 if is_memory_table = 1 and @count_actual <> count_expected
241 then
242 set msg= concat("Missing memory events: ", msg_detail);
243 signal sqlstate '05000' set message_text= msg;
244 end if;
245
246 if is_memory_table = 0 and @count_actual <> 0
247 then
248 set msg= concat("Unexpected memory events: ", msg_detail);
249 signal sqlstate '05000' set message_text= msg;
250 end if;
251 end if;
252
253 if is_transaction = 1
254 then
255 if is_transaction_table = 1 and @count_actual <> count_expected
256 then
257 set msg= concat("Missing transaction events: ", msg_detail);
258 signal sqlstate '05000' set message_text= msg;
259 end if;
260
261 if is_transaction_table = 0 and @count_actual <> 0
262 then
263 set msg= concat("Unexpected transaction events: ", msg_detail);
264 signal sqlstate '05000' set message_text= msg;
265 end if;
266 end if;
267
268 end if;
269 until done
270 end repeat;
271 close pfs_cursor;
272
273 -- Dont want to return a 02000 NOT FOUND, there should be a better way
274 signal sqlstate '01000' set message_text='Done', mysql_errno=12000;
275 end
276 $
277 delimiter ;$
278
279 --disable_prepare_warnings
280
281 # Check the configuration is ok
282 show global variables like "performance_schema%";
283
284 call check_instrument("wait/synch/mutex/");
285 call check_instrument("wait/synch/rwlock/");
286 call check_instrument("wait/synch/sxlock/");
287 call check_instrument("wait/synch/cond/");
288 call check_instrument("wait/synch/");
289 call check_instrument("wait/io/file/");
290 call check_instrument("wait/io/socket/");
291 call check_instrument("wait/io/table/");
292 call check_instrument("wait/io/");
293 call check_instrument("wait/lock/table/");
294 call check_instrument("wait/lock/");
295 call check_instrument("wait/");
296 call check_instrument("stage/");
297 call check_instrument("statement/com/");
298 call check_instrument("statement/sql/");
299 call check_instrument("statement/abstract/");
300 call check_instrument("statement/");
301 call check_instrument("idle");
302 call check_instrument("memory/");
303 call check_instrument("memory/performance_schema/");
304 call check_instrument("transaction");
305
306 drop procedure check_instrument;
307