sergei... one more point... i was looking the mk-kill 
http://linux.die.net/man/1/mk-kill

there's some cases where we want to kill a thread that's no running any query and we need to kill it only when it is not running any query, in other words i can't use kill thread id, i must use kill query id....
the point here is "how query id is increased?" for example..


(query id = 0 thread id = 10)      <- kill query id =0

[query received]
query id ++ (query id = 1 thread id = 10)
SELECT * FROM TABLE     <- kill query id =1
[query done]
(query id = 1 thread id = 10)     <- kill query id =1


[query received]
query id ++ (query id = 2 thread id = 10)
SELECT * FROM TABLE     <- kill query id =2
[query done]
(query id = 2 thread id = 10) <- kill query id =2


(query id = 2 thread id = 10)  <- kill query id =2


if i send a KILL QUERY ID = 2, i will only kill the last SELECT, or if the select is done, i will kill the thread with the last executed query id = 2

see the problem? the query id can't be reseted, and it MUST be increased only when we START a new query, not at the end of query, example:




(query id = 0 thread id = 10)      <- kill query id =0

[query received] (query id = 0 thread id = 10)
SELECT * FROM TABLE     <- kill query id =0
query id ++ (query id = 1 thread id = 10)
[query done]
(query id = 1 thread id = 10)     <- kill query id =1 !!!!


[query received] (query id = 1 thread id = 10)
SELECT * FROM TABLE     <- kill query id =1 !!!!
query id ++ (query id = 2 thread id = 10)
[query done]
(query id = 2 thread id = 10) <- kill query id =2


---
Is the QUERY ID increased ONLY WHEN A QUERY START, AND the QUERY ID isn't reseted AFTER query execution?

If yes, this is ok, we can kill a thread that is not running a query without problems using query id
in this case no problems...

bye