fix(util): refs #7205 fix util.slowLog_prune #2293
|
@ -6,11 +6,19 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log;
|
DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log;
|
||||||
DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin;
|
DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin;
|
||||||
|
DECLARE vLogExists BOOL;
|
||||||
|
|
||||||
SET sql_log_bin = OFF;
|
SET sql_log_bin = OFF;
|
||||||
SET GLOBAL slow_query_log = OFF;
|
SET GLOBAL slow_query_log = OFF;
|
||||||
|
|
||||||
RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`;
|
SELECT COUNT(*) INTO vLogExists
|
||||||
|
FROM information_schema.TABLES
|
||||||
|
WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log';
|
||||||
|
|
||||||
|
IF vLogExists THEN
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `mysql`.`slow_log_temp`;
|
||||||
|
RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`;
|
||||||
|
END IF;
|
||||||
|
|
||||||
DELETE FROM `mysql`.`slow_log_temp`
|
DELETE FROM `mysql`.`slow_log_temp`
|
||||||
WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW());
|
WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW());
|
||||||
|
|
Loading…
Reference in New Issue