| 1 |
# save |
| 2 |
SET @global_slow_query_log = @@global.slow_query_log; |
| 3 |
SET @global_log_output = @@global.log_output; |
| 4 |
############################################################################### |
| 5 |
# Begin the functionality testing for slow_query_log # |
| 6 |
############################################################################### |
| 7 |
|
| 8 |
SET @@session.long_query_time=1; |
| 9 |
|
| 10 |
SET @@global.log_output = 'TABLE'; |
| 11 |
|
| 12 |
#========================================= |
| 13 |
--echo '----When slow_query_log = OFF----' |
| 14 |
#========================================= |
| 15 |
|
| 16 |
SET @@global.slow_query_log = OFF; |
| 17 |
TRUNCATE mysql.slow_log; |
| 18 |
# The sleep is the slow query |
| 19 |
SELECT sleep(2); |
| 20 |
|
| 21 |
SELECT count(*) FROM mysql.slow_log; |
| 22 |
|
| 23 |
#========================================= |
| 24 |
--echo '----When slow_query_log = ON-----' |
| 25 |
#========================================= |
| 26 |
|
| 27 |
SET @@global.slow_query_log = ON; |
| 28 |
TRUNCATE mysql.slow_log; |
| 29 |
# The sleep is the slow query |
| 30 |
SELECT sleep(2) AS bug53630; |
| 31 |
|
| 32 |
SELECT count(*) > 0 FROM mysql.slow_log WHERE sql_text LIKE '% bug53630'; |
| 33 |
SELECT thread_id - connection_id() FROM mysql.slow_log |
| 34 |
WHERE sql_text LIKE '% bug53630' |
| 35 |
ORDER BY start_time DESC LIMIT 1; |
| 36 |
|
| 37 |
#========================================================================== |
| 38 |
--echo 'Bug#47905 stored procedures not logged correctly to slow query log' |
| 39 |
#========================================================================== |
| 40 |
# assumes logging to table turned on with long_query_time=1 as above |
| 41 |
|
| 42 |
TRUNCATE mysql.slow_log; |
| 43 |
|
| 44 |
DELIMITER //; |
| 45 |
CREATE PROCEDURE p_test() |
| 46 |
BEGIN |
| 47 |
select sleep(2); |
| 48 |
select 1; |
| 49 |
END// |
| 50 |
DELIMITER ;// |
| 51 |
|
| 52 |
CALL p_test(); |
| 53 |
SELECT count(*) > 0 FROM mysql.slow_log; |
| 54 |
DROP PROCEDURE p_test; |
| 55 |
|
| 56 |
SET sql_mode = default; |
| 57 |
|
| 58 |
|
| 59 |
#================================================================== Restore |
| 60 |
SET @@global.log_output = @global_log_output; |
| 61 |
SET @global.slow_query_log = @global_slow_query_log; |
| 62 |
TRUNCATE TABLE mysql.general_log; |
| 63 |
TRUNCATE TABLE mysql.slow_log; |
| 64 |
############################################################################### |
| 65 |
# End of the functionality test for slow_query_log # |
| 66 |
############################################################################### |
| 67 |
|