| Bug #30930 | Add auxiliary function to retrieve THD::thread_id | ||
|---|---|---|---|
| Submitted: | 10 Sep 2007 13:38 | Modified: | 25 Feb 2008 19:45 |
| Reporter: | Vasil Dimov | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S4 (Feature request) |
| Version: | 5.1 | OS: | Any |
| Assigned to: | Timothy Smith | CPU Architecture: | Any |
[10 Sep 2007 14:05]
MySQL Verification Team
Thank you for the bug report.
[11 Feb 2008 7:36]
Vasil Dimov
Any chance this gets some attention? There is a patch and it is really very simple anyway. It has been hanging here for 5 months!
[11 Feb 2008 13:23]
Marko Mäkelä
Timothy, could you please apply the patch? Also, the definition of the function thd_get_xid() in sql/sql_class.cc seems to lack the extern "C" qualifier and thus disagree with the declaration in include/mysql/plugin.h. However, for some reason, the linking does not fail.
[20 Feb 2008 23:45]
Timothy Smith
This fix is queued in 5.1- and 6.0-build.
[25 Feb 2008 15:59]
Bugs System
Pushed into 5.1.24-rc
[25 Feb 2008 16:05]
Bugs System
Pushed into 6.0.5-alpha
[25 Feb 2008 19:45]
Paul DuBois
No user-visible effects. No changelog entry needed.

Description: Hi, I am preparing a bunch of INFORMATION_SCHEMA InnoDB diagnostic tables and would like to put the MySQL thread id (THD::thread_id) in one of them so it can be joined with INFORMATION_SCHEMA.processlist. (THD::thread_id goes in INFORMATION_SCHEMA.processlist.id). I have attached a sample patch that adds such a function, feel free to change its name, comment or anything. Thanks! How to repeat: N/A Suggested fix: --- include/mysql/plugin.h 2007-09-10 14:41:45.000000000 +0300 +++ include/mysql/plugin.h 2007-09-10 16:24:50.000000000 +0300 @@ -715,6 +715,13 @@ int thd_killed(const MYSQL_THD thd); /** + Return the thread id of a user thread + @param thd user thread + @retval thread id +*/ +unsigned long thd_get_thread_id(const MYSQL_THD thd); + +/** Allocate memory in the connection's local memory pool @details --- sql/sql_class.cc 2007-09-10 14:41:49.000000000 +0300 +++ sql/sql_class.cc 2007-09-10 16:24:50.000000000 +0300 @@ -2564,6 +2564,16 @@ return(thd->killed); } +/** + Return the thread id of a user thread + @param thd user thread + @retval thread id +*/ +extern "C" unsigned long thd_get_thread_id(const MYSQL_THD thd) +{ + return((unsigned long)thd->thread_id); +} + #ifdef INNODB_COMPATIBILITY_HOOKS extern "C" struct charset_info_st *thd_charset(MYSQL_THD thd) {