blob: 35b5b93423d5d540d75a660ff02f424ccb6800f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
-- source include/have_debug.inc
SET @org_slow_query_log= @@global.slow_query_log;
SET @org_log_output= @@global.log_output;
SET @org_log_slow_admin_statements= @@global.log_slow_admin_statements;
SET @@GLOBAL.slow_query_log=OFF;
SET @@GLOBAL.log_output='TABLE';
FLUSH SLOW LOGS;
SET @@GLOBAL.slow_query_log=ON;
SET @@GLOBAL.log_slow_admin_statements=ON;
SET SESSION debug_dbug="+d,simulate_slow_query";
DELIMITER $$;
CREATE PROCEDURE show_slow_log()
BEGIN
SELECT CONCAT('[slow] ', sql_text) AS sql_text
FROM mysql.slow_log
WHERE sql_text NOT LIKE '%debug_dbug%';
END
$$
DELIMITER ;$$
--echo #
--echo # Expect all admin statements in the slow log (ON,DEFAULT)
--echo #
SET @@GLOBAL.log_slow_admin_statements=ON;
SET log_slow_filter=DEFAULT;
TRUNCATE TABLE mysql.slow_log;
CREATE TABLE t1 (a INT);
CREATE INDEX t1a ON t1 (a);
DROP INDEX t1a ON t1;
DROP TABLE t1;
CREATE TABLE t2 (a INT);
ALTER TABLE t2 RENAME t2;
RENAME TABLE t2 TO t3;
DROP TABLE t3;
CREATE TABLE t4 (a INT);
PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1';
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t4;
CALL show_slow_log();
--echo #
--echo # Expect all admin statements in the slow log (ON,admin)
--echo #
SET @@GLOBAL.log_slow_admin_statements=ON;
SET log_slow_filter=admin;
TRUNCATE TABLE mysql.slow_log;
CREATE TABLE t1 (a INT);
CREATE INDEX t1a ON t1 (a);
DROP INDEX t1a ON t1;
DROP TABLE t1;
CREATE TABLE t2 (a INT);
ALTER TABLE t2 RENAME t2;
RENAME TABLE t2 TO t3;
DROP TABLE t3;
CREATE TABLE t4 (a INT);
PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1';
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t4;
CALL show_slow_log();
--echo #
--echo # Expect none of admin DDL statements in the slow log (ON,filesort)
--echo #
SET @@GLOBAL.log_slow_admin_statements=ON;
SET log_slow_filter=filesort;
TRUNCATE TABLE mysql.slow_log;
CREATE TABLE t1 (a INT);
CREATE INDEX t1a ON t1 (a);
DROP INDEX t1a ON t1;
DROP TABLE t1;
CREATE TABLE t2 (a INT);
ALTER TABLE t2 RENAME t2;
RENAME TABLE t2 TO t3;
DROP TABLE t3;
CREATE TABLE t4 (a INT);
PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1';
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t4;
CALL show_slow_log();
--echo #
--echo # Expect none of admin statements in the slow log (OFF,DEFAULT)
--echo #
SET @@GLOBAL.log_slow_admin_statements=OFF;
SET log_slow_filter=DEFAULT;
TRUNCATE TABLE mysql.slow_log;
CREATE TABLE t1 (a INT);
CREATE INDEX t1a ON t1 (a);
DROP INDEX t1a ON t1;
DROP TABLE t1;
CREATE TABLE t2 (a INT);
ALTER TABLE t2 RENAME t2;
RENAME TABLE t2 TO t3;
DROP TABLE t3;
CREATE TABLE t4 (a INT);
PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1';
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t4;
CALL show_slow_log();
--echo #
--echo # Clean up
--echo #
SET SESSION debug_dbug="-d,simulate_slow_query";
TRUNCATE mysql.slow_log;
SET @@global.slow_query_log= @org_slow_query_log;
SET @@global.log_output= @org_log_output;
SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements;
DROP PROCEDURE show_slow_log;
|