~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/status.test

  • Committer: Monty Taylor
  • Date: 2008-09-16 00:00:48 UTC
  • mto: This revision was merged to the branch mainline in revision 391.
  • Revision ID: monty@inaugust.com-20080916000048-3rvrv3gv9l0ad3gs
Fixed copyright headers in drizzled/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This test requires that --log-output includes 'table', and the general
2
 
# log is on
3
 
 
4
 
flush status;
5
 
 
6
 
--disable_warnings
7
 
drop table if exists t1;
8
 
--enable_warnings
9
 
 
10
 
# End of 4.1 tests
11
 
 
12
 
#
13
 
# last_query_cost
14
 
#
15
 
 
16
 
 
17
 
select 1;
18
 
--replace_column 2 #
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;
27
 
--replace_column 2 #
28
 
show status like 'last_query_cost';
29
 
# Ensure value dosn't change by second status call
30
 
--replace_column 2 #
31
 
show status like 'last_query_cost';
32
 
select 1;
33
 
--replace_column 2 #
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;
62
 
let $max_used = `SELECT @max_used_connections`;
63
 
let $wait_left= `SELECT @wait_left`;
64
 
while ($max_used != 1 && $wait_left > 0)
65
 
{
66
 
  FLUSH STATUS;
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`;
72
 
}
73
 
--enable_query_log
74
 
--enable_result_log
75
 
 
76
 
# Prerequisite.
77
 
SELECT ASSERT(VARIABLE_VALUE = 1) FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
78
 
 
79
 
# Save original setting.
80
 
connect (con1,localhost,root,,);
81
 
connect (con2,localhost,root,,);
82
 
 
83
 
connection con1;
84
 
disconnect con2;
85
 
connection default;
86
 
disconnect con1;
87
 
 
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';
90
 
 
91
 
#
92
 
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
93
 
#
94
 
 
95
 
CREATE TABLE t1 ( a INT );
96
 
INSERT INTO t1 VALUES (1), (2);
97
 
 
98
 
SELECT a FROM t1 LIMIT 1;
99
 
SHOW SESSION STATUS LIKE 'Last_query_cost';
100
 
 
101
 
--replace_column 9 #
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
 
 
108
 
--replace_column 9 #
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
 
 
118
 
SELECT * FROM t1 a CROSS JOIN t1 b LIMIT 1;
119
 
SHOW SESSION STATUS LIKE 'Last_query_cost';
120
 
 
121
 
DROP TABLE t1;
122
 
 
123
 
 
124
 
# End of 5.0 tests
125
 
 
126
 
# https://bugs.launchpad.net/drizzle/+bug/310508
127
 
128
 
#
129
 
# Ensure that SHOW STATUS only changes global status variables
130
 
#
131
 
 
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
146
 
 
147
 
 
148
 
# End of 5.1 tests
149
 
 
150
 
#
151
 
# Bug #17954: Threads_connected > Threads_created
152
 
#
153
 
 
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;