You need to use the following functions when you want to create a threaded client. See Threaded clients.
This function needs to be called once in the program before calling any MySQL function. This initializes some global variables that MySQL needs. If you are using a thread-safe client library, this will also call mysql_thread_init() for this thread.
This is automatically called by mysql_init(), mysql_server_init() and mysql_connect().
This function needs to be called for each created thread to initialize thread-specific variables.
This is automatically called by my_init() and mysql_connect().
This function needs to be called before calling pthread_exit() to free memory allocated by mysql_thread_init().
Note that this function is not invoked automatically by the client library. It must be called explicitly to avoid a memory leak.