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
SELECT ASSERT(VARIABLE_VALUE = 1) FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
79
# Save original setting.
80
connect (con1,localhost,root,,);
81
connect (con2,localhost,root,,);
88
# 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';
92
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
95
CREATE TABLE t1 ( a INT );
96
INSERT INTO t1 VALUES (1), (2);
98
SELECT a FROM t1 LIMIT 1;
99
SHOW SESSION STATUS LIKE 'Last_query_cost';
102
EXPLAIN SELECT a FROM t1;
103
SHOW SESSION STATUS LIKE 'Last_query_cost';
105
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
106
SHOW SESSION STATUS LIKE 'Last_query_cost';
109
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
110
SHOW SESSION STATUS LIKE 'Last_query_cost';
112
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
113
SHOW SESSION STATUS LIKE 'Last_query_cost';
115
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
116
SHOW SESSION STATUS LIKE 'Last_query_cost';
118
SELECT * FROM t1 a CROSS JOIN t1 b LIMIT 1;
119
SHOW SESSION STATUS LIKE 'Last_query_cost';
126
# https://bugs.launchpad.net/drizzle/+bug/310508
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;
151
# 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;