summaryrefslogtreecommitdiff
path: root/mysql-test/t/status.test
blob: 79a46a38550d0c1465b3b940e468d85b909ac631 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# This test doesn't work with the embedded version as this code
# assumes that one query is running while we are doing queries on
# a second connection.
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
--source include/not_embedded.inc
# PS causes different statistics
--disable_ps_protocol

connect (con1,localhost,root,,);
connect (con2,localhost,root,,);

flush status;
show status like 'Table_lock%';
connection con1;
SET SQL_LOG_BIN=0;
--disable_warnings
drop table if exists t1;
--enable_warnings

create table t1(n int) engine=myisam;
insert into t1 values(1);
connection con2;
lock tables t1 read;
unlock tables;
lock tables t1 read;
connection con1;
--send
update t1 set n = 3;
connection con2;
sleep 0.5;
unlock tables;
connection con1;
reap;
show status like 'Table_lock%';
drop table t1;

# End of 4.1 tests

#
# last_query_cost
#

select 1;
show status like 'last_query_cost';

#
# Test for Bug #15933 max_used_connections is wrong after FLUSH STATUS
# if connections are cached
#
#
# The first suggested fix from the bug report was chosen
# (see http://bugs.mysql.com/bug.php?id=15933):
#
#   a) On flushing the status, set max_used_connections to
#   threads_connected, not to 0.
#
#   b) Check if it is necessary to increment max_used_connections when
#   taking a thread from the cache as well as when creating new threads
#

# Previous test uses con1, con2.  If we disconnect them, there will be
# a race on when exactly this will happen, so we better leave them as
# is.
connection default;

# Reset max_used_connections from previous tests.
FLUSH STATUS;
SHOW STATUS LIKE 'max_used_connections';

# Save original setting.
SET @save_thread_cache_size=@@thread_cache_size;
SET GLOBAL thread_cache_size=3;

connect (con3,localhost,root,,);
connect (con4,localhost,root,,);

connection con3;
disconnect con4;

# Check that max_used_connections still reflects maximum value.
SHOW STATUS LIKE 'max_used_connections';

# Check that after flush max_used_connections equals to current number
# of connections.
FLUSH STATUS;
SHOW STATUS LIKE 'max_used_connections';

# Check that max_used_connections is updated when cached thread is
# reused...
connect (con4,localhost,root,,);
SHOW STATUS LIKE 'max_used_connections';

# ...and when new thread is created.
connect (con5,localhost,root,,);
SHOW STATUS LIKE 'max_used_connections';

# Restore original setting.
connection default;
SET GLOBAL thread_cache_size=@save_thread_cache_size;

disconnect con5;
disconnect con4;
disconnect con3;
disconnect con2;
disconnect con1;

# End of 5.0 tests