Unreported minor bug: We start numbering query IDs at zero, which

is a special case in "SHOW PROFILE FOR QUERY n".  No one can get
the zero item (which is always the statement that turns on profiling),
because zero represents the final item, internally.

Now, order the queries starting at one.
parent cd28612e
...@@ -69,34 +69,34 @@ big_string ...@@ -69,34 +69,34 @@ big_string
012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890 012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890
show profiles; show profiles;
Query_ID Duration Query Query_ID Duration Query
0 # set session profiling = ON 1 # set session profiling = ON
1 # set session profiling_history_size=30 2 # set session profiling_history_size=30
2 # show session variables like 'profil%' 3 # show session variables like 'profil%'
3 # select @@profiling 4 # select @@profiling
4 # create table t1 ( 5 # create table t1 (
a int, a int,
b int b int
) )
5 # insert into t1 values (1,1), (2,null), (3, 4) 6 # insert into t1 values (1,1), (2,null), (3, 4)
6 # insert into t1 values (5,1), (6,null), (7, 4) 7 # insert into t1 values (5,1), (6,null), (7, 4)
7 # insert into t1 values (1,1), (2,null), (3, 4) 8 # insert into t1 values (1,1), (2,null), (3, 4)
8 # insert into t1 values (5,1), (6,null), (7, 4) 9 # insert into t1 values (5,1), (6,null), (7, 4)
9 # select max(x) from (select sum(a) as x from t1 group by b) as teeone 10 # select max(x) from (select sum(a) as x from t1 group by b) as teeone
10 # insert into t1 select * from t1 11 # insert into t1 select * from t1
11 # select count(*) from t1 12 # select count(*) from t1
12 # insert into t1 select * from t1
13 # insert into t1 select * from t1 13 # insert into t1 select * from t1
14 # insert into t1 select * from t1 14 # insert into t1 select * from t1
15 # select count(*) from t1 15 # insert into t1 select * from t1
16 # insert into t1 select * from t1 16 # select count(*) from t1
17 # insert into t1 select * from t1 17 # insert into t1 select * from t1
18 # insert into t1 select * from t1 18 # insert into t1 select * from t1
19 # select count(*) from t1 19 # insert into t1 select * from t1
20 # select sum(a) from t1 20 # select count(*) from t1
21 # select sum(a) from t1 group by b 21 # select sum(a) from t1
22 # select sum(a) + sum(b) from t1 group by b 22 # select sum(a) from t1 group by b
23 # select max(x) from (select sum(a) as x from t1 group by b) as teeone 23 # select sum(a) + sum(b) from t1 group by b
24 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345 24 # select max(x) from (select sum(a) as x from t1 group by b) as teeone
25 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345
show profile for query 15; show profile for query 15;
show profile cpu for query 15; show profile cpu for query 15;
show profile cpu, block io for query 15; show profile cpu, block io for query 15;
...@@ -131,36 +131,36 @@ insert into t2 values (1), (2), (3); ...@@ -131,36 +131,36 @@ insert into t2 values (1), (2), (3);
insert into t3 values (1), (2), (3); insert into t3 values (1), (2), (3);
show profiles; show profiles;
Query_ID Duration Query Query_ID Duration Query
10 # insert into t1 select * from t1 11 # insert into t1 select * from t1
11 # select count(*) from t1 12 # select count(*) from t1
12 # insert into t1 select * from t1
13 # insert into t1 select * from t1 13 # insert into t1 select * from t1
14 # insert into t1 select * from t1 14 # insert into t1 select * from t1
15 # select count(*) from t1 15 # insert into t1 select * from t1
16 # insert into t1 select * from t1 16 # select count(*) from t1
17 # insert into t1 select * from t1 17 # insert into t1 select * from t1
18 # insert into t1 select * from t1 18 # insert into t1 select * from t1
19 # select count(*) from t1 19 # insert into t1 select * from t1
20 # select sum(a) from t1 20 # select count(*) from t1
21 # select sum(a) from t1 group by b 21 # select sum(a) from t1
22 # select sum(a) + sum(b) from t1 group by b 22 # select sum(a) from t1 group by b
23 # select max(x) from (select sum(a) as x from t1 group by b) as teeone 23 # select sum(a) + sum(b) from t1 group by b
24 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345 24 # select max(x) from (select sum(a) as x from t1 group by b) as teeone
25 # select * from information_schema.profiling 25 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345
26 # select query_id, state, duration from information_schema.profiling 26 # select * from information_schema.profiling
27 # select query_id, sum(duration) from information_schema.profiling group by query_id 27 # select query_id, state, duration from information_schema.profiling
28 # select query_id, count(*) from information_schema.profiling group by query_id 28 # select query_id, sum(duration) from information_schema.profiling group by query_id
29 # select sum(duration) from information_schema.profiling 29 # select query_id, count(*) from information_schema.profiling group by query_id
30 # select query_id, count(*), sum(duration) from information_schema.profiling group by query_id 30 # select sum(duration) from information_schema.profiling
31 # 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 31 # select query_id, count(*), sum(duration) from information_schema.profiling group by query_id
32 # drop table if exists t1, t2, t3 32 # 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
33 # SHOW WARNINGS 33 # drop table if exists t1, t2, t3
34 # create table t1 (id int ) 34 # SHOW WARNINGS
35 # create table t2 (id int not null) 35 # create table t1 (id int )
36 # create table t3 (id int not null primary key) 36 # create table t2 (id int not null)
37 # insert into t1 values (1), (2), (3) 37 # create table t3 (id int not null primary key)
38 # insert into t2 values (1), (2), (3) 38 # insert into t1 values (1), (2), (3)
39 # insert into t3 values (1), (2), (3) 39 # insert into t2 values (1), (2), (3)
40 # insert into t3 values (1), (2), (3)
select * from t1; select * from t1;
id id
1 1
...@@ -168,36 +168,36 @@ id ...@@ -168,36 +168,36 @@ id
3 3
show profiles; show profiles;
Query_ID Duration Query Query_ID Duration Query
11 # select count(*) from t1 12 # select count(*) from t1
12 # insert into t1 select * from t1
13 # insert into t1 select * from t1 13 # insert into t1 select * from t1
14 # insert into t1 select * from t1 14 # insert into t1 select * from t1
15 # select count(*) from t1 15 # insert into t1 select * from t1
16 # insert into t1 select * from t1 16 # select count(*) from t1
17 # insert into t1 select * from t1 17 # insert into t1 select * from t1
18 # insert into t1 select * from t1 18 # insert into t1 select * from t1
19 # select count(*) from t1 19 # insert into t1 select * from t1
20 # select sum(a) from t1 20 # select count(*) from t1
21 # select sum(a) from t1 group by b 21 # select sum(a) from t1
22 # select sum(a) + sum(b) from t1 group by b 22 # select sum(a) from t1 group by b
23 # select max(x) from (select sum(a) as x from t1 group by b) as teeone 23 # select sum(a) + sum(b) from t1 group by b
24 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345 24 # select max(x) from (select sum(a) as x from t1 group by b) as teeone
25 # select * from information_schema.profiling 25 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345
26 # select query_id, state, duration from information_schema.profiling 26 # select * from information_schema.profiling
27 # select query_id, sum(duration) from information_schema.profiling group by query_id 27 # select query_id, state, duration from information_schema.profiling
28 # select query_id, count(*) from information_schema.profiling group by query_id 28 # select query_id, sum(duration) from information_schema.profiling group by query_id
29 # select sum(duration) from information_schema.profiling 29 # select query_id, count(*) from information_schema.profiling group by query_id
30 # select query_id, count(*), sum(duration) from information_schema.profiling group by query_id 30 # select sum(duration) from information_schema.profiling
31 # 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 31 # select query_id, count(*), sum(duration) from information_schema.profiling group by query_id
32 # drop table if exists t1, t2, t3 32 # 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
33 # SHOW WARNINGS 33 # drop table if exists t1, t2, t3
34 # create table t1 (id int ) 34 # SHOW WARNINGS
35 # create table t2 (id int not null) 35 # create table t1 (id int )
36 # create table t3 (id int not null primary key) 36 # create table t2 (id int not null)
37 # insert into t1 values (1), (2), (3) 37 # create table t3 (id int not null primary key)
38 # insert into t2 values (1), (2), (3) 38 # insert into t1 values (1), (2), (3)
39 # insert into t3 values (1), (2), (3) 39 # insert into t2 values (1), (2), (3)
40 # select * from t1 40 # insert into t3 values (1), (2), (3)
41 # select * from t1
This ^^ should end in "select * from t1;" This ^^ should end in "select * from t1;"
delete from t1; delete from t1;
insert into t1 values (1), (2), (3); insert into t1 values (1), (2), (3);
...@@ -212,72 +212,72 @@ id ...@@ -212,72 +212,72 @@ id
3 3
show profiles; show profiles;
Query_ID Duration Query Query_ID Duration Query
15 # select count(*) from t1 16 # select count(*) from t1
16 # insert into t1 select * from t1
17 # insert into t1 select * from t1 17 # insert into t1 select * from t1
18 # insert into t1 select * from t1 18 # insert into t1 select * from t1
19 # select count(*) from t1 19 # insert into t1 select * from t1
20 # select sum(a) from t1 20 # select count(*) from t1
21 # select sum(a) from t1 group by b 21 # select sum(a) from t1
22 # select sum(a) + sum(b) from t1 group by b 22 # select sum(a) from t1 group by b
23 # select max(x) from (select sum(a) as x from t1 group by b) as teeone 23 # select sum(a) + sum(b) from t1 group by b
24 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345 24 # select max(x) from (select sum(a) as x from t1 group by b) as teeone
25 # select * from information_schema.profiling 25 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345
26 # select query_id, state, duration from information_schema.profiling 26 # select * from information_schema.profiling
27 # select query_id, sum(duration) from information_schema.profiling group by query_id 27 # select query_id, state, duration from information_schema.profiling
28 # select query_id, count(*) from information_schema.profiling group by query_id 28 # select query_id, sum(duration) from information_schema.profiling group by query_id
29 # select sum(duration) from information_schema.profiling 29 # select query_id, count(*) from information_schema.profiling group by query_id
30 # select query_id, count(*), sum(duration) from information_schema.profiling group by query_id 30 # select sum(duration) from information_schema.profiling
31 # 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 31 # select query_id, count(*), sum(duration) from information_schema.profiling group by query_id
32 # drop table if exists t1, t2, t3 32 # 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
33 # SHOW WARNINGS 33 # drop table if exists t1, t2, t3
34 # create table t1 (id int ) 34 # SHOW WARNINGS
35 # create table t2 (id int not null) 35 # create table t1 (id int )
36 # create table t3 (id int not null primary key) 36 # create table t2 (id int not null)
37 # insert into t1 values (1), (2), (3) 37 # create table t3 (id int not null primary key)
38 # insert into t2 values (1), (2), (3) 38 # insert into t1 values (1), (2), (3)
39 # insert into t3 values (1), (2), (3) 39 # insert into t2 values (1), (2), (3)
40 # select * from t1 40 # insert into t3 values (1), (2), (3)
41 # delete from t1 41 # select * from t1
42 # insert into t1 values (1), (2), (3) 42 # delete from t1
43 # insert into t1 values (1), (2), (3) 43 # insert into t1 values (1), (2), (3)
44 # select * from t1 44 # insert into t1 values (1), (2), (3)
45 # select * from t1
set session profiling = OFF; set session profiling = OFF;
select sum(id) from t1; select sum(id) from t1;
sum(id) sum(id)
12 12
show profiles; show profiles;
Query_ID Duration Query Query_ID Duration Query
15 # select count(*) from t1 16 # select count(*) from t1
16 # insert into t1 select * from t1
17 # insert into t1 select * from t1 17 # insert into t1 select * from t1
18 # insert into t1 select * from t1 18 # insert into t1 select * from t1
19 # select count(*) from t1 19 # insert into t1 select * from t1
20 # select sum(a) from t1 20 # select count(*) from t1
21 # select sum(a) from t1 group by b 21 # select sum(a) from t1
22 # select sum(a) + sum(b) from t1 group by b 22 # select sum(a) from t1 group by b
23 # select max(x) from (select sum(a) as x from t1 group by b) as teeone 23 # select sum(a) + sum(b) from t1 group by b
24 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345 24 # select max(x) from (select sum(a) as x from t1 group by b) as teeone
25 # select * from information_schema.profiling 25 # select '0123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345
26 # select query_id, state, duration from information_schema.profiling 26 # select * from information_schema.profiling
27 # select query_id, sum(duration) from information_schema.profiling group by query_id 27 # select query_id, state, duration from information_schema.profiling
28 # select query_id, count(*) from information_schema.profiling group by query_id 28 # select query_id, sum(duration) from information_schema.profiling group by query_id
29 # select sum(duration) from information_schema.profiling 29 # select query_id, count(*) from information_schema.profiling group by query_id
30 # select query_id, count(*), sum(duration) from information_schema.profiling group by query_id 30 # select sum(duration) from information_schema.profiling
31 # 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 31 # select query_id, count(*), sum(duration) from information_schema.profiling group by query_id
32 # drop table if exists t1, t2, t3 32 # 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
33 # SHOW WARNINGS 33 # drop table if exists t1, t2, t3
34 # create table t1 (id int ) 34 # SHOW WARNINGS
35 # create table t2 (id int not null) 35 # create table t1 (id int )
36 # create table t3 (id int not null primary key) 36 # create table t2 (id int not null)
37 # insert into t1 values (1), (2), (3) 37 # create table t3 (id int not null primary key)
38 # insert into t2 values (1), (2), (3) 38 # insert into t1 values (1), (2), (3)
39 # insert into t3 values (1), (2), (3) 39 # insert into t2 values (1), (2), (3)
40 # select * from t1 40 # insert into t3 values (1), (2), (3)
41 # delete from t1 41 # select * from t1
42 # insert into t1 values (1), (2), (3) 42 # delete from t1
43 # insert into t1 values (1), (2), (3) 43 # insert into t1 values (1), (2), (3)
44 # select * from t1 44 # insert into t1 values (1), (2), (3)
45 # select * from t1
set session profiling = ON; set session profiling = ON;
select @@profiling; select @@profiling;
@@profiling @@profiling
......
...@@ -158,7 +158,7 @@ void PROFILE_ENTRY::collect() ...@@ -158,7 +158,7 @@ void PROFILE_ENTRY::collect()
QUERY_PROFILE::QUERY_PROFILE(PROFILING *profiling_arg, char *query_source_arg, QUERY_PROFILE::QUERY_PROFILE(PROFILING *profiling_arg, char *query_source_arg,
uint query_length_arg) uint query_length_arg)
:profiling(profiling_arg), server_query_id(-1), profiling_query_id(-1), :profiling(profiling_arg), server_query_id(0), profiling_query_id(0),
query_source(NULL) query_source(NULL)
{ {
profile_end= &profile_start; profile_end= &profile_start;
...@@ -445,7 +445,7 @@ bool QUERY_PROFILE::show(uint options) ...@@ -445,7 +445,7 @@ bool QUERY_PROFILE::show(uint options)
} }
PROFILING::PROFILING() PROFILING::PROFILING()
:profile_id_counter(0), keeping(1), current(NULL), last(NULL) :profile_id_counter(1), keeping(1), current(NULL), last(NULL)
{ {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment