Name

mysql_thread_id —

Synopsis

unsigned long mysql_thread_id(MYSQL * mysql)

Returns the thread ID of the current connection. This value can be used with mysql_kill to terminate the thread in case of an error. The thread ID will change if you disconnect from the server and reconnect (which may happen automatically, without warning, if you use mysql_ping). Therefore, you should call this function immediately before you use the value.

Example

thread_id = mysql_thread_id(&mysql);
/* This number can be used with mysql_kill(  ) to terminate the current thread. */

Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.