1
--source include/have_community_features.inc
3
# Verify that the protocol isn't violated if we ask for profiling info
4
# before profiling has recorded anything.
9
show session variables like 'profil%';
12
# setting global variable is an error
13
--error ER_LOCAL_VARIABLE
14
set global profiling = ON;
17
set global profiling_history_size=100;
18
show global variables like 'profil%';
21
set session profiling = ON;
22
set session profiling_history_size=30; # small enough to overflow
25
show session variables like 'profil%';
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.
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;
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 #
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 #
88
###--replace_column 2 #
89
show profile swaps limit 1 offset 2;
90
###--replace_column 2 # 5 #
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 #
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;
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;
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);
123
--echo This ^^ should end in "select * from t1;"
126
insert into t1 values (1), (2), (3);
127
insert into t1 values (1), (2), (3);
133
# Turning profiling off does freeze it
134
set session profiling = OFF;
135
select sum(id) from t1;
139
## Verify that the various juggling of THD contexts doesn't affect profiling.
141
## Functions and procedures
142
set session profiling = ON;
144
create function f1() returns varchar(50) return 'hello';
146
select * from t1 where id <> f1();
149
set session profiling = OFF;
150
drop table if exists profile_log;
151
create table profile_log (how_many int);
154
drop procedure if exists p1;
155
drop procedure if exists p2;
156
drop procedure if exists p3;
160
create procedure p1 ()
164
select 'This p1 should show up in profiling';
165
insert into profile_log select count(*) from information_schema.profiling;
167
create procedure p2()
172
select 'This p2 should show up in profiling';
174
create procedure p3 ()
178
select 'This p3 should show up in profiling';
184
--echo first call to p1
186
select * from profile_log;
187
--echo second call to p1
189
select * from profile_log;
190
--echo third call to p1
192
select * from profile_log;
193
set session profiling = OFF;
195
set session profiling = OFF;
198
--replace_column 1 # 2 #
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;
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;
213
insert into t2 values (1), (2), (3);
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);
222
alter table t2 add foreign key (id1) references t1 (id) on delete cascade;
233
select @@profiling, @@autocommit;
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;
241
--echo testing rollback
246
--echo testing commit
252
drop table if exists t1, t2, t3;
253
drop view if exists v1;
254
drop function if exists f1;
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;
262
## last thing in the file
263
set session profiling = OFF;
266
--echo End of 5.0 tests