diff options
author | unknown <tsmith@ramayana.hindu.god> | 2007-08-27 14:31:27 -0600 |
---|---|---|
committer | unknown <tsmith@ramayana.hindu.god> | 2007-08-27 14:31:27 -0600 |
commit | 61e988e712ed82542ebc1d867a21e71f3103a0f7 (patch) | |
tree | 679a96401bec41e2c195429ae868169f2520ef9b | |
parent | ad4ee2067349fa7e6d3810b4fe05692cf9b19acf (diff) | |
download | mariadb-git-61e988e712ed82542ebc1d867a21e71f3103a0f7.tar.gz |
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:
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:
Add test case to ensure connection_id() returns a sane value
mysql-test/t/func_misc.test:
Add test case to ensure connection_id() returns a sane value
sql/mysqld.cc:
Add comment warning of the duplication of code between create_new_thread()
and create_embedded_thd()
sql/sql_connect.cc:
Add comment warning of the duplication of code between
prepare_new_connection_state() and create_embedded_thd()
-rw-r--r-- | libmysqld/lib_sql.cc | 11 | ||||
-rw-r--r-- | mysql-test/r/func_misc.result | 4 | ||||
-rw-r--r-- | mysql-test/t/func_misc.test | 8 | ||||
-rw-r--r-- | sql/mysqld.cc | 5 | ||||
-rw-r--r-- | sql/sql_connect.cc | 5 |
5 files changed, 33 insertions, 0 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 42d2752f6e1..9c26febe627 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -564,6 +564,17 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag) 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 --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 447d5620a4d..39bf1470afe 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -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 --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index a48f619dc34..01eff55d1f6 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -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 --git a/sql/mysqld.cc b/sql/mysqld.cc index d5336f5dd9c..b4ea09597a8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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 --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 03b9908c1ad..6bb0f62d843 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1008,6 +1008,11 @@ void prepare_new_connection_state(THD* thd) 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; |