1
by brian
clean slate |
1 |
# This test requires that --log-output includes 'table', and the general |
2 |
# log is on |
|
3 |
||
4 |
flush status; |
|
5 |
||
734
by Brian Aker
Merging Stewart (one fix to his test case to drop t1 if left from previous |
6 |
--disable_warnings
|
7 |
drop table if exists t1; |
|
8 |
--enable_warnings
|
|
9 |
||
1
by brian
clean slate |
10 |
# End of 4.1 tests |
11 |
||
12 |
#
|
|
13 |
# last_query_cost |
|
14 |
#
|
|
15 |
||
734
by Brian Aker
Merging Stewart (one fix to his test case to drop t1 if left from previous |
16 |
|
1
by brian
clean slate |
17 |
select 1; |
18 |
show status like 'last_query_cost'; |
|
1063.9.27
by Stewart Smith
status.test for MyISAM as temp table only. Having to use default engine for EXPLAIN as opening table more than once |
19 |
create temporary table t1 (a int) engine=myisam; |
1
by brian
clean slate |
20 |
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); |
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 |
select * from t1 where a=6; |
|
26 |
show status like 'last_query_cost'; |
|
27 |
# Ensure value dosn't change by second status call |
|
28 |
show status like 'last_query_cost'; |
|
29 |
select 1;
|
|
30 |
show status like 'last_query_cost'; |
|
31 |
drop table t1;
|
|
32 |
||
33 |
#
|
|
34 |
# Test for Bug #15933 max_used_connections is wrong after FLUSH STATUS
|
|
35 |
# if connections are cached
|
|
36 |
#
|
|
37 |
#
|
|
38 |
# The first suggested fix from the bug report was chosen
|
|
39 |
# (see http://bugs.mysql.com/bug.php?id=15933):
|
|
40 |
#
|
|
41 |
# a) On flushing the status, set max_used_connections to
|
|
42 |
# threads_connected, not to 0.
|
|
43 |
#
|
|
44 |
# b) Check if it is necessary to increment max_used_connections when
|
|
45 |
# taking a thread from the cache as well as when creating new threads
|
|
46 |
#
|
|
47 |
||
48 |
# Wait for at most $disconnect_timeout seconds for disconnects to finish.
|
|
49 |
let $disconnect_timeout = 10;
|
|
50 |
||
51 |
# Wait for any previous disconnects to finish.
|
|
52 |
FLUSH STATUS;
|
|
53 |
--disable_query_log
|
|
54 |
--disable_result_log
|
|
55 |
eval SET @wait_left = $disconnect_timeout;
|
|
56 |
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`; |
|
57 |
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0; |
|
673.3.31
by Stewart Smith
status test: remove bits not applicable to Drizzle, explicitly use MyISAM in a few places to get stable costs |
58 |
let $max_used = `SELECT @max_used_connections`;
|
59 |
let $wait_left= `SELECT @wait_left`;
|
|
60 |
while ($max_used != 1 && $wait_left > 0)
|
|
1
by brian
clean slate |
61 |
{
|
62 |
sleep 1;
|
|
63 |
FLUSH STATUS;
|
|
64 |
SET @wait_left = @wait_left - 1;
|
|
65 |
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`; |
|
673.3.31
by Stewart Smith
status test: remove bits not applicable to Drizzle, explicitly use MyISAM in a few places to get stable costs |
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`;
|
|
1
by brian
clean slate |
69 |
}
|
70 |
--enable_query_log
|
|
71 |
--enable_result_log
|
|
72 |
||
73 |
# Prerequisite.
|
|
74 |
SHOW STATUS LIKE 'max_used_connections'; |
|
75 |
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; |
|
76 |
||
77 |
# Save original setting.
|
|
78 |
connect (con1,localhost,root,,);
|
|
79 |
connect (con2,localhost,root,,);
|
|
80 |
||
81 |
connection con1;
|
|
82 |
disconnect con2;
|
|
673.3.31
by Stewart Smith
status test: remove bits not applicable to Drizzle, explicitly use MyISAM in a few places to get stable costs |
83 |
connection default;
|
84 |
disconnect con1;
|
|
1
by brian
clean slate |
85 |
|
86 |
# Check that max_used_connections still reflects maximum value.
|
|
87 |
SHOW STATUS LIKE 'max_used_connections'; |
|
88 |
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; |
|
89 |
||
90 |
#
|
|
91 |
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
|
|
92 |
#
|
|
93 |
||
1063.9.27
by Stewart Smith
status.test for MyISAM as temp table only. Having to use default engine for EXPLAIN as opening table more than once |
94 |
CREATE TABLE t1 ( a INT );
|
1
by brian
clean slate |
95 |
INSERT INTO t1 VALUES (1), (2);
|
96 |
||
97 |
SELECT a FROM t1 LIMIT 1;
|
|
98 |
SHOW SESSION STATUS LIKE 'Last_query_cost'; |
|
99 |
||
1063.9.27
by Stewart Smith
status.test for MyISAM as temp table only. Having to use default engine for EXPLAIN as opening table more than once |
100 |
--replace_column 9 #
|
1
by brian
clean slate |
101 |
EXPLAIN SELECT a FROM t1;
|
102 |
SHOW SESSION STATUS LIKE 'Last_query_cost'; |
|
103 |
||
104 |
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
|
|
105 |
SHOW SESSION STATUS LIKE 'Last_query_cost'; |
|
106 |
||
1063.9.27
by Stewart Smith
status.test for MyISAM as temp table only. Having to use default engine for EXPLAIN as opening table more than once |
107 |
--replace_column 9 #
|
1
by brian
clean slate |
108 |
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
|
109 |
SHOW SESSION STATUS LIKE 'Last_query_cost'; |
|
110 |
||
111 |
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
|
|
112 |
SHOW SESSION STATUS LIKE 'Last_query_cost'; |
|
113 |
||
114 |
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
|
|
115 |
SHOW SESSION STATUS LIKE 'Last_query_cost'; |
|
116 |
||
117 |
SELECT * FROM t1 a, t1 b LIMIT 1;
|
|
118 |
SHOW SESSION STATUS LIKE 'Last_query_cost'; |
|
119 |
||
120 |
DROP TABLE t1;
|
|
121 |
||
122 |
||
123 |
# End of 5.0 tests
|
|
124 |
||
673.3.32
by Stewart Smith
final fixup of status test (filing bugs for things) |
125 |
# https://bugs.launchpad.net/drizzle/+bug/310508
|
126 |
#
|
|
1
by brian
clean slate |
127 |
#
|
128 |
# Ensure that SHOW STATUS only changes global status variables
|
|
129 |
#
|
|
130 |
||
673.3.32
by Stewart Smith
final fixup of status test (filing bugs for things) |
131 |
#connect (con1,localhost,root,,);
|
132 |
#let $rnd_next = `show global status like 'handler_read_rnd_next'`; |
|
133 |
#let $tmp_table = `show global status like 'Created_tmp_tables'`; |
|
134 |
#show status like 'com_show_status'; |
|
135 |
#show status like 'hand%write%'; |
|
136 |
#show status like '%tmp%'; |
|
137 |
#show status like 'hand%write%'; |
|
138 |
#show status like '%tmp%'; |
|
139 |
#show status like 'com_show_status'; |
|
140 |
#let $rnd_next2 = `show global status like 'handler_read_rnd_next'`; |
|
141 |
#let $tmp_table2 = `show global status like 'Created_tmp_tables'`; |
|
142 |
#--disable_query_log
|
|
143 |
#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; |
|
144 |
#--enable_query_log
|
|
1
by brian
clean slate |
145 |
|
146 |
||
147 |
# End of 5.1 tests
|
|
148 |
||
149 |
#
|
|
150 |
# Bug #17954: Threads_connected > Threads_created
|
|
151 |
#
|
|
152 |
||
673.3.32
by Stewart Smith
final fixup of status test (filing bugs for things) |
153 |
#SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected'; |
154 |
#SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc; |
|
155 |
#SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running'; |
|
156 |
#FLUSH STATUS;
|
|
157 |
#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc; |
|
158 |
#SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr; |