Bug #30389 connection_id() always return 0 in embedded server
Submitted: 13 Aug 2007 15:01 Modified: 31 Aug 2007 1:30
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S3 (Non-critical)
Version:5.1.22 OS:Any
Assigned to: Timothy Smith CPU Architecture:Any

[13 Aug 2007 15:01] Magnus Blåudd
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 20:01] Timothy Smith
May be that this caused by the fix for bug #29928.
[21 Aug 2007 16:36] Timothy 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 18:19] Timothy 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 18: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.
[21 Aug 2007 23: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.
[21 Aug 2007 23:14] Timothy Smith
Queued to 5.1-maint
[22 Aug 2007 8:38] Magnus Blåudd
Where did the patch go? Can't see it 5.1-maint
[27 Aug 2007 20: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 16:56] Trudy Pelzer
Patch has been pushed to 5.1.22 tree.
[29 Aug 2007 18:45] Timothy 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 1:30] Paul Dubois
Noted in 5.1.22 changelog.

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