Bug #30389 connection_id() always return 0 in embedded server
Submitted: 13 Aug 2007 17:01 Modified: 31 Aug 2007 3:30
Reporter: Magnus Svensson
Status: Closed
Category:libmysqld Severity:S3 (Non-critical)
Version:5.1.22 OS:Any
Assigned to: Tim Smith Target Version:5.1.22

[13 Aug 2007 17:01] Magnus Svensson
Description:
When using connection_id() in the embedded server it will always return 0 in 5.1. It works
in 4.1 and also mysql-5.1.21-beta-pb709.tar.gz that I just downloaded and tested with wo
it appears this has appeared quite recently.

How to repeat:
$>cat ms.test
select connection_id();

$>./mtr ms
+ select connection_id();
+ connection_id()
+ 1

$>./mtr ms --embedded
+ select connection_id();
+ connection_id()
+ 0
[13 Aug 2007 22:01] Tim Smith
May be that this caused by the fix for bug #29928.
[21 Aug 2007 18:36] Tim Smith
In 5.1, thd->variables.pseudo_thread_id is not being set properly in embedded server.  It
*is* set in 5.0, even in embedded.  I'm currently tracking down what's going wrong in
5.1.

Looks like THD::store_globals() doesn't set pseudo_thread_id anymore, after this
changeset:  ChangeSet 1.2409.68.1 2007/02/23 13:13:55 monty@mysql.com
[21 Aug 2007 20:19] Tim Smith
OK, problem is that create_embedded_thd() doesn't initialize pseudo_thread_id.  It should
do the same as create_new_thread().
[21 Aug 2007 20:45] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32831

ChangeSet@1.2565, 2007-08-21 12:44:54-06:00, tsmith@ramayana.hindu.god +3 -0
  Bug #30389: connection_id() always return 0 in embedded server
  
  Initialize thd->variables.pseudo_thread_id when a new embedded
  thd is created.
[22 Aug 2007 1:13] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/32848

ChangeSet@1.2565, 2007-08-21 17:12:53-06:00, tsmith@ramayana.hindu.god +5 -0
  Bug #30389: connection_id() always return 0 in embedded server
  
  Initialize thd->variables.pseudo_thread_id when a new embedded
  thd is created.
[22 Aug 2007 1:14] Tim Smith
Queued to 5.1-maint
[22 Aug 2007 10:38] Magnus Svensson
Where did the patch go? Can't see it 5.1-maint
[27 Aug 2007 22:34] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/33171

ChangeSet@1.2583, 2007-08-27 14:31:27-06:00, tsmith@ramayana.hindu.god +5 -0
  Bug #30389: connection_id() always return 0 in embedded server
    
  Initialize thd->variables.pseudo_thread_id when a new embedded
  thd is created.
[28 Aug 2007 18:56] Trudy Pelzer
Patch has been pushed to 5.1.22 tree.
[29 Aug 2007 20:45] Tim Smith
Hmmm, I should mention on this bug:  the actual code fix was done independently by Monty
in a "fix lots of small problems" commit, without reference to this bug report.  I went
ahead and pushed my extra test case + comments, but the actual code change in
create_embedded_thd() was already in place.
[31 Aug 2007 3:30] Paul DuBois
Noted in 5.1.22 changelog.

CONNECTION_ID() always returned 0 for the embedded server (libmysqld).
[4 Sep 2007 19:12] Bugs System
Pushed into 5.1.23-beta