WL#12727: A component service for the current_thd()

Affects: Server-8.0   —   Status: Complete

Sometimes it's beneficial to be able to check if the code is running inside an
user session and access the properties of that session via other services (e.g.
the current security context for example). 

Thus we need to be able to call current_thd() from a component and obtain an
opaque pointer to the THD that we can pass to other services.

This will allow certain plugins to be using this instead of the global
current_thd symbol from mysqld and will hence contribute to cleaner plugins
(including commercial ones). 

----- concrete example -----

When working with replication events within a component, the only way to be able
to apply such events is via a thd. As the current thd is not accessible from the
component interface, such operation is impossible in a clean way.
FR1. Return an opaque THD pointer if the current code is executing inside a
server thread
FR1.1. Return a 0 (NULL) if the current thread is not a server component thread
NF2. Do not expose the server component definition of the THD and just treat it
as an opaque pointer.
DEFINE_SERVICE_HANDLE(MYSQL_THD);
BEGIN_SERVICE_DECLARATION(mysql_current_thread_reader)
  DECLARE_BOOL_METHOD(get, (MYSQL_THD *pOutTHD));
END_SERVICE_DECLARATION(mysql_current_thread_reader)