fix(util): refs #7205 util.slowLog_prune code clean
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
622075a9aa
commit
ccf77ed356
|
@ -11,19 +11,19 @@ BEGIN
|
|||
SET sql_log_bin = OFF;
|
||||
SET GLOBAL slow_query_log = OFF;
|
||||
|
||||
SELECT COUNT(*) INTO vLogExists
|
||||
SELECT COUNT(*) > 0 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`;
|
||||
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());
|
||||
|
||||
RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`;
|
||||
RENAME TABLE mysql.slow_log_temp TO mysql.slow_log;
|
||||
|
||||
SET GLOBAL slow_query_log = vSlowQueryLog;
|
||||
SET sql_log_bin = vSqlLogBin;
|
||||
|
|
Loading…
Reference in New Issue