salix/db/routines/vn/procedures/mysqlConnectionsSorter_kill...

38 lines
640 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`mysqlConnectionsSorter_kill`()
BEGIN
/**
* Elimina conexiones del usuario sorter con tiempo >= 30seg. Asociado al evento con el mismo nombre
*/
DECLARE vDone INT DEFAULT 0;
DECLARE vProcesId INT;
DECLARE vCursor CURSOR FOR
SELECT p.id
FROM information_schema.processlist p
WHERE USER = 'sorter'
AND TIME >= 30;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN vCursor;
l: LOOP
FETCH vCursor INTO vProcesId;
IF vDone THEN
LEAVE l;
END IF;
KILL vProcesId;
END LOOP;
CLOSE vCursor;
END$$
DELIMITER ;