2019-08-30 15:06:54 +02:00
|
|
|
set @save_long_query_time=@@long_query_time;
|
2007-08-10 23:11:56 +02:00
|
|
|
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();
|
2006-03-02 23:40:51 +01:00
|
|
|
user_host argument
|
2007-08-10 23:11:56 +02:00
|
|
|
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();
|
2006-03-02 23:40:51 +01:00
|
|
|
user_host argument
|
2007-08-10 23:11:56 +02:00
|
|
|
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
|
2013-08-13 13:35:36 +02:00
|
|
|
show variables like 'slow_query_log';
|
2006-03-01 02:34:22 +01:00
|
|
|
Variable_name Value
|
2013-08-13 13:35:36 +02:00
|
|
|
slow_query_log ON
|
2007-08-10 23:11:56 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2007-09-05 20:14:43 +02:00
|
|
|
select user_host, db, sql_text from mysql.slow_log
|
|
|
|
where sql_text like 'select \'events_logs_test\'%';
|
2007-08-10 23:11:56 +02:00
|
|
|
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.
|
|
|
|
|
2007-09-05 20:14:43 +02:00
|
|
|
select user_host, db, sql_text from mysql.slow_log
|
|
|
|
where sql_text like 'select \'events_logs_test\'%';
|
2007-08-10 23:11:56 +02:00
|
|
|
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;
|
2019-08-30 15:06:54 +02:00
|
|
|
set @@global.long_query_time=@save_long_query_time;
|
|
|
|
set @@session.long_query_time=@save_long_query_time;
|