| 1 |
# Tests for PERFORMANCE_SCHEMA |
| 2 |
|
| 3 |
--source include/have_myisam.inc |
| 4 |
--source include/force_myisam_default.inc |
| 5 |
--source include/have_debug.inc |
| 6 |
--source include/have_debug_sync.inc |
| 7 |
|
| 8 |
# Setup |
| 9 |
|
| 10 |
connect (con1, localhost, root, , ); |
| 11 |
|
| 12 |
let $con1_THREAD_ID=`select thread_id from performance_schema.threads |
| 13 |
where PROCESSLIST_ID = connection_id()`; |
| 14 |
|
| 15 |
--disable_warnings |
| 16 |
drop table if exists t1; |
| 17 |
--enable_warnings |
| 18 |
|
| 19 |
create table t1(a int) engine = myisam; |
| 20 |
|
| 21 |
insert into t1 values (1), (2), (3), (4), (5); |
| 22 |
# Dummy alter to make sure the DD cache is populated |
| 23 |
alter table t1 force; |
| 24 |
|
| 25 |
--connection default |
| 26 |
|
| 27 |
update performance_schema.threads |
| 28 |
set instrumented = 'NO' |
| 29 |
where processlist_id = connection_id(); |
| 30 |
|
| 31 |
truncate table performance_schema.events_statements_history_long; |
| 32 |
truncate table performance_schema.events_stages_history_long; |
| 33 |
|
| 34 |
--disable_query_log |
| 35 |
eval select $con1_THREAD_ID into @con1_thread_id; |
| 36 |
--enable_query_log |
| 37 |
|
| 38 |
--connection con1 |
| 39 |
|
| 40 |
# ALTER TABLE statement to inspect, |
| 41 |
# execution should instrument progress |
| 42 |
|
| 43 |
SET DEBUG_SYNC='RESET'; |
| 44 |
SET DEBUG_SYNC='copy_data_between_tables_before SIGNAL found_row WAIT_FOR wait_row EXECUTE 5'; |
| 45 |
--send ALTER TABLE t1 engine = innodb; |
| 46 |
|
| 47 |
--connection default |
| 48 |
|
| 49 |
SET DEBUG_SYNC='now WAIT_FOR found_row'; |
| 50 |
|
| 51 |
# Find the statement id of the ALTER TABLE |
| 52 |
select event_id from performance_schema.events_statements_current |
| 53 |
where thread_id = @con1_thread_id into @con1_stmt_id; |
| 54 |
|
| 55 |
# completed 0 |
| 56 |
select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED |
| 57 |
from performance_schema.events_stages_current |
| 58 |
where (thread_id = @con1_thread_id); |
| 59 |
|
| 60 |
SET DEBUG_SYNC='now SIGNAL wait_row'; |
| 61 |
|
| 62 |
#====== |
| 63 |
|
| 64 |
SET DEBUG_SYNC='now WAIT_FOR found_row'; |
| 65 |
|
| 66 |
# completed 1 |
| 67 |
select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED |
| 68 |
from performance_schema.events_stages_current |
| 69 |
where (thread_id = @con1_thread_id); |
| 70 |
|
| 71 |
SET DEBUG_SYNC='now SIGNAL wait_row'; |
| 72 |
|
| 73 |
#====== |
| 74 |
|
| 75 |
SET DEBUG_SYNC='now WAIT_FOR found_row'; |
| 76 |
|
| 77 |
# completed 2 |
| 78 |
select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED |
| 79 |
from performance_schema.events_stages_current |
| 80 |
where (thread_id = @con1_thread_id); |
| 81 |
|
| 82 |
SET DEBUG_SYNC='now SIGNAL wait_row'; |
| 83 |
|
| 84 |
#====== |
| 85 |
|
| 86 |
SET DEBUG_SYNC='now WAIT_FOR found_row'; |
| 87 |
|
| 88 |
# completed 3 |
| 89 |
select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED |
| 90 |
from performance_schema.events_stages_current |
| 91 |
where (thread_id = @con1_thread_id); |
| 92 |
|
| 93 |
SET DEBUG_SYNC='now SIGNAL wait_row'; |
| 94 |
|
| 95 |
#====== |
| 96 |
|
| 97 |
SET DEBUG_SYNC='now WAIT_FOR found_row'; |
| 98 |
|
| 99 |
# completed 4 |
| 100 |
select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED |
| 101 |
from performance_schema.events_stages_current |
| 102 |
where (thread_id = @con1_thread_id); |
| 103 |
|
| 104 |
SET DEBUG_SYNC='now SIGNAL wait_row'; |
| 105 |
|
| 106 |
#====== |
| 107 |
|
| 108 |
--connection con1 |
| 109 |
|
| 110 |
# Complete the ALTER TABLE statement. |
| 111 |
--reap |
| 112 |
|
| 113 |
# Make sure the ALTER TABLE cleanup is executed, |
| 114 |
# as the last stages are after writing back to the client, |
| 115 |
# and done asynchronously from the last 'reap'. |
| 116 |
select "After payload"; |
| 117 |
|
| 118 |
--connection default |
| 119 |
|
| 120 |
--echo Dumping ALTER TABLE stages |
| 121 |
|
| 122 |
# Print all stages for this ALTER TABLE statement |
| 123 |
select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED |
| 124 |
from performance_schema.events_stages_history_long |
| 125 |
where (thread_id = @con1_thread_id) |
| 126 |
and (nesting_event_id = @con1_stmt_id) |
| 127 |
order by thread_id, event_id; |
| 128 |
|
| 129 |
SET DEBUG_SYNC='RESET'; |
| 130 |
|
| 131 |
--connection con1 |
| 132 |
|
| 133 |
drop table t1; |
| 134 |
|
| 135 |
--disconnect con1 |
| 136 |
|
| 137 |
--connection default |
| 138 |
|
| 139 |
update performance_schema.threads |
| 140 |
set instrumented = 'YES' |
| 141 |
where processlist_id = connection_id(); |
| 142 |
|