~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/t/status.test

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

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
SHOW STATUS LIKE 'max_used_connections';
 
78
SELECT * FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
 
79
 
 
80
# Save original setting.
 
81
connect (con1,localhost,root,,);
 
82
connect (con2,localhost,root,,);
 
83
 
 
84
connection con1;
 
85
disconnect con2;
 
86
connection default;
 
87
disconnect con1;
 
88
 
 
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';
 
92
 
 
93
#
 
94
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
 
95
#
 
96
 
 
97
CREATE TABLE t1 ( a INT );
 
98
INSERT INTO t1 VALUES (1), (2);
 
99
 
 
100
SELECT a FROM t1 LIMIT 1;
 
101
SHOW SESSION STATUS LIKE 'Last_query_cost';
 
102
 
 
103
--replace_column 9 #
 
104
EXPLAIN SELECT a FROM t1;
 
105
SHOW SESSION STATUS LIKE 'Last_query_cost';
 
106
 
 
107
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
 
108
SHOW SESSION STATUS LIKE 'Last_query_cost';
 
109
 
 
110
--replace_column 9 #
 
111
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
 
112
SHOW SESSION STATUS LIKE 'Last_query_cost';
 
113
 
 
114
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
 
115
SHOW SESSION STATUS LIKE 'Last_query_cost';
 
116
 
 
117
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
 
118
SHOW SESSION STATUS LIKE 'Last_query_cost';
 
119
 
 
120
SELECT * FROM t1 a, t1 b LIMIT 1;
 
121
SHOW SESSION STATUS LIKE 'Last_query_cost';
 
122
 
 
123
DROP TABLE t1;
 
124
 
 
125
 
 
126
# End of 5.0 tests
 
127
 
 
128
# https://bugs.launchpad.net/drizzle/+bug/310508
 
129
 
130
#
 
131
# Ensure that SHOW STATUS only changes global status variables
 
132
#
 
133
 
 
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'`;
 
145
#--disable_query_log
 
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;
 
147
#--enable_query_log
 
148
 
 
149
 
 
150
# End of 5.1 tests
 
151
 
 
152
#
 
153
# Bug #17954: Threads_connected > Threads_created
 
154
#
 
155
 
 
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';
 
159
#FLUSH STATUS;
 
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;