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
###############################################################################
8
SET @@session.long_query_time=1;
10
SET @@global.log_output = 'TABLE';
12
#=========================================
13
--echo '----When slow_query_log = OFF----'
14
#=========================================
16
SET @@global.slow_query_log = OFF;
17
TRUNCATE mysql.slow_log;
18
# The sleep is the slow query
21
SELECT count(*) FROM mysql.slow_log;
23
#=========================================
24
--echo '----When slow_query_log = ON-----'
25
#=========================================
27
SET @@global.slow_query_log = ON;
28
TRUNCATE mysql.slow_log;
29
# The sleep is the slow query
32
SELECT count(*) > 0 FROM mysql.slow_log;
35
#==========================================================================
36
--echo 'Bug#47905 stored procedures not logged correctly to slow query log'
37
#==========================================================================
38
# assumes logging to table turned on with long_query_time=1 as above
40
TRUNCATE mysql.slow_log;
43
CREATE PROCEDURE p_test()
51
SELECT count(*) > 0 FROM mysql.slow_log;
52
DROP PROCEDURE p_test;
54
#==============================================================================
55
--echo Bug53191 Lock_time in slow log is negative when logging stored routines
56
#==============================================================================
57
TRUNCATE mysql.slow_log;
58
connect (con2,localhost,root,,);
61
CREATE TABLE t1 (c0 INT PRIMARY KEY AUTO_INCREMENT, c1 TIMESTAMP, c2 TIMESTAMP);
63
CREATE FUNCTION f_slow_now() RETURNS TIMESTAMP
69
CREATE FUNCTION f_slow_current_time() RETURNS TIME
72
RETURN CURRENT_TIME();
76
INSERT INTO t1 (c1,c2) VALUES (now(), f_slow_now())//
78
CREATE TRIGGER tf_before BEFORE INSERT ON t1
80
SET new.c2 = f_slow_now();
85
INSERT INTO t1 (c1,c2) values (now(),now());
87
INSERT INTO t1 (c1,c2) values (now(),now());
92
INSERT INTO t1 (c1,c2) VALUES (now(), now());
96
--echo *** There shouldn't less than 1 s difference between each row
97
SELECT t1.c1-self.c1 > 1 FROM t1, t1 as self WHERE t1.c0=self.c0+1 ORDER BY t1.c0;
99
DROP TRIGGER tf_before;
100
DROP FUNCTION f_slow_now;
101
DROP FUNCTION f_slow_current_time;
104
DROP TABLE IF EXISTS t1;
105
CREATE TABLE t1(c1 INT) ENGINE=MyISAM;
106
DROP PROCEDURE IF EXISTS p1;
108
CREATE PROCEDURE p1()
110
INSERT INTO t1 VALUES (1);
111
SELECT COUNT(*) FROM t1 WHERE c1= 1;
112
UPDATE t1 SET c1=c1*2;
120
--echo Back to default connection
124
--echo Wait three seconds and unlock the table
131
--echo **** 1 == we have slow log entries
132
SELECT count(*) > 0 FROM mysql.slow_log;
133
--echo **** 0 == None of the entries have a lock time greater than 10 s
134
SELECT count(*) FROM mysql.slow_log WHERE lock_time > 10;
140
#================================================================== Restore
141
SET @@global.log_output = @global_log_output;
142
SET @global.slow_query_log = @global_slow_query_log;
144
###############################################################################
145
# End of the functionality test for slow_query_log #
146
###############################################################################