BUG#54729: sleep() capped to 5 seconds when executed in the sql thread or in an event
BUG#54729: sleep() capped to 5 seconds when executed in the sql thread or in an event

Symptom:
When the sql function SLEEP() was executed in the slave SQL thread or from an event (as in
CREATE EVENT, not binlog event), then the timeout was capped to 5 seconds.

Background:
This bug was introduced in the fix of BUG#10374, in the function interruptible_wait() in
item_func.cc.
The function interruptible_wait(), called from item_func_sleep::val_int(), splits the
sleep into 5 seconds units. After each unit, it checks if thd->is_connected() is true: if
not, it stops sleeping. The purpose is to not use system resources to sleep when a client
disconnects.
However, thd->is_connected() returns false for the slave SQL thread and for the event
worker thread, because they don't connect to the server the same way as client threads
do.

Fix:
Make thd->is_connected() return true for all system threads.


sql/sql_class.h:
  Made THD::is_connected() return true for all system threads.

flynn1973/mariadb-aix,flynn1973/mariadb-aix,davidl-zend/zenddbi,flynn1973/mariadb-aix,ollie314/server,ollie314/server,ollie314/server,flynn1973/mariadb-aix,ollie314/server,ollie314/server,flynn1973/mariadb-aix,davidl-zend/zenddbi,natsys/mariadb_10.2,natsys/mariadb_10.2,natsys/mariadb_10.2,natsys/mariadb_10.2,slanterns/server,natsys/mariadb_10.2,ollie314/server,natsys/mariadb_10.2,flynn1973/mariadb-aix,natsys/mariadb_10.2,flynn1973/mariadb-aix,davidl-zend/zenddbi,davidl-zend/zenddbi,ollie314/server,natsys/mariadb_10.2,davidl-zend/zenddbi,natsys/mariadb_10.2,davidl-zend/zenddbi,flynn1973/mariadb-aix,davidl-zend/zenddbi,flynn1973/mariadb-aix,davidl-zend/zenddbi,ollie314/server,natsys/mariadb_10.2,natsys/mariadb_10.2,flynn1973/mariadb-aix,ollie314/server,davidl-zend/zenddbi,davidl-zend/zenddbi,davidl-zend/zenddbi,ollie314/server,ollie314/server,flynn1973/mariadb-aix