set THR_THD key and current_thd=NULL as early as possible,
otherwise safemalloc and my_malloc_size_cb_func will use
current_thd before it's defined
MDEV-537 Make multi-column non-top level subqueries to be executed via index (index/unique subquery)
           instead of single_select_engine

This task changes the IN-EXISTS rewrite for multi-column subqueries
"(a, b) IN (select b, c ...)" to work in the same way as for
single-column subqueries "a IN (select b ...) with respect to the
injection of NULL-rejecting predicates.
 
More specifically, the method
Item_in_subselect::create_row_in_to_exists_cond()
adds Item_is_not_null_test and Item_func_trig_cond only if the left
IN operand can be NULL. Not having these predicates when not necessary,
makes it possible to rewrite the subquery into a "unique_subquery" or
"index_subquery" when there is a suitable index on the only
subquery table.
Fix for MDEV-4149, backport from 10.0:
  committer: Sergei Golubchik <sergii@pisem.net> 
    fix for a valgrind builds. 
    my_alloca() cannot have MY_THREAD_SPECIFIC, because can be used 
    outside of the THD context.
Automatic merge
MDEV-156 Threadpool - add thd_wait_begin/thd_wait_end to the network IO functions