Debian Codegraph @

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

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