Commit b07fc544 authored by unknown's avatar unknown

Merge trift2.:/MySQL/M51/clone-5.1

into  trift2.:/MySQL/M51/target-5.1.22

parents efac5af7 833afa54
CREATE DATABASE IF NOT EXISTS events_test;
USE events_test;
"We use procedure here because its statements won't be logged into the general log"
"If we had used normal select that are logged in different ways depending on whether"
"the test suite is run in normal mode or with --ps-protocol"
CREATE procedure select_general_log()
BEGIN
SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%';
END|
"Check General Query Log"
CALL select_general_log();
drop database if exists events_test;
create database if not exists events_test;
use events_test;
We use procedure here because its statements won't be
logged into the general log. If we had used normal select
that are logged in different ways depending on whether the
test suite is run in normal mode or with --ps-protocol
create procedure select_general_log()
begin
select user_host, argument from mysql.general_log
where argument like '%events_logs_test%';
end|
Check that general query log works, but sub-statements
of the stored procedure do not leave traces in it.
truncate mysql.general_log;
select 'events_logs_tests' as outside_event;
outside_event
events_logs_tests
call select_general_log();
user_host argument
USER_HOST CREATE procedure select_general_log()
BEGIN
SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%';
END
SET GLOBAL event_scheduler=on;
TRUNCATE mysql.general_log;
CREATE EVENT log_general ON SCHEDULE EVERY 1 MINUTE DO SELECT 'alabala', SLEEP(1) FROM DUAL;
"Wait the scheduler to start"
"Should see 2 rows - the 'SELECT' is in the middle. The other two are selects from general_log"
CALL select_general_log();
USER_HOST select 'events_logs_tests' as outside_event
Check that unlike sub-statements of stored procedures,
sub-statements of events are present in the general log.
set global event_scheduler=on;
truncate mysql.general_log;
create event ev_log_general on schedule at now() on completion not preserve do select 'events_logs_test' as inside_event;
call select_general_log();
user_host argument
USER_HOST CREATE EVENT log_general ON SCHEDULE EVERY 1 MINUTE DO SELECT 'alabala', SLEEP(1) FROM DUAL
USER_HOST SELECT 'alabala', SLEEP(1) FROM DUAL
DROP PROCEDURE select_general_log;
DROP EVENT log_general;
SET GLOBAL event_scheduler=off;
"Check slow query log"
"Save the values"
SET @old_global_long_query_time:=(select get_value());
SET @old_session_long_query_time:=@@long_query_time;
SHOW VARIABLES LIKE 'log_slow_queries';
USER_HOST create event ev_log_general on schedule at now() on completion not preserve do select 'events_logs_test' as inside_event
USER_HOST select 'events_logs_test' as inside_event
Check slow query log
Ensure that slow logging is on
show variables like 'log_slow_queries';
Variable_name Value
log_slow_queries ON
DROP FUNCTION get_value;
"Make it quite long"
SET SESSION long_query_time=300;
TRUNCATE mysql.slow_log;
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host query_time db sql_text
"Set new values"
SET GLOBAL long_query_time=4;
SET SESSION long_query_time=0.5;
"Check that logging is working"
SELECT SLEEP(2);
SLEEP(2)
0
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host query_time db sql_text
USER_HOST SLEEPVAL events_test SELECT SLEEP(2)
SET SESSION long_query_time=300;
"Make it quite long"
TRUNCATE mysql.slow_log;
CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
SET SESSION long_query_time=1;
"This won't go to the slow log"
SELECT * FROM slow_event_test;
slo_val val
SET SESSION long_query_time=1;
SET GLOBAL event_scheduler=on;
SET GLOBAL long_query_time=20;
CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(1.5);
"Sleep some more time than the actual event run will take"
SHOW VARIABLES LIKE 'event_scheduler';
Variable_name Value
event_scheduler ON
"Check our table. Should see 1 row"
SELECT * FROM slow_event_test;
slo_val val
20 0
"Check slow log. Should not see anything because 1.5 is under the threshold of 20 for GLOBAL, though over SESSION which is 1"
"This should show that the GLOBAL value is regarded and not the SESSION one of the current connection"
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host query_time db sql_text
"Another test to show that GLOBAL is regarded and not SESSION."
"This should go to the slow log"
SET SESSION long_query_time=10;
DROP EVENT long_event;
SET GLOBAL long_query_time=1;
CREATE EVENT long_event2 ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(2);
"Sleep some more time than the actual event run will take"
"Check our table. Should see 2 rows"
SELECT * FROM slow_event_test;
slo_val val
20 0
1 0
"Check slow log. Should see 1 row because 2 is over the threshold of 1 for GLOBAL, though under SESSION which is 10"
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host query_time db sql_text
USER_HOST SLEEPVAL events_test INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(2)
DROP EVENT long_event2;
"Make it quite long"
SET SESSION long_query_time=300;
TRUNCATE mysql.slow_log;
DROP TABLE slow_event_test;
SET GLOBAL long_query_time =@old_global_long_query_time;
SET SESSION long_query_time =@old_session_long_query_time;
DROP DATABASE events_test;
SET GLOBAL event_scheduler=off;
Demonstrate that session value has no effect
set @@session.long_query_time=1;
set @@global.long_query_time=300;
truncate mysql.slow_log;
create event ev_log_general on schedule at now() on completion not preserve
do select 'events_logs_test' as inside_event, sleep(1.5);
Nothing should be logged
select user_host, db, sql_text from mysql.slow_log where sql_text not like 'create event%';
user_host db sql_text
set @@global.long_query_time=1;
truncate mysql.slow_log;
create event ev_log_general on schedule at now() on completion not preserve
do select 'events_logs_test' as inside_event, sleep(1.5);
Event sub-statement should be logged.
select user_host, db, sql_text from mysql.slow_log where sql_text not like 'create event%';
user_host db sql_text
USER_HOST events_test select 'events_logs_test' as inside_event, sleep(1.5)
drop database events_test;
set global event_scheduler=off;
set @@global.long_query_time=default;
set @@session.long_query_time=default;
......@@ -13,9 +13,9 @@ insert into t1 values (1);
lock tables t1 read;
update low_priority t1 set n = 4;
select n from t1;
unlock tables;
n
1
unlock tables;
drop table t1;
create table t1 (a int, b int);
create table t2 (c int, d int);
......@@ -43,6 +43,7 @@ insert t1 select * from t2;
drop table t2;
ERROR 42S02: Table 'test.t2' doesn't exist
drop table t1;
End of 4.1 tests
create table t1(a int);
lock tables t1 write;
show columns from t1;
......@@ -91,10 +92,11 @@ DROP DATABASE mysqltest_1;
ERROR HY000: Can't drop database 'mysqltest_1'; database doesn't exist
create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) engine=innodb;
lock tables t1 write;
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
alter table t1 auto_increment=0;
alter table t1 auto_increment=0;
unlock tables;
drop table t1;
End of 5.0 tests
create table t1 (i int);
lock table t1 read;
update t1 set i= 10;;
......
......@@ -200,6 +200,240 @@ COUNT(*)
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
CREATE TABLE test.t (
a smallint NOT NULL,
b int NOT NULL,
c bigint NOT NULL,
d char(10),
e TEXT,
f VARCHAR(255),
PRIMARY KEY(a)
) TABLESPACE ts1 STORAGE DISK ENGINE=NDB;
ALTER TABLE test.t ADD INDEX (d), ADD INDEX (f);
SHOW CREATE TABLE test.t;
Table Create Table
t CREATE TABLE `t` (
`a` smallint(6) NOT NULL,
`b` int(11) NOT NULL,
`c` bigint(20) NOT NULL,
`d` char(10) DEFAULT NULL,
`e` text,
`f` varchar(255) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `d` (`d`),
KEY `f` (`f`)
) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
SELECT * FROM test.t order by a;
a b c d e f
1 2 3 aaa1 bbb1 ccccc1
2 3 4 aaa2 bbb2 ccccc2
3 4 5 aaa3 bbb3 ccccc3
4 5 6 aaa4 bbb4 ccccc4
5 6 7 aaa5 bbb5 ccccc5
6 7 8 aaa6 bbb6 ccccc6
7 8 9 aaa7 bbb7 ccccc7
8 9 10 aaa8 bbb8 ccccc8
9 10 11 aaa9 bbb9 ccccc9
10 11 12 aaa10 bbb10 ccccc10
11 12 13 aaa11 bbb11 ccccc11
12 13 14 aaa12 bbb12 ccccc12
13 14 15 aaa13 bbb13 ccccc13
14 15 16 aaa14 bbb14 ccccc14
15 16 17 aaa15 bbb15 ccccc15
16 17 18 aaa16 bbb16 ccccc16
17 18 19 aaa17 bbb17 ccccc17
18 19 20 aaa18 bbb18 ccccc18
19 20 21 aaa19 bbb19 ccccc19
20 21 22 aaa20 bbb20 ccccc20
21 22 23 aaa21 bbb21 ccccc21
22 23 24 aaa22 bbb22 ccccc22
23 24 25 aaa23 bbb23 ccccc23
24 25 26 aaa24 bbb24 ccccc24
25 26 27 aaa25 bbb25 ccccc25
26 27 28 aaa26 bbb26 ccccc26
27 28 29 aaa27 bbb27 ccccc27
28 29 30 aaa28 bbb28 ccccc28
29 30 31 aaa29 bbb29 ccccc29
30 31 32 aaa30 bbb30 ccccc30
31 32 33 aaa31 bbb31 ccccc31
32 33 34 aaa32 bbb32 ccccc32
33 34 35 aaa33 bbb33 ccccc33
34 35 36 aaa34 bbb34 ccccc34
35 36 37 aaa35 bbb35 ccccc35
36 37 38 aaa36 bbb36 ccccc36
37 38 39 aaa37 bbb37 ccccc37
38 39 40 aaa38 bbb38 ccccc38
39 40 41 aaa39 bbb39 ccccc39
40 41 42 aaa40 bbb40 ccccc40
41 42 43 aaa41 bbb41 ccccc41
42 43 44 aaa42 bbb42 ccccc42
43 44 45 aaa43 bbb43 ccccc43
44 45 46 aaa44 bbb44 ccccc44
45 46 47 aaa45 bbb45 ccccc45
46 47 48 aaa46 bbb46 ccccc46
47 48 49 aaa47 bbb47 ccccc47
48 49 50 aaa48 bbb48 ccccc48
49 50 51 aaa49 bbb49 ccccc49
50 51 52 aaa50 bbb50 ccccc50
51 52 53 aaa51 bbb51 ccccc51
52 53 54 aaa52 bbb52 ccccc52
53 54 55 aaa53 bbb53 ccccc53
54 55 56 aaa54 bbb54 ccccc54
55 56 57 aaa55 bbb55 ccccc55
56 57 58 aaa56 bbb56 ccccc56
57 58 59 aaa57 bbb57 ccccc57
58 59 60 aaa58 bbb58 ccccc58
59 60 61 aaa59 bbb59 ccccc59
60 61 62 aaa60 bbb60 ccccc60
61 62 63 aaa61 bbb61 ccccc61
62 63 64 aaa62 bbb62 ccccc62
63 64 65 aaa63 bbb63 ccccc63
64 65 66 aaa64 bbb64 ccccc64
65 66 67 aaa65 bbb65 ccccc65
66 67 68 aaa66 bbb66 ccccc66
67 68 69 aaa67 bbb67 ccccc67
68 69 70 aaa68 bbb68 ccccc68
69 70 71 aaa69 bbb69 ccccc69
70 71 72 aaa70 bbb70 ccccc70
71 72 73 aaa71 bbb71 ccccc71
72 73 74 aaa72 bbb72 ccccc72
73 74 75 aaa73 bbb73 ccccc73
74 75 76 aaa74 bbb74 ccccc74
75 76 77 aaa75 bbb75 ccccc75
76 77 78 aaa76 bbb76 ccccc76
77 78 79 aaa77 bbb77 ccccc77
78 79 80 aaa78 bbb78 ccccc78
79 80 81 aaa79 bbb79 ccccc79
80 81 82 aaa80 bbb80 ccccc80
81 82 83 aaa81 bbb81 ccccc81
82 83 84 aaa82 bbb82 ccccc82
83 84 85 aaa83 bbb83 ccccc83
84 85 86 aaa84 bbb84 ccccc84
85 86 87 aaa85 bbb85 ccccc85
86 87 88 aaa86 bbb86 ccccc86
87 88 89 aaa87 bbb87 ccccc87
88 89 90 aaa88 bbb88 ccccc88
89 90 91 aaa89 bbb89 ccccc89
90 91 92 aaa90 bbb90 ccccc90
91 92 93 aaa91 bbb91 ccccc91
92 93 94 aaa92 bbb92 ccccc92
93 94 95 aaa93 bbb93 ccccc93
94 95 96 aaa94 bbb94 ccccc94
95 96 97 aaa95 bbb95 ccccc95
96 97 98 aaa96 bbb96 ccccc96
97 98 99 aaa97 bbb97 ccccc97
98 99 100 aaa98 bbb98 ccccc98
99 100 101 aaa99 bbb99 ccccc99
100 101 102 aaa100 bbb100 ccccc100
SELECT * INTO OUTFILE 't_backup' FROM test.t;
TRUNCATE test.t;
SELECT count(*) FROM test.t;
count(*)
0
LOAD DATA INFILE 't_backup' INTO TABLE test.t;
SELECT * FROM test.t order by a;
a b c d e f
1 2 3 aaa1 bbb1 ccccc1
2 3 4 aaa2 bbb2 ccccc2
3 4 5 aaa3 bbb3 ccccc3
4 5 6 aaa4 bbb4 ccccc4
5 6 7 aaa5 bbb5 ccccc5
6 7 8 aaa6 bbb6 ccccc6
7 8 9 aaa7 bbb7 ccccc7
8 9 10 aaa8 bbb8 ccccc8
9 10 11 aaa9 bbb9 ccccc9
10 11 12 aaa10 bbb10 ccccc10
11 12 13 aaa11 bbb11 ccccc11
12 13 14 aaa12 bbb12 ccccc12
13 14 15 aaa13 bbb13 ccccc13
14 15 16 aaa14 bbb14 ccccc14
15 16 17 aaa15 bbb15 ccccc15
16 17 18 aaa16 bbb16 ccccc16
17 18 19 aaa17 bbb17 ccccc17
18 19 20 aaa18 bbb18 ccccc18
19 20 21 aaa19 bbb19 ccccc19
20 21 22 aaa20 bbb20 ccccc20
21 22 23 aaa21 bbb21 ccccc21
22 23 24 aaa22 bbb22 ccccc22
23 24 25 aaa23 bbb23 ccccc23
24 25 26 aaa24 bbb24 ccccc24
25 26 27 aaa25 bbb25 ccccc25
26 27 28 aaa26 bbb26 ccccc26
27 28 29 aaa27 bbb27 ccccc27
28 29 30 aaa28 bbb28 ccccc28
29 30 31 aaa29 bbb29 ccccc29
30 31 32 aaa30 bbb30 ccccc30
31 32 33 aaa31 bbb31 ccccc31
32 33 34 aaa32 bbb32 ccccc32
33 34 35 aaa33 bbb33 ccccc33
34 35 36 aaa34 bbb34 ccccc34
35 36 37 aaa35 bbb35 ccccc35
36 37 38 aaa36 bbb36 ccccc36
37 38 39 aaa37 bbb37 ccccc37
38 39 40 aaa38 bbb38 ccccc38
39 40 41 aaa39 bbb39 ccccc39
40 41 42 aaa40 bbb40 ccccc40
41 42 43 aaa41 bbb41 ccccc41
42 43 44 aaa42 bbb42 ccccc42
43 44 45 aaa43 bbb43 ccccc43
44 45 46 aaa44 bbb44 ccccc44
45 46 47 aaa45 bbb45 ccccc45
46 47 48 aaa46 bbb46 ccccc46
47 48 49 aaa47 bbb47 ccccc47
48 49 50 aaa48 bbb48 ccccc48
49 50 51 aaa49 bbb49 ccccc49
50 51 52 aaa50 bbb50 ccccc50
51 52 53 aaa51 bbb51 ccccc51
52 53 54 aaa52 bbb52 ccccc52
53 54 55 aaa53 bbb53 ccccc53
54 55 56 aaa54 bbb54 ccccc54
55 56 57 aaa55 bbb55 ccccc55
56 57 58 aaa56 bbb56 ccccc56
57 58 59 aaa57 bbb57 ccccc57
58 59 60 aaa58 bbb58 ccccc58
59 60 61 aaa59 bbb59 ccccc59
60 61 62 aaa60 bbb60 ccccc60
61 62 63 aaa61 bbb61 ccccc61
62 63 64 aaa62 bbb62 ccccc62
63 64 65 aaa63 bbb63 ccccc63
64 65 66 aaa64 bbb64 ccccc64
65 66 67 aaa65 bbb65 ccccc65
66 67 68 aaa66 bbb66 ccccc66
67 68 69 aaa67 bbb67 ccccc67
68 69 70 aaa68 bbb68 ccccc68
69 70 71 aaa69 bbb69 ccccc69
70 71 72 aaa70 bbb70 ccccc70
71 72 73 aaa71 bbb71 ccccc71
72 73 74 aaa72 bbb72 ccccc72
73 74 75 aaa73 bbb73 ccccc73
74 75 76 aaa74 bbb74 ccccc74
75 76 77 aaa75 bbb75 ccccc75
76 77 78 aaa76 bbb76 ccccc76
77 78 79 aaa77 bbb77 ccccc77
78 79 80 aaa78 bbb78 ccccc78
79 80 81 aaa79 bbb79 ccccc79
80 81 82 aaa80 bbb80 ccccc80
81 82 83 aaa81 bbb81 ccccc81
82 83 84 aaa82 bbb82 ccccc82
83 84 85 aaa83 bbb83 ccccc83
84 85 86 aaa84 bbb84 ccccc84
85 86 87 aaa85 bbb85 ccccc85
86 87 88 aaa86 bbb86 ccccc86
87 88 89 aaa87 bbb87 ccccc87
88 89 90 aaa88 bbb88 ccccc88
89 90 91 aaa89 bbb89 ccccc89
90 91 92 aaa90 bbb90 ccccc90
91 92 93 aaa91 bbb91 ccccc91
92 93 94 aaa92 bbb92 ccccc92
93 94 95 aaa93 bbb93 ccccc93
94 95 96 aaa94 bbb94 ccccc94
95 96 97 aaa95 bbb95 ccccc95
96 97 98 aaa96 bbb96 ccccc96
97 98 99 aaa97 bbb97 ccccc97
98 99 100 aaa98 bbb98 ccccc98
99 100 101 aaa99 bbb99 ccccc99
100 101 102 aaa100 bbb100 ccccc100
DROP TABLE test.t;
ALTER TABLESPACE ts1
DROP DATAFILE 'datafile_ts1_01.dat'
ENGINE = NDB;
......
......@@ -224,43 +224,44 @@ DROP TABLE t3;
#### BUG 18856 test case comented out
##### Use "SELECT * INTO OUTFILE" to dump data and "LOAD DATA INFILE" to load ##### data back to the data file.
#CREATE TABLE test.t (
# a smallint NOT NULL,
# b int NOT NULL,
# c bigint NOT NULL,
# d char(10),
# e TEXT,
# f VARCHAR(255),
# PRIMARY KEY(a)
#) TABLESPACE ts1 STORAGE DISK ENGINE=NDB;
# ALTER TABLE test.t ADD INDEX (d), ADD INDEX (f);
# SHOW CREATE TABLE test.t;
CREATE TABLE test.t (
a smallint NOT NULL,
b int NOT NULL,
c bigint NOT NULL,
d char(10),
e TEXT,
f VARCHAR(255),
PRIMARY KEY(a)
) TABLESPACE ts1 STORAGE DISK ENGINE=NDB;
ALTER TABLE test.t ADD INDEX (d), ADD INDEX (f);
SHOW CREATE TABLE test.t;
# insert records into tables
# let $1=100;
# disable_query_log;
# while ($1)
# {
# eval insert into test.t values($1, $1+1, $1+2, "aaa$1", "bbb$1", "ccccc$1");
# dec $1;
# }
# enable_query_log;
let $1=100;
disable_query_log;
while ($1)
{
eval insert into test.t values($1, $1+1, $1+2, "aaa$1", "bbb$1", "ccccc$1");
dec $1;
}
enable_query_log;
# SELECT * FROM test.t order by a;
SELECT * FROM test.t order by a;
# SELECT * INTO OUTFILE 't_backup' FROM test.t;
# TRUNCATE test.t;
SELECT * INTO OUTFILE 't_backup' FROM test.t;
TRUNCATE test.t;
#'TRUNCATE test.t' failed: 1205: Lock wait timeout exceeded; try restarting #transaction. TABLESPACE ts STORAGE DISK ENGINE=NDB;
#'TRUNCATE test.t' failed: 1205: Lock wait timeout exceeded; try restarting
#transaction. TABLESPACE ts STORAGE DISK ENGINE=NDB;
# SELECT count(*) FROM test.t;
# LOAD DATA INFILE 't_backup' INTO TABLE test.t;
SELECT count(*) FROM test.t;
LOAD DATA INFILE 't_backup' INTO TABLE test.t;
# SELECT * FROM test.t order by a;
SELECT * FROM test.t order by a;
# DROP TABLE test.t;
DROP TABLE test.t;
ALTER TABLESPACE ts1
......
# Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc
CREATE DATABASE IF NOT EXISTS events_test;
USE events_test;
--echo "We use procedure here because its statements won't be logged into the general log"
--echo "If we had used normal select that are logged in different ways depending on whether"
--echo "the test suite is run in normal mode or with --ps-protocol"
--disable_warnings
drop database if exists events_test;
--enable_warnings
create database if not exists events_test;
use events_test;
--echo
--echo We use procedure here because its statements won't be
--echo logged into the general log. If we had used normal select
--echo that are logged in different ways depending on whether the
--echo test suite is run in normal mode or with --ps-protocol
--echo
delimiter |;
CREATE procedure select_general_log()
BEGIN
SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%';
END|
create procedure select_general_log()
begin
select user_host, argument from mysql.general_log
where argument like '%events_logs_test%';
end|
delimiter ;|
--echo "Check General Query Log"
--echo
--echo Check that general query log works, but sub-statements
--echo of the stored procedure do not leave traces in it.
--echo
truncate mysql.general_log;
# Logging format in ps protocol is slightly different
--disable_ps_protocol
select 'events_logs_tests' as outside_event;
--enable_ps_protocol
--replace_column 1 USER_HOST
CALL select_general_log();
SET GLOBAL event_scheduler=on;
TRUNCATE mysql.general_log;
CREATE EVENT log_general ON SCHEDULE EVERY 1 MINUTE DO SELECT 'alabala', SLEEP(1) FROM DUAL;
--echo "Wait the scheduler to start"
--sleep 1.5
--echo "Should see 2 rows - the 'SELECT' is in the middle. The other two are selects from general_log"
call select_general_log();
--echo
--echo Check that unlike sub-statements of stored procedures,
--echo sub-statements of events are present in the general log.
--echo
set global event_scheduler=on;
truncate mysql.general_log;
create event ev_log_general on schedule at now() on completion not preserve do select 'events_logs_test' as inside_event;
--let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general'
--source include/wait_condition.inc
--replace_column 1 USER_HOST
CALL select_general_log();
DROP PROCEDURE select_general_log;
DROP EVENT log_general;
SET GLOBAL event_scheduler=off;
call select_general_log();
--echo "Check slow query log"
--disable_query_log
DELIMITER |;
CREATE FUNCTION get_value()
returns INT
deterministic
BEGIN
DECLARE var_name CHAR(255);
DECLARE var_val INT;
DECLARE done INT DEFAULT 0;
DECLARE cur1 CURSOR FOR SHOW GLOBAL VARIABLES LIKE 'long_query_time';
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
OPEN cur1;
FETCH cur1 INTO var_name, var_val;
CLOSE cur1;
RETURN var_val;
end|
DELIMITER ;|
--enable_query_log
--echo "Save the values"
SET @old_global_long_query_time:=(select get_value());
SET @old_session_long_query_time:=@@long_query_time;
SHOW VARIABLES LIKE 'log_slow_queries';
DROP FUNCTION get_value;
--echo "Make it quite long"
SET SESSION long_query_time=300;
TRUNCATE mysql.slow_log;
--echo
--echo Check slow query log
--echo
--echo Ensure that slow logging is on
show variables like 'log_slow_queries';
--echo
--echo Demonstrate that session value has no effect
--echo
set @@session.long_query_time=1;
set @@global.long_query_time=300;
truncate mysql.slow_log;
create event ev_log_general on schedule at now() on completion not preserve
do select 'events_logs_test' as inside_event, sleep(1.5);
--let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general'
--source include/wait_condition.inc
--echo
--echo Nothing should be logged
--echo
--replace_column 1 USER_HOST
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
--echo "Set new values"
SET GLOBAL long_query_time=4;
SET SESSION long_query_time=0.5;
--echo "Check that logging is working"
SELECT SLEEP(2);
--replace_column 1 USER_HOST 2 SLEEPVAL
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
SET SESSION long_query_time=300;
--echo "Make it quite long"
TRUNCATE mysql.slow_log;
CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
SET SESSION long_query_time=1;
--echo "This won't go to the slow log"
SELECT * FROM slow_event_test;
SET SESSION long_query_time=1;
SET GLOBAL event_scheduler=on;
SET GLOBAL long_query_time=20;
CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(1.5);
--echo "Sleep some more time than the actual event run will take"
--sleep 2
SHOW VARIABLES LIKE 'event_scheduler';
--echo "Check our table. Should see 1 row"
SELECT * FROM slow_event_test;
--echo "Check slow log. Should not see anything because 1.5 is under the threshold of 20 for GLOBAL, though over SESSION which is 1"
--echo "This should show that the GLOBAL value is regarded and not the SESSION one of the current connection"
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
--echo "Another test to show that GLOBAL is regarded and not SESSION."
--echo "This should go to the slow log"
SET SESSION long_query_time=10;
DROP EVENT long_event;
SET GLOBAL long_query_time=1;
CREATE EVENT long_event2 ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(2);
--echo "Sleep some more time than the actual event run will take"
let $wait_timeout= 30;
let $wait_condition= SELECT COUNT(*) = 1 FROM mysql.slow_log;
select user_host, db, sql_text from mysql.slow_log where sql_text not like 'create event%';
set @@global.long_query_time=1;
truncate mysql.slow_log;
create event ev_log_general on schedule at now() on completion not preserve
do select 'events_logs_test' as inside_event, sleep(1.5);
--let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general'
--source include/wait_condition.inc
--echo "Check our table. Should see 2 rows"
SELECT * FROM slow_event_test;
--echo "Check slow log. Should see 1 row because 2 is over the threshold of 1 for GLOBAL, though under SESSION which is 10"
--replace_column 1 USER_HOST 2 SLEEPVAL
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
DROP EVENT long_event2;
--echo "Make it quite long"
SET SESSION long_query_time=300;
TRUNCATE mysql.slow_log;
DROP TABLE slow_event_test;
SET GLOBAL long_query_time =@old_global_long_query_time;
SET SESSION long_query_time =@old_session_long_query_time;
DROP DATABASE events_test;
--echo
--echo Event sub-statement should be logged.
--echo
--replace_column 1 USER_HOST
select user_host, db, sql_text from mysql.slow_log where sql_text not like 'create event%';
SET GLOBAL event_scheduler=off;
drop database events_test;
set global event_scheduler=off;
set @@global.long_query_time=default;
set @@session.long_query_time=default;
#
# Safety
#
let $wait_condition=
select count(*) = 0 from information_schema.processlist
where db='events_test' and command = 'Connect' and user=current_user();
......
......@@ -16,10 +16,16 @@ lock tables t1 write;
connection writer;
send update low_priority t1 set n = 4;
connection reader;
--sleep 2
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "update low_priority t1 set n = 4";
--source include/wait_condition.inc
send select n from t1;
connection locker;
--sleep 2
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "select n from t1";
--source include/wait_condition.inc
unlock tables;
connection writer;
reap;
......@@ -34,15 +40,15 @@ lock tables t1 read;
connection writer;
send update low_priority t1 set n = 4;
connection reader;
--sleep 2
send select n from t1;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "update low_priority t1 set n = 4";
--source include/wait_condition.inc
select n from t1;
connection locker;
--sleep 2
unlock tables;
connection writer;
reap;
connection reader;
reap;
drop table t1;
#
......@@ -58,13 +64,9 @@ insert into t1 values(2,2);
insert into t2 values(1,2);
lock table t1 read;
connection writer;
--sleep 2
send update t1,t2 set c=a where b=d;
update t1,t2 set c=a where b=d;
connection reader;
--sleep 2
select c from t2;
connection writer;
reap;
connection locker;
drop table t1;
drop table t2;
......@@ -73,7 +75,7 @@ drop table t2;
# Test problem when using locks on many tables and droping a table that
# is to-be-locked by another thread
#
#
connection locker;
create table t1 (a int);
create table t2 (a int);
......@@ -81,6 +83,10 @@ lock table t1 write, t2 write;
connection reader;
send insert t1 select * from t2;
connection locker;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "insert t1 select * from t2";
--source include/wait_condition.inc
drop table t2;
connection reader;
--error 1146
......@@ -99,6 +105,10 @@ lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
connection reader;
send insert t1 select * from t2;
connection locker;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "insert t1 select * from t2";
--source include/wait_condition.inc
drop table t2;
connection reader;
--error 1146
......@@ -107,7 +117,7 @@ connection locker;
drop table t1;
# End of 4.1 tests
--echo End of 4.1 tests
#
# BUG#9998 - MySQL client hangs on USE "database"
......@@ -131,15 +141,18 @@ connection locker;
use mysql;
LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
FLUSH TABLES;
--sleep 1
#
connection reader;
use mysql;
#NOTE: This must be a multi-table select, otherwise the deadlock will not occur
send SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
--sleep 1
#
connection locker;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info =
"SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1";
--source include/wait_condition.inc
# Make test case independent from earlier grants.
--replace_result "Table is already up to date" "OK"
OPTIMIZE TABLES columns_priv, db, host, user;
......@@ -163,10 +176,13 @@ LOCK TABLE t1 WRITE;
# This waits until t1 is unlocked.
connection locker;
send FLUSH TABLES WITH READ LOCK;
--sleep 1
#
# This must not block.
connection writer;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
--source include/wait_condition.inc
# This must not block.
CREATE TABLE t2 (c1 int);
UNLOCK TABLES;
#
......@@ -187,10 +203,13 @@ LOCK TABLE t1 WRITE;
# This waits until t1 is unlocked.
connection locker;
send FLUSH TABLES WITH READ LOCK;
--sleep 1
#
# This must not block.
connection writer;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Flushing tables" and info = "FLUSH TABLES WITH READ LOCK";
--source include/wait_condition.inc
--error 1100
CREATE TABLE t2 AS SELECT * FROM t1;
UNLOCK TABLES;
......@@ -219,11 +238,15 @@ FLUSH TABLES WITH READ LOCK;
# wait in wait_if_global_read_lock().
connection con2;
send DROP DATABASE mysqltest_1;
--sleep 1
#
# With bug in place: try to acquire LOCK_mysql_create_table...
# When fixed: Reject dropping db because of the read lock.
connection con1;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for release of readlock"
and info = "DROP DATABASE mysqltest_1";
--source include/wait_condition.inc
--error ER_CANT_UPDATE_WITH_READLOCK
DROP DATABASE mysqltest_1;
UNLOCK TABLES;
......@@ -249,17 +272,18 @@ create table t1 (f1 int(12) unsigned not null auto_increment, primary key(f1)) e
--enable_warnings
lock tables t1 write;
connection writer;
--sleep 2
delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;//
send alter table t1 auto_increment=0;
connection reader;
--sleep 2
delimiter //;
send alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; alter table t1 auto_increment=0; //
delimiter ;//
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Locked" and info = "alter table t1 auto_increment=0";
--source include/wait_condition.inc
send alter table t1 auto_increment=0;
connection locker;
--sleep 2
let $wait_condition=
select count(*) = 2 from information_schema.processlist
where state = "Locked" and info = "alter table t1 auto_increment=0";
--source include/wait_condition.inc
unlock tables;
connection writer;
reap;
......@@ -267,8 +291,8 @@ connection reader;
reap;
connection locker;
drop table t1;
# End of 5.0 tests
#
--echo End of 5.0 tests
#
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment