2007-08-18 03:29:08 +02:00
# This test requires that --log-output includes 'table', and the general
# log is on
2006-11-13 17:06:45 +01:00
# embedded server causes different stat
-- source include/not_embedded.inc
2009-02-05 17:48:47 +01:00
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
2008-10-03 13:40:45 +02:00
# Disable concurrent inserts to avoid sporadic test failures as it might
# affect the the value of variables used throughout the test case.
set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
2009-06-10 10:58:36 +02:00
# Disable logging to table, since this will also cause table locking and unlocking, which will
# show up in SHOW STATUS and may cause sporadic failures
SET @old_log_output = @@global.log_output;
SET GLOBAL LOG_OUTPUT = 'FILE';
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;
2007-08-18 03:29:08 +02:00
2001-01-27 04:00:42 +01:00
show status like 'Table_lock%';
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
mysql-test/r/information_schema.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/information_schema_db.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/status.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added testcases.
mysql-test/r/variables.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added test cases.
mysql-test/t/status.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
mysql-test/t/variables.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
sql/sql_show.cc:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
Also, show_status_array(): argument 'ucase_names' is added (true means that
all variable names are to be converted to upper case).
sql/table.h:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
2006-09-14 01:37:40 +02:00
select * from information_schema.session_status where variable_name like 'Table_lock%';
2007-08-18 03:29:08 +02:00
2001-01-27 04:00:42 +01:00
connection con1;
2008-10-03 13:40:45 +02:00
--echo # Switched to connection: con1
set sql_log_bin=0;
set @old_general_log = @@global.general_log;
2007-10-16 10:43:16 +02:00
set global general_log = 'OFF';
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);
2008-10-03 13:40:45 +02:00
# Execute dummy select in order to ensure that tables used in the
# previous statement are unlocked and closed.
select 1;
2007-08-18 03:29:08 +02:00
2001-01-27 04:00:42 +01:00
connection con2;
2008-10-03 13:40:45 +02:00
--echo # Switched to connection: con2
2001-01-27 04:00:42 +01:00
lock tables t1 read;
unlock tables;
lock tables t1 read;
2007-08-18 03:29:08 +02:00
2001-01-27 04:00:42 +01:00
connection con1;
2008-10-03 13:40:45 +02:00
--echo # Switched to connection: con1
2007-07-19 21:25:54 +02:00
let $ID= `select connection_id()`;
2008-10-03 13:40:45 +02:00
--send update t1 set n = 3
2007-08-18 03:29:08 +02:00
2001-01-27 04:00:42 +01:00
connection con2;
2008-10-03 13:40:45 +02:00
--echo # Switched to connection: con2
2007-06-27 03:10:51 +02:00
# wait for the other query to start executing
2007-07-19 21:25:54 +02:00
let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Locked";
2007-06-27 03:10:51 +02:00
--source include/wait_condition.inc
2001-01-27 04:00:42 +01:00
unlock tables;
2007-08-18 03:29:08 +02:00
2001-01-27 04:00:42 +01:00
connection con1;
2008-10-03 13:40:45 +02:00
--echo # Switched to connection: con1
2001-01-27 04:00:42 +01:00
reap;
2007-08-18 03:29:08 +02:00
show status like 'Table_locks_waited';
2001-01-27 23:33:31 +01:00
drop table t1;
2007-10-16 10:43:16 +02:00
set global general_log = @old_general_log;
2005-07-28 02:22:47 +02:00
2006-04-12 15:37:57 +02:00
disconnect con2;
disconnect con1;
connection default;
2008-10-03 13:40:45 +02:00
--echo # Switched to connection: default
2006-04-12 15:37:57 +02:00
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-06-20 12:20:32 +02:00
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
select * from t1 where a=6;
show status like 'last_query_cost';
# Ensure value dosn't change by second status call
show status like 'last_query_cost';
select 1;
show status like 'last_query_cost';
drop table t1;
2006-04-07 13:30:40 +02:00
#
2009-02-05 17:48:47 +01:00
# Test for Bug#15933 max_used_connections is wrong after FLUSH STATUS
2006-04-07 13:30:40 +02:00
# 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';
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
mysql-test/r/information_schema.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/information_schema_db.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/status.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added testcases.
mysql-test/r/variables.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added test cases.
mysql-test/t/status.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
mysql-test/t/variables.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
sql/sql_show.cc:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
Also, show_status_array(): argument 'ucase_names' is added (true means that
all variable names are to be converted to upper case).
sql/table.h:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
2006-09-14 01:37:40 +02:00
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
2006-04-07 13:30:40 +02:00
# 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';
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
mysql-test/r/information_schema.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/information_schema_db.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/status.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added testcases.
mysql-test/r/variables.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added test cases.
mysql-test/t/status.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
mysql-test/t/variables.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
sql/sql_show.cc:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
Also, show_status_array(): argument 'ucase_names' is added (true means that
all variable names are to be converted to upper case).
sql/table.h:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
2006-09-14 01:37:40 +02:00
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
2006-04-07 13:30:40 +02:00
# 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';
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
mysql-test/r/information_schema.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/information_schema_db.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/status.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added testcases.
mysql-test/r/variables.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added test cases.
mysql-test/t/status.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
mysql-test/t/variables.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
sql/sql_show.cc:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
Also, show_status_array(): argument 'ucase_names' is added (true means that
all variable names are to be converted to upper case).
sql/table.h:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
2006-09-14 01:37:40 +02:00
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
2006-04-07 13:30:40 +02:00
# 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';
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
mysql-test/r/information_schema.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/information_schema_db.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/status.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added testcases.
mysql-test/r/variables.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added test cases.
mysql-test/t/status.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
mysql-test/t/variables.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
sql/sql_show.cc:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
Also, show_status_array(): argument 'ucase_names' is added (true means that
all variable names are to be converted to upper case).
sql/table.h:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
2006-09-14 01:37:40 +02:00
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
2006-04-07 13:30:40 +02:00
# ...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';
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
mysql-test/r/information_schema.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/information_schema_db.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed test cases result (changes are due to the new tables added).
mysql-test/r/status.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added testcases.
mysql-test/r/variables.result:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Fixed results for added test cases.
mysql-test/t/status.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
mysql-test/t/variables.test:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Added test cases.
sql/sql_show.cc:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
Also, show_status_array(): argument 'ucase_names' is added (true means that
all variable names are to be converted to upper case).
sql/table.h:
WL#3247,#3248: Adding [GLOBAL|SESSION]_STATUS and [GLOBAL|SESSION]_VARIABLES
tables to INFORMATION_SCHEMA.
Implementation of the new I_S tables.
2006-09-14 01:37:40 +02:00
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections';
2006-04-07 13:30:40 +02:00
# 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
#
2009-02-05 17:48:47 +01:00
# Bug#30377 EXPLAIN loses last_query_cost when used with UNION
2007-08-28 17:51:03 +02:00
#
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
2006-06-20 12:20:32 +02:00
#
# Ensure that SHOW STATUS only changes global status variables
#
connect (con1,localhost,root,,);
let $rnd_next = `show global status like 'handler_read_rnd_next'`;
let $tmp_table = `show global status like 'Created_tmp_tables'`;
show status like 'com_show_status';
show status like 'hand%write%';
show status like '%tmp%';
show status like 'hand%write%';
show status like '%tmp%';
show status like 'com_show_status';
let $rnd_next2 = `show global status like 'handler_read_rnd_next'`;
let $tmp_table2 = `show global status like 'Created_tmp_tables'`;
--disable_query_log
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;
--enable_query_log
2008-12-29 13:15:48 +01:00
disconnect con1;
connection default;
2006-06-20 12:20:32 +02:00
2009-02-05 17:48:47 +01:00
#
2007-12-15 00:27:40 +01:00
# Bug#30252 Com_create_function is not incremented.
#
2008-05-13 16:10:08 +02:00
flush status;
2008-05-21 17:34:14 +02:00
show status like 'Com%function';
2007-12-15 00:27:40 +01:00
DELIMITER //;
create function f1 (x INTEGER) returns integer
begin
declare ret integer;
set ret = x * 10;
return ret;
end //
DELIMITER ;//
drop function f1;
2008-05-21 17:34:14 +02:00
show status like 'Com%function';
2007-12-15 00:27:40 +01:00
2008-09-05 12:44:16 +02:00
#
2009-02-05 17:48:47 +01:00
# Bug#37908 Skipped access right check caused server crash.
2008-09-05 12:44:16 +02:00
#
connect (root, localhost, root,,test);
connection root;
2009-03-06 15:56:17 +01:00
let $root_connection_id= `select connection_id()`;
2008-09-05 12:44:16 +02:00
--disable_warnings
create database db37908;
--enable_warnings
create table db37908.t1(f1 int);
insert into db37908.t1 values(1);
grant usage,execute on test.* to mysqltest_1@localhost;
delimiter |;
create procedure proc37908() begin select 1; end |
2009-02-05 17:48:47 +01:00
create function func37908() returns int sql security invoker
2008-09-05 12:44:16 +02:00
return (select * from db37908.t1 limit 1)|
delimiter ;|
2009-02-05 17:48:47 +01:00
2008-09-05 12:44:16 +02:00
connect (user1,localhost,mysqltest_1,,test);
connection user1;
2009-03-06 15:56:17 +01:00
let $user1_connection_id= `select connection_id()`;
2008-09-05 12:44:16 +02:00
2009-02-05 17:48:47 +01:00
--error ER_TABLEACCESS_DENIED_ERROR
2008-09-05 12:44:16 +02:00
select * from db37908.t1;
2009-02-05 17:48:47 +01:00
--error ER_TABLEACCESS_DENIED_ERROR
2008-09-05 12:44:16 +02:00
show status where variable_name ='uptime' and 2 in (select * from db37908.t1);
2009-02-05 17:48:47 +01:00
--error ER_TABLEACCESS_DENIED_ERROR
2008-09-05 12:44:16 +02:00
show procedure status where name ='proc37908' and 1 in (select f1 from db37908.t1);
2009-02-05 17:48:47 +01:00
--error ER_TABLEACCESS_DENIED_ERROR
2008-09-05 12:44:16 +02:00
show function status where name ='func37908' and 1 in (select func37908());
2008-11-13 20:19:00 +01:00
connection default;
disconnect user1;
disconnect root;
2008-09-05 12:44:16 +02:00
drop database db37908;
drop procedure proc37908;
drop function func37908;
2008-11-13 20:19:00 +01:00
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost;
DROP USER mysqltest_1@localhost;
2009-03-06 15:56:17 +01:00
# Wait till the sessions user1 and root are disconnected
let $wait_condition =
SELECT COUNT(*) = 0
FROM information_schema.processlist
WHERE id in ('$root_connection_id','$user1_connection_id');
--source include/wait_condition.inc
2008-12-29 13:15:48 +01:00
2008-12-29 13:06:53 +01:00
#
# Bug#41131 "Questions" fails to increment - ignores statements instead stored procs
#
connect (con1,localhost,root,,);
connection con1;
--disable_warnings
DROP PROCEDURE IF EXISTS p1;
DROP FUNCTION IF EXISTS f1;
--enable_warnings
DELIMITER $$;
CREATE FUNCTION f1() RETURNS INTEGER
BEGIN
DECLARE foo INTEGER;
DECLARE bar INTEGER;
SET foo=1;
SET bar=2;
RETURN foo;
END $$
CREATE PROCEDURE p1()
BEGIN
SELECT 1;
END $$
DELIMITER ;$$
let $org_queries= `SHOW STATUS LIKE 'Queries'`;
SELECT f1();
CALL p1();
let $new_queries= `SHOW STATUS LIKE 'Queries'`;
2009-01-23 13:22:05 +01:00
--disable_query_log
2008-12-29 13:06:53 +01:00
let $diff= `SELECT SUBSTRING('$new_queries',9)-SUBSTRING('$org_queries',9)`;
2009-01-23 13:22:05 +01:00
--enable_query_log
2008-12-29 13:06:53 +01:00
eval SELECT $diff;
disconnect con1;
connection default;
DROP PROCEDURE p1;
DROP FUNCTION f1;
2006-06-20 12:20:32 +02:00
# End of 5.1 tests
2008-10-03 13:40:45 +02:00
# Restore global concurrent_insert value. Keep in the end of the test file.
--connection default
set @@global.concurrent_insert= @old_concurrent_insert;
2009-06-10 10:58:36 +02:00
SET GLOBAL log_output = @old_log_output;
2009-02-05 17:48:47 +01:00
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc