select concat(ifnull(user,"None-"),"———",ifnull(db,"None-"),
"———",ifnull(state,"None-"),"———",ifnull(`time`,"None-"),
"———",concat("mysession:",id," was blocked by:",ifnull(b.blockerid,""),"———"),
ifnull(case when info like "%insert%" and info like "%values%" and info like "%into%"
then left(info,1500) else info end,"None-"),"
")
from information_schema.`PROCESSLIST` a left join
(
SELECT b.trx_mysql_thread_id as 'blockerid',r.trx_mysql_thread_id as 'blockedid'
FROM information_schema.innodb_lock_waits w
INNER JOIN information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id INNER
JOIN information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id
)b on a.id=b.blockedid
where info is not null and length(info)>4
and info not like "%PROCESSLIST%" order by time desc limit 100;