~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/status.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# This test requires that --log-output includes 'table', and the general
2
2
# log is on
3
3
 
 
4
# embedded server causes different stat
 
5
-- source include/not_embedded.inc
 
6
 
 
7
# PS causes different statistics
 
8
--disable_ps_protocol
 
9
 
 
10
connect (con1,localhost,root,,);
 
11
connect (con2,localhost,root,,);
 
12
 
4
13
flush status;
5
14
 
 
15
# Logging to the general query log table (--log-output=table --log) increments
 
16
# Table_locks_immediate with each query, so here Immediate becomes 1
 
17
show status like 'Table_lock%';
 
18
# ++Immediate = 2
 
19
select * from information_schema.session_status where variable_name like 'Table_lock%';
 
20
 
 
21
connection con1;
 
22
# ++Immediate = 3
 
23
SET SQL_LOG_BIN=0;
 
24
set @old_general_log = @@global.general_log;                                      
 
25
set global general_log = 'OFF';
6
26
--disable_warnings
 
27
# ++Immediate = 4
7
28
drop table if exists t1;
8
29
--enable_warnings
9
30
 
 
31
# ++Immediate = 5
 
32
create table t1(n int) engine=myisam;
 
33
# Immediate + 2 = 7
 
34
insert into t1 values(1);
 
35
 
 
36
connection con2;
 
37
# Immediate + 2 = 9
 
38
lock tables t1 read;
 
39
# ++Immediate = 10
 
40
unlock tables;
 
41
# Immediate + 2 = 12
 
42
lock tables t1 read;
 
43
 
 
44
connection con1;
 
45
# ++Immediate = 13
 
46
let $ID= `select connection_id()`;
 
47
# ++Immediate = 14 (Not +2, because this increments Table_locks_waited)
 
48
--send
 
49
update t1 set n = 3;
 
50
 
 
51
connection con2;
 
52
# wait for the other query to start executing
 
53
let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Table lock";
 
54
# Immediate = 14 + $wait_condition_reps ($wait_timeout is 0, so no extra select
 
55
# is done inside wait_condition.inc)
 
56
--source include/wait_condition.inc
 
57
# ++Immediate = 15 + $wait_condition_reps
 
58
unlock tables;
 
59
 
 
60
connection con1;
 
61
reap;
 
62
# ++Immediate = 16 + $wait_condition_reps
 
63
show status like 'Table_locks_waited';
 
64
drop table t1;
 
65
set global general_log = @old_general_log;
 
66
 
 
67
disconnect con2;
 
68
disconnect con1;
 
69
connection default;
 
70
 
10
71
# End of 4.1 tests
11
72
 
12
73
#
13
74
# last_query_cost
14
75
#
15
76
 
16
 
 
17
77
select 1;
18
 
--replace_column 2 #
19
78
show status like 'last_query_cost';
20
 
create temporary table t1 (a int) engine=myisam;
 
79
create table t1 (a int);
21
80
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
22
81
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
23
82
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
24
83
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
25
84
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
26
85
select * from t1 where a=6;
27
 
--replace_column 2 #
28
86
show status like 'last_query_cost';
29
87
# Ensure value dosn't change by second status call
30
 
--replace_column 2 #
31
88
show status like 'last_query_cost';
32
89
select 1;
33
 
--replace_column 2 #
34
90
show status like 'last_query_cost';
35
91
drop table t1;
36
92
 
59
115
eval SET @wait_left = $disconnect_timeout;
60
116
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
61
117
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)
 
118
let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`;
 
119
while ($wait_more)
65
120
{
 
121
  sleep 1;
66
122
  FLUSH STATUS;
67
123
  SET @wait_left = @wait_left - 1;
68
124
  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`;
 
125
  eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
 
126
  let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`;
72
127
}
73
128
--enable_query_log
74
129
--enable_result_log
75
130
 
76
131
# Prerequisite.
77
 
SELECT ASSERT(VARIABLE_VALUE = 1) FROM data_dictionary.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
 
132
SHOW STATUS LIKE 'max_used_connections';
 
133
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
78
134
 
79
135
# Save original setting.
 
136
SET @save_thread_cache_size=@@thread_cache_size;
 
137
SET GLOBAL thread_cache_size=3;
 
138
 
80
139
connect (con1,localhost,root,,);
81
140
connect (con2,localhost,root,,);
82
141
 
83
142
connection con1;
84
143
disconnect con2;
85
 
connection default;
86
 
disconnect con1;
87
144
 
88
145
# 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';
 
146
SHOW STATUS LIKE 'max_used_connections';
 
147
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
 
148
 
 
149
# Check that after flush max_used_connections equals to current number
 
150
# of connections.  First wait for previous disconnect to finish.
 
151
FLUSH STATUS;
 
152
--disable_query_log
 
153
--disable_result_log
 
154
eval SET @wait_left = $disconnect_timeout;
 
155
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
 
156
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
 
157
let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`;
 
158
while ($wait_more)
 
159
{
 
160
  sleep 1;
 
161
  FLUSH STATUS;
 
162
  SET @wait_left = @wait_left - 1;
 
163
  let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
 
164
  eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
 
165
  let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`;
 
166
}
 
167
--enable_query_log
 
168
--enable_result_log
 
169
# Check that we don't count disconnected thread any longer.
 
170
SHOW STATUS LIKE 'max_used_connections';
 
171
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
 
172
 
 
173
# Check that max_used_connections is updated when cached thread is
 
174
# reused...
 
175
connect (con2,localhost,root,,);
 
176
SHOW STATUS LIKE 'max_used_connections';
 
177
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
 
178
 
 
179
# ...and when new thread is created.
 
180
connect (con3,localhost,root,,);
 
181
SHOW STATUS LIKE 'max_used_connections';
 
182
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
 
183
 
 
184
# Restore original setting.
 
185
connection default;
 
186
SET GLOBAL thread_cache_size=@save_thread_cache_size;
 
187
 
 
188
disconnect con3;
 
189
disconnect con2;
 
190
disconnect con1;
 
191
 
90
192
 
91
193
#
92
194
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
98
200
SELECT a FROM t1 LIMIT 1;
99
201
SHOW SESSION STATUS LIKE 'Last_query_cost';
100
202
 
101
 
--replace_column 9 #
102
203
EXPLAIN SELECT a FROM t1;
103
204
SHOW SESSION STATUS LIKE 'Last_query_cost';
104
205
 
105
206
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
106
207
SHOW SESSION STATUS LIKE 'Last_query_cost';
107
208
 
108
 
--replace_column 9 #
109
209
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
110
210
SHOW SESSION STATUS LIKE 'Last_query_cost';
111
211
 
115
215
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
116
216
SHOW SESSION STATUS LIKE 'Last_query_cost';
117
217
 
118
 
SELECT * FROM t1 a CROSS JOIN t1 b LIMIT 1;
 
218
SELECT * FROM t1 a, t1 b LIMIT 1;
119
219
SHOW SESSION STATUS LIKE 'Last_query_cost';
120
220
 
121
221
DROP TABLE t1;
123
223
 
124
224
# End of 5.0 tests
125
225
 
126
 
# https://bugs.launchpad.net/drizzle/+bug/310508
 
226
#
 
227
# Ensure that SHOW STATUS only changes global status variables
 
228
#
 
229
 
 
230
connect (con1,localhost,root,,);
 
231
let $rnd_next = `show global status like 'handler_read_rnd_next'`;
 
232
let $tmp_table = `show global status like 'Created_tmp_tables'`;
 
233
show status like 'com_show_status';
 
234
show status like 'hand%write%';
 
235
show status like '%tmp%';
 
236
show status like 'hand%write%';
 
237
show status like '%tmp%';
 
238
show status like 'com_show_status';
 
239
let $rnd_next2 = `show global status like 'handler_read_rnd_next'`;
 
240
let $tmp_table2 = `show global status like 'Created_tmp_tables'`;
 
241
--disable_query_log
 
242
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;
 
243
--enable_query_log
 
244
 
127
245
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
 
246
# Bug#30252 Com_create_function is not incremented.
 
247
#
 
248
show global status like 'Com%function%';
 
249
 
 
250
DELIMITER //;
 
251
create function f1 (x INTEGER) returns integer
 
252
  begin
 
253
    declare ret integer;
 
254
    set ret = x * 10;
 
255
    return ret;
 
256
  end //
 
257
DELIMITER ;//
 
258
 
 
259
drop function f1;
 
260
 
 
261
show global status like 'Com%function%';
146
262
 
147
263
 
148
264
# End of 5.1 tests
151
267
# Bug #17954: Threads_connected > Threads_created
152
268
#
153
269
 
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;
 
270
SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
 
271
SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
 
272
SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
 
273
FLUSH STATUS;
 
274
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
 
275
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;