38 lines
636 B
MySQL
38 lines
636 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`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 ;
|