1
1
# This test requires that --log-output includes 'table', and the general
4
# PS causes different statistics
7
connect (con1,localhost,root,,);
8
connect (con2,localhost,root,,);
12
# Logging to the general query log table (--log-output=table --log) increments
13
# Table_locks_immediate with each query, so here Immediate becomes 1
14
show status like 'Table_lock%';
16
select * from information_schema.session_status where variable_name like 'Table_lock%';
21
set @old_general_log = @@global.general_log;
22
set global general_log = 'OFF';
25
7
drop table if exists t1;
29
create table t1(n int) engine=myisam;
31
insert into t1 values(1);
43
let $ID= `select connection_id()`;
44
# ++Immediate = 14 (Not +2, because this increments Table_locks_waited)
49
# wait for the other query to start executing
50
let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Table lock";
51
# Immediate = 14 + $wait_condition_reps ($wait_timeout is 0, so no extra select
52
# is done inside wait_condition.inc)
53
--source include/wait_condition.inc
54
# ++Immediate = 15 + $wait_condition_reps
59
# ++Immediate = 16 + $wait_condition_reps
60
show status like 'Table_locks_waited';
62
set global general_log = @old_general_log;
75
18
show status like 'last_query_cost';
76
create table t1 (a int);
19
create table t1 (a int) engine=myisam;
77
20
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
78
21
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
79
22
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
112
55
eval SET @wait_left = $disconnect_timeout;
113
56
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
114
57
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
115
let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`;
58
let $max_used = `SELECT @max_used_connections`;
59
let $wait_left= `SELECT @wait_left`;
60
while ($max_used != 1 && $wait_left > 0)
120
64
SET @wait_left = @wait_left - 1;
121
65
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
122
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
123
let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`;
66
SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
67
let $max_used = `SELECT @max_used_connections`;
68
let $wait_left= `SELECT @wait_left`;
125
70
--enable_query_log
126
71
--enable_result_log
130
75
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
132
77
# Save original setting.
133
SET @save_thread_cache_size=@@thread_cache_size;
134
SET GLOBAL thread_cache_size=3;
136
78
connect (con1,localhost,root,,);
137
79
connect (con2,localhost,root,,);
142
86
# Check that max_used_connections still reflects maximum value.
143
87
SHOW STATUS LIKE 'max_used_connections';
144
88
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
146
# Check that after flush max_used_connections equals to current number
147
# of connections. First wait for previous disconnect to finish.
151
eval SET @wait_left = $disconnect_timeout;
152
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
153
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
154
let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`;
159
SET @wait_left = @wait_left - 1;
160
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
161
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
162
let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`;
166
# Check that we don't count disconnected thread any longer.
167
SHOW STATUS LIKE 'max_used_connections';
168
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
170
# Check that max_used_connections is updated when cached thread is
172
connect (con2,localhost,root,,);
173
SHOW STATUS LIKE 'max_used_connections';
174
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
176
# ...and when new thread is created.
177
connect (con3,localhost,root,,);
178
SHOW STATUS LIKE 'max_used_connections';
179
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
181
# Restore original setting.
183
SET GLOBAL thread_cache_size=@save_thread_cache_size;
191
91
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
194
CREATE TABLE t1 ( a INT );
94
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM;
195
95
INSERT INTO t1 VALUES (1), (2);
197
97
SELECT a FROM t1 LIMIT 1;
221
121
# End of 5.0 tests
123
# https://bugs.launchpad.net/drizzle/+bug/310508
224
126
# Ensure that SHOW STATUS only changes global status variables
227
connect (con1,localhost,root,,);
228
let $rnd_next = `show global status like 'handler_read_rnd_next'`;
229
let $tmp_table = `show global status like 'Created_tmp_tables'`;
230
show status like 'com_show_status';
231
show status like 'hand%write%';
232
show status like '%tmp%';
233
show status like 'hand%write%';
234
show status like '%tmp%';
235
show status like 'com_show_status';
236
let $rnd_next2 = `show global status like 'handler_read_rnd_next'`;
237
let $tmp_table2 = `show global status like 'Created_tmp_tables'`;
239
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;
243
# Bug#30252 Com_create_function is not incremented.
245
show global status like 'Com%function%';
248
create function f1 (x INTEGER) returns integer
258
show global status like 'Com%function%';
129
#connect (con1,localhost,root,,);
130
#let $rnd_next = `show global status like 'handler_read_rnd_next'`;
131
#let $tmp_table = `show global status like 'Created_tmp_tables'`;
132
#show status like 'com_show_status';
133
#show status like 'hand%write%';
134
#show status like '%tmp%';
135
#show status like 'hand%write%';
136
#show status like '%tmp%';
137
#show status like 'com_show_status';
138
#let $rnd_next2 = `show global status like 'handler_read_rnd_next'`;
139
#let $tmp_table2 = `show global status like 'Created_tmp_tables'`;
141
#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;
261
145
# End of 5.1 tests
264
148
# Bug #17954: Threads_connected > Threads_created
267
SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
268
SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
269
SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
271
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
272
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;
151
#SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
152
#SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
153
#SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
155
#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
156
#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;