1
# This test requires that --log-output includes 'table', and the general
7
drop table if exists t1;
19
show status like 'last_query_cost';
20
create temporary table t1 (a int) engine=myisam;
21
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
22
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
23
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
24
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
25
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
26
select * from t1 where a=6;
28
show status like 'last_query_cost';
29
# Ensure value dosn't change by second status call
31
show status like 'last_query_cost';
34
show status like 'last_query_cost';
38
# Test for Bug #15933 max_used_connections is wrong after FLUSH STATUS
39
# if connections are cached
42
# The first suggested fix from the bug report was chosen
43
# (see http://bugs.mysql.com/bug.php?id=15933):
45
# a) On flushing the status, set max_used_connections to
46
# threads_connected, not to 0.
48
# b) Check if it is necessary to increment max_used_connections when
49
# taking a thread from the cache as well as when creating new threads
52
# Wait for at most $disconnect_timeout seconds for disconnects to finish.
53
let $disconnect_timeout = 10;
55
# Wait for any previous disconnects to finish.
59
eval SET @wait_left = $disconnect_timeout;
60
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
61
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)
67
SET @wait_left = @wait_left - 1;
68
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`;
77
SHOW STATUS LIKE 'max_used_connections';
78
SELECT * FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
80
# Save original setting.
81
connect (con1,localhost,root,,);
82
connect (con2,localhost,root,,);
89
# Check that max_used_connections still reflects maximum value.
90
SHOW STATUS LIKE 'max_used_connections';
91
SELECT * FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
94
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
97
CREATE TABLE t1 ( a INT );
98
INSERT INTO t1 VALUES (1), (2);
100
SELECT a FROM t1 LIMIT 1;
101
SHOW SESSION STATUS LIKE 'Last_query_cost';
104
EXPLAIN SELECT a FROM t1;
105
SHOW SESSION STATUS LIKE 'Last_query_cost';
107
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
108
SHOW SESSION STATUS LIKE 'Last_query_cost';
111
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
112
SHOW SESSION STATUS LIKE 'Last_query_cost';
114
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
115
SHOW SESSION STATUS LIKE 'Last_query_cost';
117
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
118
SHOW SESSION STATUS LIKE 'Last_query_cost';
120
SELECT * FROM t1 a, t1 b LIMIT 1;
121
SHOW SESSION STATUS LIKE 'Last_query_cost';
128
# https://bugs.launchpad.net/drizzle/+bug/310508
131
# Ensure that SHOW STATUS only changes global status variables
134
#connect (con1,localhost,root,,);
135
#let $rnd_next = `show global status like 'handler_read_rnd_next'`;
136
#let $tmp_table = `show global status like 'Created_tmp_tables'`;
137
#show status like 'com_show_status';
138
#show status like 'hand%write%';
139
#show status like '%tmp%';
140
#show status like 'hand%write%';
141
#show status like '%tmp%';
142
#show status like 'com_show_status';
143
#let $rnd_next2 = `show global status like 'handler_read_rnd_next'`;
144
#let $tmp_table2 = `show global status like 'Created_tmp_tables'`;
146
#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;
153
# Bug #17954: Threads_connected > Threads_created
156
#SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
157
#SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
158
#SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
160
#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
161
#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;