| 1 |
--source include/no_valgrind_without_big.inc |
| 2 |
|
| 3 |
SET @old_log_output= @@global.log_output; |
| 4 |
SET @old_slow_query_log= @@global.slow_query_log; |
| 5 |
SET @old_long_query_time= @@session.long_query_time; |
| 6 |
SET @old_log_slow_admin_statements= @@global.log_slow_admin_statements; |
| 7 |
|
| 8 |
USE test; |
| 9 |
CREATE TABLE log_slow_admin_statements ( |
| 10 |
i INT PRIMARY KEY AUTO_INCREMENT, |
| 11 |
j VARCHAR(255) |
| 12 |
) ENGINE=InnoDB; |
| 13 |
|
| 14 |
# enable slow logging to table |
| 15 |
SET GLOBAL log_output = 'file,table'; |
| 16 |
SET GLOBAL slow_query_log = on; |
| 17 |
SET SESSION long_query_time = 0; |
| 18 |
SET GLOBAL log_slow_admin_statements = off; |
| 19 |
|
| 20 |
# test ALTER, OPTIMIZE and CHECK against the table shown up |
| 21 |
ALTER TABLE log_slow_admin_statements ADD COLUMN k INT DEFAULT 17; |
| 22 |
|
| 23 |
# add rows so OPTIMIZE and CHECK runs |
| 24 |
DELIMITER $; |
| 25 |
|
| 26 |
CREATE PROCEDURE add_rows() |
| 27 |
BEGIN |
| 28 |
DECLARE count INT; |
| 29 |
SET count = 1; |
| 30 |
INSERT INTO log_slow_admin_statements(j) values (REPEAT('A', 255)); |
| 31 |
WHILE count <= 15 DO |
| 32 |
INSERT INTO log_slow_admin_statements(j) SELECT j FROM log_slow_admin_statements; |
| 33 |
SET count = count + 1; |
| 34 |
END WHILE; |
| 35 |
END |
| 36 |
$ |
| 37 |
|
| 38 |
DELIMITER ;$ |
| 39 |
|
| 40 |
CALL add_rows(); |
| 41 |
|
| 42 |
ANALYZE TABLE log_slow_admin_statements; |
| 43 |
OPTIMIZE TABLE log_slow_admin_statements; |
| 44 |
CHECK TABLE log_slow_admin_statements EXTENDED; |
| 45 |
|
| 46 |
echo Administrative sql statements must not be logged; |
| 47 |
SELECT count(sql_text)= 0 FROM mysql.slow_log |
| 48 |
WHERE sql_text LIKE '%TABLE log_slow_admin_statements%'; |
| 49 |
# SELECT sql_text FROM mysql.slow_log WHERE sql_text LIKE '%TABLE log_slow_admin_statements%'; |
| 50 |
|
| 51 |
SET GLOBAL log_slow_admin_statements = on; |
| 52 |
|
| 53 |
DROP TABLE log_slow_admin_statements; |
| 54 |
CREATE TABLE log_slow_admin_statements ( |
| 55 |
i INT PRIMARY KEY AUTO_INCREMENT, |
| 56 |
j VARCHAR(255) |
| 57 |
) ENGINE=InnoDB; |
| 58 |
|
| 59 |
# ALTER, OPTIMIZE, CHECK and DROP operations should be logged in slow query log. |
| 60 |
CALL add_rows(); |
| 61 |
|
| 62 |
ANALYZE TABLE log_slow_admin_statements; |
| 63 |
OPTIMIZE TABLE log_slow_admin_statements; |
| 64 |
CHECK TABLE log_slow_admin_statements EXTENDED; |
| 65 |
|
| 66 |
echo At least one administrativ sql statement must be logged in slow query log; |
| 67 |
SELECT count(sql_text)> 0 FROM mysql.slow_log |
| 68 |
WHERE sql_text LIKE '%TABLE log_slow_admin_statements%'; |
| 69 |
|
| 70 |
SET @@global.log_output= @old_log_output; |
| 71 |
SET @@global.slow_query_log= @old_slow_query_log; |
| 72 |
SET @@session.long_query_time= @old_long_query_time; |
| 73 |
SET @@global.log_slow_admin_statements= @old_log_slow_admin_statements; |
| 74 |
|
| 75 |
DROP PROCEDURE add_rows; |
| 76 |
DROP TABLE log_slow_admin_statements; |
| 77 |
TRUNCATE TABLE mysql.slow_log; |
| 78 |
TRUNCATE TABLE mysql.general_log; |