events_logs_tests.result 3.89 KB
Newer Older
1 2
CREATE DATABASE IF NOT EXISTS events_test;
USE events_test;
andrey@lmy004's avatar
andrey@lmy004 committed
3 4 5 6 7 8 9
"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|
10
"Check General Query Log"
11
CALL select_general_log();
andrey@lmy004's avatar
andrey@lmy004 committed
12
user_host	argument
13 14 15 16
USER_HOST	CREATE procedure select_general_log()
BEGIN
SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%';
END
17
SET GLOBAL event_scheduler=on;
18 19
TRUNCATE mysql.general_log;
CREATE EVENT log_general ON SCHEDULE EVERY 1 MINUTE DO SELECT 'alabala', SLEEP(1) FROM DUAL;
20
"Wait the scheduler to start"
21 22
"Should see 2 rows - the 'SELECT' is in the middle. The other two are selects from general_log"
CALL select_general_log();
andrey@lmy004's avatar
andrey@lmy004 committed
23
user_host	argument
24 25
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
andrey@lmy004's avatar
andrey@lmy004 committed
26
DROP PROCEDURE select_general_log;
27
DROP EVENT log_general;
28
SET GLOBAL event_scheduler=off;
29
"Check slow query log"
andrey@lmy004's avatar
andrey@lmy004 committed
30 31 32 33 34 35 36
"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';
Variable_name	Value
log_slow_queries	ON
DROP FUNCTION get_value;
37 38
"Make it quite long"
SET SESSION long_query_time=300;
andrey@lmy004's avatar
andrey@lmy004 committed
39 40 41 42 43
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;
44
SET SESSION long_query_time=1;
andrey@lmy004's avatar
andrey@lmy004 committed
45
"Check that logging is working"
46 47
SELECT SLEEP(2);
SLEEP(2)
andrey@lmy004's avatar
andrey@lmy004 committed
48 49 50
0
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host	query_time	db	sql_text
51
USER_HOST	SLEEPVAL	events_test	SELECT SLEEP(2)
52 53
SET SESSION long_query_time=300;
"Make it quite long"
andrey@lmy004's avatar
andrey@lmy004 committed
54 55
TRUNCATE mysql.slow_log;
CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
56
SET SESSION long_query_time=1;
andrey@lmy004's avatar
andrey@lmy004 committed
57 58 59
"This won't go to the slow log"
SELECT * FROM slow_event_test;
slo_val	val
60
SET SESSION long_query_time=1;
61
SET GLOBAL event_scheduler=on;
62
SET GLOBAL long_query_time=20;
63
CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(1.5);
andrey@lmy004's avatar
andrey@lmy004 committed
64
"Sleep some more time than the actual event run will take"
65 66
SHOW VARIABLES LIKE 'event_scheduler';
Variable_name	Value
67
event_scheduler	ON
andrey@lmy004's avatar
andrey@lmy004 committed
68 69 70
"Check our table. Should see 1 row"
SELECT * FROM slow_event_test;
slo_val	val
71 72 73
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"
andrey@lmy004's avatar
andrey@lmy004 committed
74 75
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host	query_time	db	sql_text
76
"Another test to show that GLOBAL is regarded and not SESSION."
andrey@lmy004's avatar
andrey@lmy004 committed
77 78
"This should go to the slow log"
SET SESSION long_query_time=10;
79
DROP EVENT long_event;
80 81
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);
andrey@lmy004's avatar
andrey@lmy004 committed
82 83 84 85
"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
86
20	0
87 88
1	0
"Check slow log. Should see 1 row because 4 is over the threshold of 3 for GLOBAL, though under SESSION which is 10"
andrey@lmy004's avatar
andrey@lmy004 committed
89 90
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host	query_time	db	sql_text
91
USER_HOST	SLEEPVAL	events_test	INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(2)
92
DROP EVENT long_event2;
93 94
"Make it quite long"
SET SESSION long_query_time=300;
andrey@lmy004's avatar
andrey@lmy004 committed
95 96
TRUNCATE mysql.slow_log;
DROP TABLE slow_event_test;
97 98
SET GLOBAL  long_query_time =@old_global_long_query_time;
SET SESSION long_query_time =@old_session_long_query_time;
99
DROP DATABASE events_test;
100
SET GLOBAL event_scheduler=off;