Commit 3c8432a7 authored by unknown's avatar unknown
Browse files

Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into lmy004.:/work/mysql-5.1-bug17494

parents 3aeea1bb d576ca18
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
create database if not exists events_test;
use events_test;
"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;
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=2;
"Check that logging is working"
SELECT SLEEP(3);
SLEEP(3)
0
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host	query_time	db	sql_text
root[root] @ localhost []	00:00:03	events_test	SELECT SLEEP(3)
TRUNCATE mysql.slow_log;
CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
"This won't go to the slow log"
CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(3);
SELECT * FROM slow_event_test;
slo_val	val
SET GLOBAL event_scheduler=1;
"Sleep some more time than the actual event run will take"
"Check our table. Should see 1 row"
SELECT * FROM slow_event_test;
slo_val	val
4	0
"Check slow log. Should not see anything because 3 is under the threshold of 4 for GLOBAL, though over SESSION which is 2"
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host	query_time	db	sql_text
"This should go to the slow log"
SET SESSION long_query_time=10;
ALTER EVENT long_event DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(5);
"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
4	0
4	0
"Check slow log. Should see 1 row because 5 is over the threshold of 4 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
root[root] @ localhost [localhost]	00:00:05	events_test	INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(5)
DROP EVENT long_event;
SET GLOBAL  long_query_time =@old_global_long_query_time;
SET SESSION long_query_time =@old_session_long_query_time;
TRUNCATE mysql.slow_log;
DROP TABLE slow_event_test;
drop database events_test;
+1 −0
Original line number Diff line number Diff line
--log-slow-queries
+62 −0
Original line number Diff line number Diff line
create database if not exists events_test;
use events_test;

--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;
TRUNCATE mysql.slow_log;
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=2;
--echo "Check that logging is working"
SELECT SLEEP(3);
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
TRUNCATE mysql.slow_log;
CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
--echo "This won't go to the slow log"
CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(3);
SELECT * FROM slow_event_test;
SET GLOBAL event_scheduler=1;
--echo "Sleep some more time than the actual event run will take"
--sleep 5
--echo "Check our table. Should see 1 row"
SELECT * FROM slow_event_test;
--echo "Check slow log. Should not see anything because 3 is under the threshold of 4 for GLOBAL, though over SESSION which is 2"
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
--echo "This should go to the slow log"
SET SESSION long_query_time=10;
ALTER EVENT long_event DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(5);
--echo "Sleep some more time than the actual event run will take"
--sleep 7
--echo "Check our table. Should see 2 rows"
SELECT * FROM slow_event_test;
--echo "Check slow log. Should see 1 row because 5 is over the threshold of 4 for GLOBAL, though under SESSION which is 10"
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
DROP EVENT long_event;
SET GLOBAL  long_query_time =@old_global_long_query_time;
SET SESSION long_query_time =@old_session_long_query_time; 
TRUNCATE mysql.slow_log;
DROP TABLE slow_event_test;

drop database events_test;
+2 −1
Original line number Diff line number Diff line
@@ -273,7 +273,7 @@ init_event_thread(THD* thd)
  my_net_init(&thd->net, 0);
  thd->net.read_timeout = slave_net_timeout;
  thd->slave_thread= 0;
  thd->options= OPTION_AUTO_IS_NULL;
  thd->options|= OPTION_AUTO_IS_NULL;
  thd->client_capabilities= CLIENT_LOCAL_FILES;
  thd->real_id=pthread_self();
  VOID(pthread_mutex_lock(&LOCK_thread_count));
@@ -708,6 +708,7 @@ event_executor_worker(void *event_void)
  thd= current_thd;
#endif

  thd->enable_slow_log= TRUE;
  {
    int ret;
    sql_print_information("SCHEDULER: Executing event %s.%s of %s [EXPR:%d]",
+2 −0
Original line number Diff line number Diff line
@@ -1162,6 +1162,8 @@ Event_timed::execute(THD *thd, MEM_ROOT *mem_root)
  {
    List<Item> empty_item_list;
    empty_item_list.empty();
    if (thd->enable_slow_log)
      sphead->m_flags|= sp_head::LOG_SLOW_STATEMENTS;
    ret= sphead->execute_procedure(thd, &empty_item_list);
  }
  else
Loading