You can call the mysql_kill() function to request the server to kill the thread specified by pid.
Syntax
int
mysql_kill(MYSQL *mysql,
unsigned long pid)
Return values
0 is returned for an operation success, and a non-zero value is returned for errors.
Errors
CR_COMMANDS_OUT_OF_SYNC: Commands were executed in an improper order.CR_INVALID_CONN_HANDLE: Thepidwas greater than 32 bits.CR_SERVER_GONE_ERROR: The connection to the OBServer was disconnected.CR_SERVER_LOST: The connection to the server was lost during the query.CR_UNKNOWN_ERROR: An unknown error occurred.ER_DATA_OUT_OF_RANGE: The internal thread ID counter of the server has reached a value greater than 32 bits. In this case, the server rejects allmysql_kill()calls.
Notes
mysql_kill() cannot handle values greater than 32 bits. However, to avoid killing the wrong thread, it returns an error in the following cases:
Given an ID greater than 32 bits,
mysql_kill()returns aCR_INVALID_CONN_HANDLEerror.After the internal thread ID counter of the server reaches a value greater than 32 bits, the server returns an
ER_DATA_OUT_OF_RANGEerror formysql_kill()calls, andmysql_kill()fails.