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