~drizzle-trunk/drizzle/development

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;
1273.16.1 by Brian Aker
More removal of show code.
18
--replace_column 2 #
1 by brian
clean slate
19
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
20
create temporary table t1 (a int) engine=myisam;
1 by brian
clean slate
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;
1273.16.1 by Brian Aker
More removal of show code.
27
--replace_column 2 #
1 by brian
clean slate
28
show status like 'last_query_cost';
29
# Ensure value dosn't change by second status call
1273.16.1 by Brian Aker
More removal of show code.
30
--replace_column 2 #
1 by brian
clean slate
31
show status like 'last_query_cost';
32
select 1;
1273.16.1 by Brian Aker
More removal of show code.
33
--replace_column 2 #
1 by brian
clean slate
34
show status like 'last_query_cost';
35
drop table t1;
36
37
#
38
# Test for Bug #15933 max_used_connections is wrong after FLUSH STATUS
39
# if connections are cached
40
#
41
#
42
# The first suggested fix from the bug report was chosen
43
# (see http://bugs.mysql.com/bug.php?id=15933):
44
#
45
#   a) On flushing the status, set max_used_connections to
46
#   threads_connected, not to 0.
47
#
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
50
#
51
52
# Wait for at most $disconnect_timeout seconds for disconnects to finish.
53
let $disconnect_timeout = 10;
54
55
# Wait for any previous disconnects to finish.
56
FLUSH STATUS;
57
--disable_query_log
58
--disable_result_log
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;
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
62
let $max_used = `SELECT @max_used_connections`;
63
let $wait_left= `SELECT @wait_left`;
64
while ($max_used != 1 && $wait_left > 0)
1 by brian
clean slate
65
{
66
  FLUSH STATUS;
67
  SET @wait_left = @wait_left - 1;
68
  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
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`;
1 by brian
clean slate
72
}
73
--enable_query_log
74
--enable_result_log
75
76
# Prerequisite.
2095.2.1 by Brian Aker
Fix for lcov random order jittery
77
SELECT ASSERT(VARIABLE_VALUE = 1) FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
1 by brian
clean slate
78
79
# Save original setting.
80
connect (con1,localhost,root,,);
81
connect (con2,localhost,root,,);
82
83
connection con1;
84
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
85
connection default;
86
disconnect con1;
1 by brian
clean slate
87
88
# Check that max_used_connections still reflects maximum value.
2095.2.1 by Brian Aker
Fix for lcov random order jittery
89
SELECT ASSERT(VARIABLE_VALUE >= 3) FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
1 by brian
clean slate
90
91
#
92
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
93
#
94
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
95
CREATE TABLE t1 ( a INT );
1 by brian
clean slate
96
INSERT INTO t1 VALUES (1), (2);
97
98
SELECT a FROM t1 LIMIT 1;
99
SHOW SESSION STATUS LIKE 'Last_query_cost';
100
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
101
--replace_column 9 #
1 by brian
clean slate
102
EXPLAIN SELECT a FROM t1;
103
SHOW SESSION STATUS LIKE 'Last_query_cost';
104
105
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
106
SHOW SESSION STATUS LIKE 'Last_query_cost';
107
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
108
--replace_column 9 #
1 by brian
clean slate
109
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
110
SHOW SESSION STATUS LIKE 'Last_query_cost';
111
112
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
113
SHOW SESSION STATUS LIKE 'Last_query_cost';
114
115
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
116
SHOW SESSION STATUS LIKE 'Last_query_cost';
117
2141.4.2 by Andrew Hutchings
Implicit joins of the form "SELECT * FROM t1, t2" without WHERE or ON now error.
118
SELECT * FROM t1 a CROSS JOIN t1 b LIMIT 1;
1 by brian
clean slate
119
SHOW SESSION STATUS LIKE 'Last_query_cost';
120
121
DROP TABLE t1;
122
123
124
# End of 5.0 tests
125
673.3.32 by Stewart Smith
final fixup of status test (filing bugs for things)
126
# https://bugs.launchpad.net/drizzle/+bug/310508
127
# 
1 by brian
clean slate
128
#
129
# Ensure that SHOW STATUS only changes global status variables
130
#
131
673.3.32 by Stewart Smith
final fixup of status test (filing bugs for things)
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'`;
143
#--disable_query_log
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;
145
#--enable_query_log
1 by brian
clean slate
146
147
148
# End of 5.1 tests
149
150
#
151
# Bug #17954: Threads_connected > Threads_created
152
#
153
673.3.32 by Stewart Smith
final fixup of status test (filing bugs for things)
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';
157
#FLUSH STATUS;
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;