List:Commits« Previous MessageNext Message »
From:tim Date:August 27 2007 8:31pm
Subject:bk commit into 5.1 tree (tsmith:1.2583) BUG#30389
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tsmith. When tsmith does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-08-27 14:31:27-06:00, tsmith@stripped +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.

  libmysqld/lib_sql.cc@stripped, 2007-08-27 14:31:26-06:00, tsmith@stripped +11 -0
    Add comment regarding duplication of code in create_embedded_thd()
    vs. create_new_thread() and prepare_new_connection_state().  This
    was a cause for not properly initializing the pseudo_thread_id variable.

  mysql-test/r/func_misc.result@stripped, 2007-08-27 14:31:26-06:00, tsmith@stripped +4 -0
    Add test case to ensure connection_id() returns a sane value

  mysql-test/t/func_misc.test@stripped, 2007-08-27 14:31:26-06:00, tsmith@stripped +8 -0
    Add test case to ensure connection_id() returns a sane value

  sql/mysqld.cc@stripped, 2007-08-27 14:31:26-06:00, tsmith@stripped +5 -0
    Add comment warning of the duplication of code between create_new_thread()
    and create_embedded_thd()

  sql/sql_connect.cc@stripped, 2007-08-27 14:31:26-06:00, tsmith@stripped +5 -0
    Add comment warning of the duplication of code between
    prepare_new_connection_state() and create_embedded_thd()

diff -Nrup a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
--- a/libmysqld/lib_sql.cc	2007-08-16 07:47:29 -06:00
+++ b/libmysqld/lib_sql.cc	2007-08-27 14:31:26 -06:00
@@ -564,6 +564,17 @@ void init_embedded_mysql(MYSQL *mysql, i
   init_alloc_root(&mysql->field_alloc, 8192, 0);
 }
 
+/**
+  @brief Initialize a new THD for a connection in the embedded server
+
+  @param client_flag  Client capabilities which this thread supports
+  @return pointer to the created THD object
+
+  @todo
+  This function copies code from several places in the server, including
+  create_new_thread(), and prepare_new_connection_state().  This should
+  be refactored to avoid code duplication.
+*/
 void *create_embedded_thd(int client_flag)
 {
   THD * thd= new THD;
diff -Nrup a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
--- a/mysql-test/r/func_misc.result	2007-08-16 07:47:29 -06:00
+++ b/mysql-test/r/func_misc.result	2007-08-27 14:31:26 -06:00
@@ -191,3 +191,7 @@ drop table table_26093;
 drop function func_26093_a;
 drop function func_26093_b;
 End of 5.0 tests
+select connection_id() > 0;
+connection_id() > 0
+1
+End of tests
diff -Nrup a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
--- a/mysql-test/t/func_misc.test	2007-08-16 07:47:29 -06:00
+++ b/mysql-test/t/func_misc.test	2007-08-27 14:31:26 -06:00
@@ -199,3 +199,11 @@ drop function func_26093_a;
 drop function func_26093_b;
 
 --echo End of 5.0 tests
+
+#
+# Bug #30389: connection_id() always return 0 in embedded server
+#
+
+select connection_id() > 0;
+
+--echo End of tests
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2007-08-27 06:01:27 -06:00
+++ b/sql/mysqld.cc	2007-08-27 14:31:26 -06:00
@@ -4355,6 +4355,11 @@ static void create_new_thread(THD *thd)
     DBUG_VOID_RETURN;
   }
   pthread_mutex_lock(&LOCK_thread_count);
+  /*
+    The initialization of thread_id is done in create_embedded_thd() for
+    the embedded library.
+    TODO: refactor this to avoid code duplication there
+  */
   thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
 
   /* Start a new thread to handle connection */
diff -Nrup a/sql/sql_connect.cc b/sql/sql_connect.cc
--- a/sql/sql_connect.cc	2007-07-30 02:33:44 -06:00
+++ b/sql/sql_connect.cc	2007-08-27 14:31:26 -06:00
@@ -1008,6 +1008,11 @@ void prepare_new_connection_state(THD* t
   if (thd->client_capabilities & CLIENT_COMPRESS)
     thd->net.compress=1;				// Use compression
 
+  /*
+    Much of this is duplicated in create_embedded_thd() for the
+    embedded server library.
+    TODO: refactor this to avoid code duplication there
+  */
   thd->version= refresh_version;
   thd->proc_info= 0;
   thd->command= COM_SLEEP;
Thread
bk commit into 5.1 tree (tsmith:1.2583) BUG#30389tim27 Aug