Debian Codegraph @

mysql-test/suite/sys_vars/t/log_slow_admin_statements_func.test

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