diff options
Diffstat (limited to 'mysql-test/t/log_tables.test')
-rw-r--r-- | mysql-test/t/log_tables.test | 87 |
1 files changed, 74 insertions, 13 deletions
diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index 3047d16d3b6..bdd22538c14 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -10,6 +10,21 @@ --disable_ps_protocol use mysql; +# Capture initial settings of system variables +# so that we can revert to old state after manipulation for testing +# NOTE: PLEASE USE THESE VALUES TO 'RESET' SYSTEM VARIABLES +# Capturing old values within the tests results in loss of values +# due to people not paying attention to previous tests' changes, captures +# or improper cleanup +SET @saved_long_query_time = @@long_query_time; +SET @saved_log_output = @@log_output; +SET @saved_general_log = @@GLOBAL.general_log; +SET @saved_slow_query_log = @@GLOBAL.slow_query_log; + +SELECT @saved_long_query_time, @saved_log_output, @saved_general_log, @saved_slow_query_log; + + + # # Check that log tables work and we can do basic selects. This also # tests truncate, which works in a special mode with the log tables @@ -161,6 +176,7 @@ set session long_query_time=1; select sleep(2); --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME select * from mysql.slow_log; +set @@session.long_query_time = @saved_long_query_time; # # Bug #18559 log tables cannot change engine, and gets deadlocked when @@ -305,6 +321,7 @@ unlock tables; # Bug #21785 Server crashes after rename of the log table # +SET SESSION long_query_time = 1000; --disable_warnings drop table if exists mysql.renamed_general_log; drop table if exists mysql.renamed_slow_log; @@ -365,6 +382,7 @@ set global slow_query_log='ON'; RENAME TABLE general_log2 TO general_log; RENAME TABLE slow_log2 TO slow_log; +SET SESSION long_query_time = @saved_long_query_time; # this should work set global general_log='ON'; @@ -476,8 +494,6 @@ ALTER TABLE mysql.general_log ENGINE = CSV; ## test the slow query log -SET @old_long_query_time:=@@long_query_time; - SET GLOBAL slow_query_log = 0; FLUSH LOGS; @@ -503,12 +519,14 @@ SELECT "My own slow query", sleep(2); SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3; SET GLOBAL slow_query_log = 0; -SET SESSION long_query_time =@old_long_query_time; +SET SESSION long_query_time =@saved_long_query_time; FLUSH LOGS; ALTER TABLE mysql.slow_log DROP COLUMN seq; ALTER TABLE mysql.slow_log ENGINE = CSV; +SET GLOBAL slow_query_log = @saved_slow_query_log; + # # Bug#25422 (Hang with log tables) # @@ -790,9 +808,6 @@ END // DELIMITER ;// -SET @old_general_log_state = @@global.general_log; -SET @old_slow_log_state = @@global.slow_query_log; - SET GLOBAL general_log = ON; SET GLOBAL slow_query_log = ON; @@ -814,8 +829,8 @@ DROP PROCEDURE IF EXISTS `db_17876.archiveSlowLog`; DROP PROCEDURE IF EXISTS `db_17876.archiveGeneralLog`; DROP DATABASE IF EXISTS `db_17876`; -SET GLOBAL general_log = @old_general_log_state; -SET GLOBAL slow_query_log = @old_slow_log_state; +SET GLOBAL general_log = @saved_general_log; +SET GLOBAL slow_query_log = @saved_slow_query_log; # # Bug#21557 entries in the general query log truncated at 1000 characters. @@ -823,7 +838,6 @@ SET GLOBAL slow_query_log = @old_slow_log_state; select CONNECTION_ID() into @thread_id; truncate table mysql.general_log; -set @old_general_log_state = @@global.general_log; set global general_log = on; --disable_result_log set @lparam = "000 001 002 003 004 005 006 007 008 009" @@ -934,12 +948,54 @@ execute long_query using @lparam; set global general_log = off; select command_type, argument from mysql.general_log where thread_id = @thread_id; deallocate prepare long_query; -set global general_log = @old_general_log_state; +set global general_log = @saved_general_log; + +# +# Bug#34306: Can't make copy of log tables when server binary log is enabled +# + +--disable_warnings +DROP TABLE IF EXISTS log_count; +DROP TABLE IF EXISTS slow_log_copy; +DROP TABLE IF EXISTS general_log_copy; +--enable_warnings + +CREATE TABLE log_count (count BIGINT(21)); + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; + +CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log)); +DROP TABLE slow_log_copy; + +CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); +DROP TABLE general_log_copy; + +SET GLOBAL general_log = OFF; +SET GLOBAL slow_query_log = OFF; + +CREATE TABLE slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO slow_log_copy SELECT * FROM mysql.slow_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.slow_log)); +DROP TABLE slow_log_copy; + +CREATE TABLE general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO general_log_copy SELECT * FROM mysql.general_log; +INSERT INTO log_count (count) VALUES ((SELECT count(*) FROM mysql.general_log)); +DROP TABLE general_log_copy; + +SET GLOBAL general_log = @saved_general_log; +SET GLOBAL slow_query_log = @saved_slow_query_log; + +DROP TABLE log_count; # # Bug #31700: thd->examined_row_count not incremented for 'const' type queries # -SET @old_slow_log_state = @@global.slow_query_log; SET SESSION long_query_time = 0; SET GLOBAL slow_query_log = ON; @@ -964,5 +1020,10 @@ DROP TABLE t1; TRUNCATE TABLE mysql.slow_log; -SET GLOBAL slow_query_log = @old_slow_log_state; -SET SESSION long_query_time =@old_long_query_time; +# RESET altered system variables before exiting the test +SET GLOBAL slow_query_log = @saved_slow_query_log; +SET GLOBAL general_log=@saved_general_log; +SET SESSION long_query_time =@saved_long_query_time; +SET GLOBAL LOG_OUTPUT = @saved_log_output; + + |