2006-11-13 17:06:45 +01:00
|
|
|
# embedded server causes different stat
|
|
|
|
-- source include/not_embedded.inc
|
|
|
|
|
2004-10-26 18:30:01 +02:00
|
|
|
# PS causes different statistics
|
|
|
|
--disable_ps_protocol
|
2001-10-08 03:58:07 +02:00
|
|
|
|
2001-03-25 00:02:26 +01:00
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
connect (con2,localhost,root,,);
|
2001-01-27 04:00:42 +01:00
|
|
|
|
2001-01-27 23:33:31 +01:00
|
|
|
flush status;
|
2001-01-27 04:00:42 +01:00
|
|
|
show status like 'Table_lock%';
|
|
|
|
connection con1;
|
|
|
|
SET SQL_LOG_BIN=0;
|
2003-01-06 00:48:59 +01:00
|
|
|
--disable_warnings
|
2001-01-27 04:00:42 +01:00
|
|
|
drop table if exists t1;
|
2003-01-06 00:48:59 +01:00
|
|
|
--enable_warnings
|
|
|
|
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t1(n int) engine=myisam;
|
2001-01-27 04:00:42 +01:00
|
|
|
insert into t1 values(1);
|
|
|
|
connection con2;
|
|
|
|
lock tables t1 read;
|
|
|
|
unlock tables;
|
|
|
|
lock tables t1 read;
|
|
|
|
connection con1;
|
2001-02-15 02:43:14 +01:00
|
|
|
--send
|
|
|
|
update t1 set n = 3;
|
2001-01-27 04:00:42 +01:00
|
|
|
connection con2;
|
2007-06-27 02:33:53 +02:00
|
|
|
sleep 1;
|
2001-01-27 04:00:42 +01:00
|
|
|
unlock tables;
|
|
|
|
connection con1;
|
|
|
|
reap;
|
|
|
|
show status like 'Table_lock%';
|
2001-01-27 23:33:31 +01:00
|
|
|
drop table t1;
|
2005-07-28 02:22:47 +02:00
|
|
|
|
2006-04-12 15:37:57 +02:00
|
|
|
disconnect con2;
|
|
|
|
disconnect con1;
|
|
|
|
connection default;
|
|
|
|
|
2005-07-28 02:22:47 +02:00
|
|
|
# End of 4.1 tests
|
2005-09-06 12:00:35 +02:00
|
|
|
|
|
|
|
#
|
2006-04-07 13:30:40 +02:00
|
|
|
# last_query_cost
|
2005-09-06 12:00:35 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
select 1;
|
|
|
|
show status like 'last_query_cost';
|
2006-04-07 13:30:40 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
2006-04-12 15:37:57 +02:00
|
|
|
# Wait for at most $disconnect_timeout seconds for disconnects to finish.
|
|
|
|
let $disconnect_timeout = 10;
|
2006-04-07 13:30:40 +02:00
|
|
|
|
2006-04-12 15:37:57 +02:00
|
|
|
# Wait for any previous disconnects to finish.
|
2006-04-07 13:30:40 +02:00
|
|
|
FLUSH STATUS;
|
2006-04-12 15:37:57 +02:00
|
|
|
--disable_query_log
|
|
|
|
--disable_result_log
|
|
|
|
eval SET @wait_left = $disconnect_timeout;
|
|
|
|
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
|
|
|
|
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
|
|
|
|
let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`;
|
|
|
|
while ($wait_more)
|
|
|
|
{
|
|
|
|
sleep 1;
|
|
|
|
FLUSH STATUS;
|
|
|
|
SET @wait_left = @wait_left - 1;
|
|
|
|
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
|
|
|
|
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
|
|
|
|
let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`;
|
|
|
|
}
|
|
|
|
--enable_query_log
|
|
|
|
--enable_result_log
|
|
|
|
|
|
|
|
# Prerequisite.
|
2006-04-07 13:30:40 +02:00
|
|
|
SHOW STATUS LIKE 'max_used_connections';
|
|
|
|
|
|
|
|
# Save original setting.
|
|
|
|
SET @save_thread_cache_size=@@thread_cache_size;
|
|
|
|
SET GLOBAL thread_cache_size=3;
|
|
|
|
|
2006-04-12 15:37:57 +02:00
|
|
|
connect (con1,localhost,root,,);
|
|
|
|
connect (con2,localhost,root,,);
|
2006-04-07 13:30:40 +02:00
|
|
|
|
2006-04-12 15:37:57 +02:00
|
|
|
connection con1;
|
|
|
|
disconnect con2;
|
2006-04-07 13:30:40 +02:00
|
|
|
|
|
|
|
# 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
|
2006-04-12 15:37:57 +02:00
|
|
|
# of connections. First wait for previous disconnect to finish.
|
2006-04-07 13:30:40 +02:00
|
|
|
FLUSH STATUS;
|
2006-04-12 15:37:57 +02:00
|
|
|
--disable_query_log
|
|
|
|
--disable_result_log
|
|
|
|
eval SET @wait_left = $disconnect_timeout;
|
|
|
|
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
|
|
|
|
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
|
|
|
|
let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`;
|
|
|
|
while ($wait_more)
|
|
|
|
{
|
|
|
|
sleep 1;
|
|
|
|
FLUSH STATUS;
|
|
|
|
SET @wait_left = @wait_left - 1;
|
|
|
|
let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`;
|
|
|
|
eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0;
|
|
|
|
let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`;
|
|
|
|
}
|
|
|
|
--enable_query_log
|
|
|
|
--enable_result_log
|
|
|
|
# Check that we don't count disconnected thread any longer.
|
2006-04-07 13:30:40 +02:00
|
|
|
SHOW STATUS LIKE 'max_used_connections';
|
|
|
|
|
|
|
|
# Check that max_used_connections is updated when cached thread is
|
|
|
|
# reused...
|
2006-04-12 15:37:57 +02:00
|
|
|
connect (con2,localhost,root,,);
|
2006-04-07 13:30:40 +02:00
|
|
|
SHOW STATUS LIKE 'max_used_connections';
|
|
|
|
|
|
|
|
# ...and when new thread is created.
|
2006-04-12 15:37:57 +02:00
|
|
|
connect (con3,localhost,root,,);
|
2006-04-07 13:30:40 +02:00
|
|
|
SHOW STATUS LIKE 'max_used_connections';
|
|
|
|
|
|
|
|
# Restore original setting.
|
|
|
|
connection default;
|
|
|
|
SET GLOBAL thread_cache_size=@save_thread_cache_size;
|
|
|
|
|
|
|
|
disconnect con3;
|
|
|
|
disconnect con2;
|
|
|
|
disconnect con1;
|
|
|
|
|
2007-08-28 17:51:03 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Bug #30377: EXPLAIN loses last_query_cost when used with UNION
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 ( a INT );
|
|
|
|
INSERT INTO t1 VALUES (1), (2);
|
|
|
|
|
|
|
|
SELECT a FROM t1 LIMIT 1;
|
|
|
|
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
|
|
|
|
|
|
|
EXPLAIN SELECT a FROM t1;
|
|
|
|
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
|
|
|
|
|
|
|
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
|
|
|
|
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
|
|
|
|
|
|
|
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
|
|
|
|
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
|
|
|
|
|
|
|
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
|
|
|
|
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
|
|
|
|
|
|
|
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
|
|
|
|
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
|
|
|
|
|
|
|
SELECT * FROM t1 a, t1 b LIMIT 1;
|
|
|
|
SHOW SESSION STATUS LIKE 'Last_query_cost';
|
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
|
2006-04-07 13:30:40 +02:00
|
|
|
# End of 5.0 tests
|