新建函数
BEGIN
declare Done int default 0;
declare id_to_be_killed bigint;
/* 声明游标 */
declare process_ids cursor for
select ID
from information_schema.processlist
where (command = 'sleep' and time > 100) or (info like '%acct_info %');
/* 异常处理 */
declare continue handler for sqlstate '02000' set Done = 1;
/* 打开游标 */
open process_ids;
/*读取值*/
fetch next from process_ids into id_to_be_killed;
repeat
if not Done then
kill id_to_be_killed;
end if;
fetch next from process_ids into id_to_be_killed;
until Done
end repeat;
END