1
1
# This test requires that --log-output includes 'table', and the general
4
# embedded server causes different stat
5
-- source include/not_embedded.inc
7
# PS causes different statistics
10
connect (con1,localhost,root,,);
11
connect (con2,localhost,root,,);
15
# Logging to the general query log table (--log-output=table --log) increments
16
# Table_locks_immediate with each query, so here Immediate becomes 1
17
show status like 'Table_lock%';
19
select * from information_schema.session_status where variable_name like 'Table_lock%';
24
set @old_general_log = @@global.general_log;
25
set global general_log = 'OFF';
7
28
drop table if exists t1;
32
create table t1(n int) engine=myisam;
34
insert into t1 values(1);
46
let $ID= `select connection_id()`;
47
# ++Immediate = 14 (Not +2, because this increments Table_locks_waited)
52
# wait for the other query to start executing
53
let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Table lock";
54
# Immediate = 14 + $wait_condition_reps ($wait_timeout is 0, so no extra select
55
# is done inside wait_condition.inc)
56
--source include/wait_condition.inc
57
# ++Immediate = 15 + $wait_condition_reps
62
# ++Immediate = 16 + $wait_condition_reps
63
show status like 'Table_locks_waited';
65
set global general_log = @old_general_log;
19
78
show status like 'last_query_cost';
20
create temporary table t1 (a int) engine=myisam;
79
create table t1 (a int);
21
80
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
22
81
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
23
82
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
24
83
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
25
84
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
26
85
select * from t1 where a=6;
28
86
show status like 'last_query_cost';
29
87
# Ensure value dosn't change by second status call
31
88
show status like 'last_query_cost';
34
90
show status like 'last_query_cost';
59
115
eval SET @wait_left = $disconnect_timeout;
60
116
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
61
117
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
62
let $max_used = `SELECT @max_used_connections`;
63
let $wait_left= `SELECT @wait_left`;
64
while ($max_used != 1 && $wait_left > 0)
118
let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`;
67
123
SET @wait_left = @wait_left - 1;
68
124
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
69
SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
70
let $max_used = `SELECT @max_used_connections`;
71
let $wait_left= `SELECT @wait_left`;
125
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
126
let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`;
73
128
--enable_query_log
74
129
--enable_result_log
77
SELECT ASSERT(VARIABLE_VALUE = 1) FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
132
SHOW STATUS LIKE 'max_used_connections';
133
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
79
135
# Save original setting.
136
SET @save_thread_cache_size=@@thread_cache_size;
137
SET GLOBAL thread_cache_size=3;
80
139
connect (con1,localhost,root,,);
81
140
connect (con2,localhost,root,,);
88
145
# Check that max_used_connections still reflects maximum value.
89
SELECT ASSERT(VARIABLE_VALUE >= 3) FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
146
SHOW STATUS LIKE 'max_used_connections';
147
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
149
# Check that after flush max_used_connections equals to current number
150
# of connections. First wait for previous disconnect to finish.
154
eval SET @wait_left = $disconnect_timeout;
155
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
156
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
157
let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`;
162
SET @wait_left = @wait_left - 1;
163
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
164
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
165
let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`;
169
# Check that we don't count disconnected thread any longer.
170
SHOW STATUS LIKE 'max_used_connections';
171
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
173
# Check that max_used_connections is updated when cached thread is
175
connect (con2,localhost,root,,);
176
SHOW STATUS LIKE 'max_used_connections';
177
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
179
# ...and when new thread is created.
180
connect (con3,localhost,root,,);
181
SHOW STATUS LIKE 'max_used_connections';
182
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
184
# Restore original setting.
186
SET GLOBAL thread_cache_size=@save_thread_cache_size;
92
194
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
124
224
# End of 5.0 tests
126
# https://bugs.launchpad.net/drizzle/+bug/310508
227
# Ensure that SHOW STATUS only changes global status variables
230
connect (con1,localhost,root,,);
231
let $rnd_next = `show global status like 'handler_read_rnd_next'`;
232
let $tmp_table = `show global status like 'Created_tmp_tables'`;
233
show status like 'com_show_status';
234
show status like 'hand%write%';
235
show status like '%tmp%';
236
show status like 'hand%write%';
237
show status like '%tmp%';
238
show status like 'com_show_status';
239
let $rnd_next2 = `show global status like 'handler_read_rnd_next'`;
240
let $tmp_table2 = `show global status like 'Created_tmp_tables'`;
242
eval select substring_index('$rnd_next2',0x9,-1)-substring_index('$rnd_next',0x9,-1) as rnd_diff, substring_index('$tmp_table2',0x9,-1)-substring_index('$tmp_table',0x9,-1) as tmp_table_diff;
129
# Ensure that SHOW STATUS only changes global status variables
132
#connect (con1,localhost,root,,);
133
#let $rnd_next = `show global status like 'handler_read_rnd_next'`;
134
#let $tmp_table = `show global status like 'Created_tmp_tables'`;
135
#show status like 'com_show_status';
136
#show status like 'hand%write%';
137
#show status like '%tmp%';
138
#show status like 'hand%write%';
139
#show status like '%tmp%';
140
#show status like 'com_show_status';
141
#let $rnd_next2 = `show global status like 'handler_read_rnd_next'`;
142
#let $tmp_table2 = `show global status like 'Created_tmp_tables'`;
144
#eval select substring_index('$rnd_next2',0x9,-1)-substring_index('$rnd_next',0x9,-1) as rnd_diff, substring_index('$tmp_table2',0x9,-1)-substring_index('$tmp_table',0x9,-1) as tmp_table_diff;
246
# Bug#30252 Com_create_function is not incremented.
248
show global status like 'Com%function%';
251
create function f1 (x INTEGER) returns integer
261
show global status like 'Com%function%';
148
264
# End of 5.1 tests
151
267
# Bug #17954: Threads_connected > Threads_created
154
#SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
155
#SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
156
#SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
158
#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
159
#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;
270
SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
271
SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
272
SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
274
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
275
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;