1
by brian
clean slate |
1 |
--source include/have_community_features.inc |
2 |
||
3 |
# Verify that the protocol isn't violated if we ask for profiling info
|
|
4 |
# before profiling has recorded anything.
|
|
5 |
show profiles; |
|
6 |
show profile all; |
|
7 |
||
8 |
# default is OFF
|
|
9 |
show session variables like 'profil%'; |
|
10 |
select @@profiling; |
|
11 |
||
12 |
# setting global variable is an error
|
|
13 |
--error ER_LOCAL_VARIABLE |
|
14 |
set global profiling = ON; |
|
15 |
||
16 |
# But size is okay
|
|
17 |
set global profiling_history_size=100; |
|
18 |
show global variables like 'profil%'; |
|
19 |
||
20 |
# turn on for testing
|
|
21 |
set session profiling = ON; |
|
22 |
set session profiling_history_size=30; # small enough to overflow |
|
23 |
||
24 |
# verify it is active
|
|
25 |
show session variables like 'profil%'; |
|
26 |
select @@profiling; |
|
27 |
||
28 |
# Profiling is a descriptive look into the way the server operated
|
|
29 |
# in retrospect. Chad doesn't think it's wise to include the result
|
|
30 |
# log, as this creates a proscriptive specification about how the
|
|
31 |
# server should work in the future -- or it forces everyone who
|
|
32 |
# changes the server significantly to record the test results again,
|
|
33 |
# and that violates the spirit of our tests. Please don't include
|
|
34 |
# execution-specific data here, as in all of the "show profile" and
|
|
35 |
# information_schema.profiling results.
|
|
36 |
||
37 |
create table t1 ( |
|
38 |
a int, |
|
39 |
b int |
|
40 |
);
|
|
41 |
insert into t1 values (1,1), (2,null), (3, 4); |
|
42 |
insert into t1 values (5,1), (6,null), (7, 4); |
|
43 |
insert into t1 values (1,1), (2,null), (3, 4); |
|
44 |
insert into t1 values (5,1), (6,null), (7, 4); |
|
45 |
select max(x) from (select sum(a) as x from t1 group by b) as teeone; |
|
46 |
insert into t1 select * from t1; |
|
47 |
select count(*) from t1; |
|
48 |
insert into t1 select * from t1; |
|
49 |
insert into t1 select * from t1; |
|
50 |
insert into t1 select * from t1; |
|
51 |
select count(*) from t1; |
|
52 |
insert into t1 select * from t1; |
|
53 |
insert into t1 select * from t1; |
|
54 |
insert into t1 select * from t1; |
|
55 |
select count(*) from t1; |
|
56 |
select sum(a) from t1; |
|
57 |
select sum(a) from t1 group by b; |
|
58 |
select sum(a) + sum(b) from t1 group by b; |
|
59 |
select max(x) from (select sum(a) as x from t1 group by b) as teeone; |
|
60 |
select '012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890' as big_string; |
|
61 |
||
62 |
--enable_result_log |
|
63 |
--replace_column 2 # |
|
64 |
show profiles; |
|
65 |
||
66 |
--disable_result_log |
|
67 |
###--replace_column 2 # 3 # 4 #
|
|
68 |
show profile for query 15; |
|
69 |
###--replace_column 2 # 3 # 4 #
|
|
70 |
show profile cpu for query 15; |
|
71 |
###--replace_column 2 # 3 # 4 # 5 # 6 #
|
|
72 |
show profile cpu, block io for query 15; |
|
73 |
###--replace_column 2 # 3 # 4 #
|
|
74 |
show profile cpu for query 9 limit 2 offset 2; |
|
75 |
show profile cpu for query 10 limit 0; |
|
76 |
--error 0,ER_WRONG_ARGUMENTS |
|
77 |
show profile cpu for query 65534; |
|
78 |
###--replace_column 2 #
|
|
79 |
show profile memory; |
|
80 |
###--replace_column 2 # 3 # 4 #
|
|
81 |
show profile block io; |
|
82 |
###--replace_column 2 # 3 # 4 #
|
|
83 |
show profile context switches; |
|
84 |
###--replace_column 2 # 3 # 4 #
|
|
85 |
show profile page faults; |
|
86 |
###--replace_column 2 # 3 # 4 #
|
|
87 |
show profile ipc; |
|
88 |
###--replace_column 2 #
|
|
89 |
show profile swaps limit 1 offset 2; |
|
90 |
###--replace_column 2 # 5 #
|
|
91 |
show profile source; |
|
92 |
show profile all for query 0 limit 0; |
|
93 |
###--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 11 # 12 # 13 # 16 #
|
|
94 |
show profile all for query 15; |
|
95 |
###--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 11 # 12 # 13 # 16 #
|
|
96 |
||
97 |
select * from information_schema.profiling; |
|
98 |
select query_id, state, duration from information_schema.profiling; |
|
99 |
select query_id, sum(duration) from information_schema.profiling group by query_id; |
|
100 |
select query_id, count(*) from information_schema.profiling group by query_id; |
|
101 |
select sum(duration) from information_schema.profiling; |
|
102 |
||
103 |
# Broken down into number of stages and duration of each query.
|
|
104 |
select query_id, count(*), sum(duration) from information_schema.profiling group by query_id; |
|
105 |
select CPU_user, CPU_system, Context_voluntary, Context_involuntary, Block_ops_in, Block_ops_out, Messages_sent, Messages_received, Page_faults_major, Page_faults_minor, Swaps, Source_function, Source_file, Source_line from information_schema.profiling; |
|
106 |
||
107 |
||
108 |
--enable_result_log |
|
109 |
drop table if exists t1, t2, t3; |
|
110 |
create table t1 (id int ); |
|
111 |
create table t2 (id int not null); |
|
112 |
create table t3 (id int not null primary key); |
|
113 |
insert into t1 values (1), (2), (3); |
|
114 |
insert into t2 values (1), (2), (3); |
|
115 |
insert into t3 values (1), (2), (3); |
|
116 |
||
117 |
--replace_column 2 # |
|
118 |
show profiles; |
|
119 |
||
120 |
select * from t1; |
|
121 |
--replace_column 2 # |
|
122 |
show profiles; |
|
123 |
--echo This ^^ should end in "select * from t1;" |
|
124 |
||
125 |
delete from t1; |
|
126 |
insert into t1 values (1), (2), (3); |
|
127 |
insert into t1 values (1), (2), (3); |
|
128 |
||
129 |
select * from t1; |
|
130 |
--replace_column 2 # |
|
131 |
show profiles; |
|
132 |
||
133 |
# Turning profiling off does freeze it
|
|
134 |
set session profiling = OFF; |
|
135 |
select sum(id) from t1; |
|
136 |
--replace_column 2 # |
|
137 |
show profiles; |
|
138 |
||
139 |
## Verify that the various juggling of THD contexts doesn't affect profiling.
|
|
140 |
||
141 |
## Functions and procedures
|
|
142 |
set session profiling = ON; |
|
143 |
select @@profiling; |
|
144 |
create function f1() returns varchar(50) return 'hello'; |
|
145 |
select @@profiling; |
|
146 |
select * from t1 where id <> f1(); |
|
147 |
select @@profiling; |
|
148 |
||
149 |
set session profiling = OFF; |
|
150 |
drop table if exists profile_log; |
|
151 |
create table profile_log (how_many int); |
|
152 |
||
153 |
--disable_warnings |
|
154 |
drop procedure if exists p1; |
|
155 |
drop procedure if exists p2; |
|
156 |
drop procedure if exists p3; |
|
157 |
--enable_warnings |
|
158 |
||
159 |
delimiter //; |
|
160 |
create procedure p1 () |
|
161 |
modifies sql data |
|
162 |
begin
|
|
163 |
set profiling = ON; |
|
164 |
select 'This p1 should show up in profiling'; |
|
165 |
insert into profile_log select count(*) from information_schema.profiling; |
|
166 |
end// |
|
167 |
create procedure p2() |
|
168 |
deterministic
|
|
169 |
begin
|
|
170 |
set profiling = ON; |
|
171 |
call p1(); |
|
172 |
select 'This p2 should show up in profiling'; |
|
173 |
end// |
|
174 |
create procedure p3 () |
|
175 |
reads sql data |
|
176 |
begin
|
|
177 |
set profiling = ON; |
|
178 |
select 'This p3 should show up in profiling'; |
|
179 |
show profile; |
|
180 |
end// |
|
181 |
delimiter ;// |
|
182 |
||
183 |
--disable_result_log |
|
184 |
--echo first call to p1 |
|
185 |
call p1; |
|
186 |
select * from profile_log; |
|
187 |
--echo second call to p1 |
|
188 |
call p1; |
|
189 |
select * from profile_log; |
|
190 |
--echo third call to p1 |
|
191 |
call p1; |
|
192 |
select * from profile_log; |
|
193 |
set session profiling = OFF; |
|
194 |
call p2; |
|
195 |
set session profiling = OFF; |
|
196 |
call p3; |
|
197 |
||
198 |
--replace_column 1 # 2 # |
|
199 |
show profiles; |
|
200 |
--enable_result_log |
|
201 |
||
202 |
drop procedure if exists p1; |
|
203 |
drop procedure if exists p2; |
|
204 |
drop procedure if exists p3; |
|
205 |
drop table if exists profile_log; |
|
206 |
||
207 |
## Triggers
|
|
208 |
set session profiling = ON; |
|
209 |
drop table if exists t2; |
|
210 |
create table t2 (id int not null); |
|
211 |
create trigger t2_bi before insert on t2 for each row set @x=0; |
|
212 |
select @@profiling; |
|
213 |
insert into t2 values (1), (2), (3); |
|
214 |
select @@profiling; |
|
215 |
||
216 |
## ALTER TABLE
|
|
217 |
set session profiling = ON; |
|
218 |
drop table if exists t1, t2; |
|
219 |
create table t1 (id int not null primary key); |
|
220 |
create table t2 (id int not null primary key, id1 int not null); |
|
221 |
select @@profiling; |
|
222 |
alter table t2 add foreign key (id1) references t1 (id) on delete cascade; |
|
223 |
select @@profiling; |
|
224 |
||
225 |
## Table LOCKing
|
|
226 |
lock table t1 write; |
|
227 |
select @@profiling; |
|
228 |
unlock table; |
|
229 |
select @@profiling; |
|
230 |
||
231 |
## Transactions
|
|
232 |
set autocommit=0; |
|
233 |
select @@profiling, @@autocommit; |
|
234 |
begin; |
|
235 |
select @@profiling; |
|
236 |
insert into t1 values (1); |
|
237 |
insert into t2 values (1,1); |
|
238 |
--echo testing referential integrity cascade |
|
239 |
delete from t1 where id = 1; |
|
240 |
select @@profiling; |
|
241 |
--echo testing rollback |
|
242 |
--disable_warnings |
|
243 |
rollback; |
|
244 |
--enable_warnings |
|
245 |
select @@profiling; |
|
246 |
--echo testing commit |
|
247 |
begin; |
|
248 |
select @@profiling; |
|
249 |
commit; |
|
250 |
select @@profiling; |
|
251 |
||
252 |
drop table if exists t1, t2, t3; |
|
253 |
drop view if exists v1; |
|
254 |
drop function if exists f1; |
|
255 |
||
256 |
## Multiple queries in one packet. Combo statements don't work with ps-proto.
|
|
257 |
#--eval select 1; select 2; select 3;
|
|
258 |
## two continuations, one starting
|
|
259 |
#select state from information_schema.profiling where seq=1 order by query_id desc limit 3;
|
|
260 |
||
261 |
||
262 |
## last thing in the file
|
|
263 |
set session profiling = OFF; |
|
264 |
||
265 |
##
|
|
266 |
--echo End of 5.0 tests |