List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:April 13 2012 12:01pm
Subject:bzr push into mysql-trunk branch (tor.didriksen:3876 to 3877) WL#6221
View as plain text  
 3877 Tor Didriksen	2012-04-13
      WL#6221 THD refactoring, remove ilink inheritance
      
      Remove the ilink ineritance from THD, and remove global variables
      I_List<THD> threads;
      uint volatile thread_count;
      
      Add an interface for manipulating the list of THDs and the count.
     @ libmysqld/lib_sql.cc
        Use add/remove_global_thread()
     @ mysql-test/r/show_check.result
        Tests need sorted_result with the new implementation.
     @ mysql-test/r/sp-threads.result
        Tests need sorted_result with the new implementation.
     @ mysql-test/suite/funcs_1/datadict/processlist_priv.inc
        Tests need sorted_result with the new implementation.
     @ mysql-test/suite/funcs_1/datadict/processlist_val.inc
        Tests need sorted_result with the new implementation.
     @ mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
        Tests need sorted_result with the new implementation.
     @ mysql-test/suite/funcs_1/r/processlist_priv_ps.result
        Tests need sorted_result with the new implementation.
     @ mysql-test/suite/funcs_1/r/processlist_val_no_prot.result
        Tests need sorted_result with the new implementation.
     @ mysql-test/suite/funcs_1/r/processlist_val_ps.result
        Tests need sorted_result with the new implementation.
     @ mysql-test/t/show_check.test
        Tests need sorted_result with the new implementation.
     @ mysql-test/t/sp-threads.test
        Tests need sorted_result with the new implementation.
     @ sql/binlog.cc
        Use Thread_iterator.
        
        Move LOG_INFO linfo to outer scope,
        to prevent destruction while still being pointed to by thd.
     @ sql/event_scheduler.cc
        Use add/remove_global_thread()
        Use Thread_iterator.
     @ sql/global_threads.h
        New interface for keeping list of global threads.
     @ sql/log.h
        Add comment for LOG_INFO struct.
     @ sql/mysqld.cc
        Remove the global variables
        I_List<THD> threads;
        uint volatile thread_count;
        
        global_thread_count is read by a signal handler, so it must be of type sig_atomic_t
        global_thread_list is on the heap, to avoid race conditions during shutdown
        
        The list of threads is no longer internal to each THD,
        so we can grab LOCK_thread_count once, and then
        iterate through the list doing close_connection(THD*)
        
        We must keep delete_thd() since it is used by the thread_pool.
        
        Remove unlink_thd(), which locked the mutex, and left it locked.
        
        Rename cache_thread() to block_until_new_connection()
        and let it do it's own mutex lock/unlock.
        
        In bootstrap mode: Tell the signal handler thread to enter it's main loop.
     @ sql/mysqld.h
        Move LOCK_thread_count COND_thread_count to global_threads.h
        Remove unlink_thd()
        Move sql_rnd_with_mutex(), since Lock_thread_count was moved.
     @ sql/rpl_master.cc
        Use Thread_iterator.
     @ sql/rpl_slave.cc
        Use add/remove_global_thread()
     @ sql/scheduler.cc
        Grab and release LOCK_thread_count in the same function.
     @ sql/sql_class.cc
        Use add_global_thread().
     @ sql/sql_class.h
        ilink<THD> is gone!
     @ sql/sql_insert.cc
        Use add_global_thread().
     @ sql/sql_parse.cc
        Use add_global_thread().
        Use Thread_iterator.
     @ sql/sql_plugin.cc
        Dont cast current_thd to (long)
     @ sql/sql_show.cc
        Use Thread_iterator.
     @ storage/perfschema/pfs_check.cc
        current_thd returned pointer to a THD which was deleted.

    modified:
      libmysqld/lib_sql.cc
      mysql-test/r/show_check.result
      mysql-test/r/sp-threads.result
      mysql-test/suite/funcs_1/datadict/processlist_priv.inc
      mysql-test/suite/funcs_1/datadict/processlist_val.inc
      mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result
      mysql-test/suite/funcs_1/r/processlist_priv_ps.result
      mysql-test/suite/funcs_1/r/processlist_val_no_prot.result
      mysql-test/suite/funcs_1/r/processlist_val_ps.result
      mysql-test/t/show_check.test
      mysql-test/t/sp-threads.test
      sql/binlog.cc
      sql/event_scheduler.cc
      sql/global_threads.h
      sql/log.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/rpl_master.cc
      sql/rpl_slave.cc
      sql/rpl_slave.h
      sql/scheduler.cc
      sql/signal_handler.cc
      sql/sp_head.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_insert.cc
      sql/sql_parse.cc
      sql/sql_plugin.cc
      sql/sql_reload.cc
      sql/sql_show.cc
      sql/sql_test.cc
      sql/sys_vars.cc
      storage/perfschema/pfs_check.cc
 3876 magnus.blaudd@stripped	2012-04-13 [merge]
      Merge

    added:
      mysql-test/suite/sys_vars/r/transaction_allow_batching_basic.result
      mysql-test/suite/sys_vars/t/transaction_allow_batching_basic.test
    modified:
      sql/sys_vars.cc
      storage/ndb/compile-cluster
=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc	2012-04-06 18:58:01 +0000
+++ b/libmysqld/lib_sql.cc	2012-04-13 12:00:39 +0000
@@ -19,10 +19,6 @@
   The following is needed to not cause conflicts when we include mysqld.cc
 */
 
-#define main main1
-#define mysql_unix_port mysql_inix_port1
-#define mysql_port mysql_port1
-
 extern "C"
 {
   extern unsigned long max_allowed_packet, net_buffer_length;
@@ -30,24 +26,28 @@ extern "C"
 
 #include "../sql/mysqld.cc"
 
-C_MODE_START
+extern "C" {
 
 #include <mysql.h>
 #undef ER
 #include "errmsg.h"
 #include "embedded_priv.h"
 
+} // extern "C"
+
 #include <algorithm>
 
 using std::min;
 using std::max;
 
+extern "C" {
+
 extern unsigned int mysql_server_last_errno;
 extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
 static my_bool emb_read_query_result(MYSQL *mysql);
 
 
-extern "C" void unireg_clear(int exit_code)
+void unireg_clear(int exit_code)
 {
   DBUG_ENTER("unireg_clear");
   clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */
@@ -422,9 +422,12 @@ static void emb_free_embedded_thd(MYSQL 
 {
   THD *thd= (THD*)mysql->thd;
   thd->clear_data_list();
-  thread_count--;
   thd->store_globals();
-  thd->unlink();
+
+  mysql_mutex_lock(&LOCK_thread_count);
+  remove_global_thread(thd);
+  mysql_mutex_unlock(&LOCK_thread_count);
+
   delete thd;
   my_pthread_setspecific_ptr(THR_THD,  0);
   mysql->thd=0;
@@ -720,8 +723,9 @@ void *create_embedded_thd(int client_fla
   thd->data_tail= &thd->first_data;
   memset(&thd->net, 0, sizeof(thd->net));
 
-  thread_count++;
-  threads.push_front(thd);
+  mysql_mutex_lock(&LOCK_thread_count);
+  add_global_thread(thd);
+  mysql_mutex_unlock(&LOCK_thread_count);
   thd->mysys_var= 0;
   return thd;
 err:
@@ -815,7 +819,8 @@ err:
 }
 #endif
 
-C_MODE_END
+} // extern "C"
+
 
 void THD::clear_data_list()
 {

=== modified file 'mysql-test/r/show_check.result'
--- a/mysql-test/r/show_check.result	2011-11-01 11:52:24 +0000
+++ b/mysql-test/r/show_check.result	2012-04-13 12:00:39 +0000
@@ -1539,13 +1539,13 @@ SET NAMES latin1;
 SELECT GET_LOCK('t',1000) AS 'óóóó';;
 SHOW PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-###	root	###	test	Query	###	###	SHOW PROCESSLIST
 ###	root	###	test	Query	###	###	SELECT GET_LOCK('t',1000) AS 'óóóó'
+###	root	###	test	Query	###	###	SHOW PROCESSLIST
 SET NAMES utf8;
 SHOW PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-###	root	###	test	Query	###	###	SHOW PROCESSLIST
 ###	root	###	test	Query	###	###	SELECT GET_LOCK('t',1000) AS 'óóóó'
+###	root	###	test	Query	###	###	SHOW PROCESSLIST
 SELECT RELEASE_LOCK('t');
 RELEASE_LOCK('t')
 1

=== modified file 'mysql-test/r/sp-threads.result'
--- a/mysql-test/r/sp-threads.result	2011-02-16 10:22:49 +0000
+++ b/mysql-test/r/sp-threads.result	2012-04-13 12:00:39 +0000
@@ -34,10 +34,10 @@ lock tables t2 write;
 call bug9486();
 show processlist;
 Id	User	Host	db	Command	Time	State	Info
-#	root	localhost	test	Sleep	#		NULL
 #	root	localhost	test	Query	#	Waiting for table metadata lock	update t1, t2 set val= 1 where id1=id2
 #	root	localhost	test	Query	#	init	show processlist
 #	root	localhost	test	Sleep	#		NULL
+#	root	localhost	test	Sleep	#		NULL
 unlock tables;
 drop procedure bug9486;
 drop table t1, t2;

=== modified file 'mysql-test/suite/funcs_1/datadict/processlist_priv.inc'
--- a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc	2009-05-27 08:54:59 +0000
+++ b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc	2012-04-13 12:00:39 +0000
@@ -137,6 +137,7 @@ WHERE DB = 'information_schema' AND COMM
 --source include/wait_condition.inc
 eval SHOW CREATE TABLE $table;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 eval SHOW $table;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
 eval SELECT * FROM $table $select_where ORDER BY id;
@@ -181,8 +182,10 @@ GRANT PROCESS ON *.* TO ddicttestuser1@'
 connection con100;
 SHOW GRANTS;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -193,8 +196,10 @@ SELECT * FROM information_schema.process
 connect (con101,localhost,ddicttestuser1,ddictpass,information_schema);
 SHOW GRANTS;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -215,8 +220,10 @@ GRANT PROCESS ON *.* TO ''@'localhost';
 connect (anonymous1,localhost,"''",,information_schema);
 SHOW GRANTS;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -237,8 +244,10 @@ connect (con102,localhost,ddicttestuser1
 --echo ####################################################################################
 SHOW GRANTS;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -262,9 +271,11 @@ if ($fixed_bug_30395)
 {
 # Bug#30395 strange results after REVOKE PROCESS ON *.* FROM ...
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 }
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -284,8 +295,10 @@ connect (con103,localhost,ddicttestuser1
 --echo ####################################################################################
 SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -306,8 +319,10 @@ connect (con104,localhost,ddicttestuser1
 --echo ####################################################################################
 SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -353,8 +368,10 @@ connect (con200,localhost,ddicttestuser2
 --echo ####################################################################################
 SHOW GRANTS FOR 'ddicttestuser2'@'localhost';
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -374,8 +391,10 @@ connect (con201,localhost,ddicttestuser2
 --echo ####################################################################################
 SHOW GRANTS;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -397,8 +416,10 @@ SHOW GRANTS FOR 'ddicttestuser1'@'localh
 --error ER_ACCESS_DENIED_ERROR
 GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost';
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 
@@ -421,8 +442,10 @@ connect (con108,localhost,ddicttestuser1
 --echo ####################################################################################
 SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SHOW processlist;
 --replace_column 1 ID 3 HOST_NAME 6 TIME
+--sorted_result
 SELECT * FROM information_schema.processlist;
 --real_sleep 0.3
 

=== modified file 'mysql-test/suite/funcs_1/datadict/processlist_val.inc'
--- a/mysql-test/suite/funcs_1/datadict/processlist_val.inc	2010-08-06 11:29:37 +0000
+++ b/mysql-test/suite/funcs_1/datadict/processlist_val.inc	2012-04-13 12:00:39 +0000
@@ -93,8 +93,10 @@ echo
 #
 # 1. Just dump what we get
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SHOW FULL PROCESSLIST;
 #
 # Determine the connection id of the current connection (default)
@@ -166,8 +168,10 @@ let $wait_condition= SELECT COUNT(*) = 1
 --source include/wait_condition.inc
 # 1. Just dump what we get
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SHOW FULL PROCESSLIST;
 #
 # Pull ID and TIME of the second connection
@@ -211,8 +215,10 @@ echo
 ;
 connection con1;
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SHOW FULL PROCESSLIST;
 
 
@@ -245,8 +251,10 @@ echo
 connection con2;
 # Just dump what we get
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SHOW FULL PROCESSLIST;
 #
 echo
@@ -305,8 +313,10 @@ WHERE ID = @test_user_con2_id AND Comman
 --source include/wait_condition.inc
 # 1. Just dump what we get
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SHOW FULL PROCESSLIST;
 #
 # Pull some information about the connection con2
@@ -376,6 +386,7 @@ let $wait_condition= SELECT COUNT(*) FRO
 # Expect to see the state 'Waiting for table metadata lock' for the third
 # connection because the SELECT collides with the WRITE TABLE LOCK.
 --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
+--sorted_result
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 UNLOCK TABLES;
 #
@@ -435,10 +446,13 @@ echo
 # SHOW PROCESSLIST                               statement truncated after 100 char
 ;
 --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE>
+--sorted_result
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE>
+--sorted_result
 SHOW FULL PROCESSLIST;
 --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE>
+--sorted_result
 SHOW PROCESSLIST;
 UNLOCK TABLES;
 echo

=== modified file 'mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result'
--- a/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result	2011-06-24 10:45:34 +0000
+++ b/mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result	2012-04-13 12:00:39 +0000
@@ -33,8 +33,8 @@ PROCESSLIST	CREATE TEMPORARY TABLE `PROC
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	root	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID	root	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM processlist  ORDER BY id;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	root	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM processlist  ORDER BY id
@@ -182,9 +182,9 @@ Grants for ddicttestuser1@localhost
 GRANT PROCESS ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
+ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
@@ -205,10 +205,10 @@ Grants for @localhost
 GRANT PROCESS ON *.* TO ''@'localhost'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID		HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
+ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID		HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
@@ -230,9 +230,9 @@ Grants for ddicttestuser1@localhost
 GRANT USAGE ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
@@ -269,10 +269,10 @@ Grants for ddicttestuser1@localhost
 GRANT SUPER ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
@@ -294,11 +294,11 @@ Grants for ddicttestuser1@localhost
 GRANT USAGE ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
@@ -342,29 +342,29 @@ Grants for ddicttestuser2@localhost
 GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID		HOST_NAME	information_schema	Sleep	TIME		NULL
+ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser2	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
+ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
-ID	ddicttestuser2	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
+ID		HOST_NAME	information_schema	Sleep	TIME		NULL
+ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID	ddicttestuser2	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
 ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
 ####################################################################################
 11 User ddicttestuser1 revokes PROCESS privilege from user ddicttestuser2
@@ -380,8 +380,8 @@ Grants for ddicttestuser2@localhost
 GRANT USAGE ON *.* TO 'ddicttestuser2'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	ddicttestuser2	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser2	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
+ID	ddicttestuser2	HOST_NAME	information_schema	Sleep	TIME		NULL
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser2	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
@@ -403,6 +403,7 @@ GRANT PROCESS ON *.* TO 'ddicttestuser2'
 ERROR 28000: Access denied for user 'ddicttestuser1'@'localhost' (using password: YES)
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
@@ -410,7 +411,6 @@ ID	ddicttestuser1	HOST_NAME	information_
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist
@@ -438,6 +438,7 @@ Grants for ddicttestuser1@localhost
 GRANT USAGE ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
@@ -446,7 +447,6 @@ ID	ddicttestuser1	HOST_NAME	information_
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	executing	SELECT * FROM information_schema.processlist

=== modified file 'mysql-test/suite/funcs_1/r/processlist_priv_ps.result'
--- a/mysql-test/suite/funcs_1/r/processlist_priv_ps.result	2011-07-25 11:57:20 +0000
+++ b/mysql-test/suite/funcs_1/r/processlist_priv_ps.result	2012-04-13 12:00:39 +0000
@@ -33,8 +33,8 @@ PROCESSLIST	CREATE TEMPORARY TABLE `PROC
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	root	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID	root	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM processlist  ORDER BY id;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	root	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM processlist  ORDER BY id
@@ -182,9 +182,9 @@ Grants for ddicttestuser1@localhost
 GRANT PROCESS ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
+ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
@@ -205,10 +205,10 @@ Grants for @localhost
 GRANT PROCESS ON *.* TO ''@'localhost'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID		HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
+ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID		HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
@@ -230,9 +230,9 @@ Grants for ddicttestuser1@localhost
 GRANT USAGE ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
@@ -269,10 +269,10 @@ Grants for ddicttestuser1@localhost
 GRANT SUPER ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
@@ -294,11 +294,11 @@ Grants for ddicttestuser1@localhost
 GRANT USAGE ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
@@ -342,29 +342,29 @@ Grants for ddicttestuser2@localhost
 GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID		HOST_NAME	information_schema	Sleep	TIME		NULL
+ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser2	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
+ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
-ID	ddicttestuser2	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
+ID		HOST_NAME	information_schema	Sleep	TIME		NULL
+ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID		HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
+ID	ddicttestuser2	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
 ID	root	HOST_NAME	information_schema	Sleep	TIME		NULL
 ####################################################################################
 11 User ddicttestuser1 revokes PROCESS privilege from user ddicttestuser2
@@ -380,8 +380,8 @@ Grants for ddicttestuser2@localhost
 GRANT USAGE ON *.* TO 'ddicttestuser2'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
-ID	ddicttestuser2	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser2	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
+ID	ddicttestuser2	HOST_NAME	information_schema	Sleep	TIME		NULL
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser2	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
@@ -403,6 +403,7 @@ GRANT PROCESS ON *.* TO 'ddicttestuser2'
 ERROR 28000: Access denied for user 'ddicttestuser1'@'localhost' (using password: YES)
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
@@ -410,7 +411,6 @@ ID	ddicttestuser1	HOST_NAME	information_
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist
@@ -438,6 +438,7 @@ Grants for ddicttestuser1@localhost
 GRANT USAGE ON *.* TO 'ddicttestuser1'@'localhost' IDENTIFIED BY PASSWORD '*22DA61451703738F203CDB9DB041ACBA1F4760B1'
 SHOW processlist;
 Id	User	Host	db	Command	Time	State	Info
+ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
@@ -446,7 +447,6 @@ ID	ddicttestuser1	HOST_NAME	information_
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
 ID	ddicttestuser1	HOST_NAME	information_schema	Sleep	TIME		NULL
-ID	ddicttestuser1	HOST_NAME	information_schema	Query	TIME	init	SHOW processlist
 SELECT * FROM information_schema.processlist;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 ID	ddicttestuser1	HOST_NAME	information_schema	Execute	TIME	executing	SELECT * FROM information_schema.processlist

=== modified file 'mysql-test/suite/funcs_1/r/processlist_val_no_prot.result'
--- a/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result	2011-02-16 10:22:49 +0000
+++ b/mysql-test/suite/funcs_1/r/processlist_val_no_prot.result	2012-04-13 12:00:39 +0000
@@ -73,8 +73,8 @@ Has TIME a reasonable value?
 
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
-<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 <ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
+<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 SHOW FULL PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
 <ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	init	SHOW FULL PROCESSLIST
@@ -128,8 +128,8 @@ ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 <ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 SHOW FULL PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 <ID>	test_user	<HOST_NAME>	information_schema	Query	<TIME>	init	SHOW FULL PROCESSLIST
+<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 # ----- switch to connection default (user = root) -----
 
 SELECT ID INTO @test_user_con2_id FROM INFORMATION_SCHEMA.PROCESSLIST
@@ -150,14 +150,14 @@ SELECT sleep(10), 17;
 
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
+<ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
 <ID>	test_user	<HOST_NAME>	information_schema	Query	<TIME>	User sleep	SELECT sleep(10), 17
 <ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
-<ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
 SHOW FULL PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
 <ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	init	SHOW FULL PROCESSLIST
-<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 <ID>	test_user	<HOST_NAME>	information_schema	Query	<TIME>	User sleep	SELECT sleep(10), 17
+<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 SELECT STATE, TIME, INFO INTO @state, @time, @info
 FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE ID = @test_user_con2_id;
@@ -197,9 +197,9 @@ SELECT COUNT(*) FROM test.t1;
 
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
+<ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
 <ID>	test_user	<HOST_NAME>	information_schema	Query	<TIME>	Waiting for table metadata lock	SELECT COUNT(*) FROM test.t1
 <ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
-<ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
 UNLOCK TABLES;
 # ----- switch to connection con2 (user = test_user) -----
 
@@ -231,9 +231,9 @@ SELECT count(*),'BEGIN-This is the repre
 
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
-<ID>	test_user	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	SELECT count(*),'BEGIN-This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.-END' AS "Long string" FROM test.t1
-<ID>	test_user	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	NULL
 <ID>	root	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
+<ID>	test_user	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	NULL
+<ID>	test_user	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	SELECT count(*),'BEGIN-This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.-END' AS "Long string" FROM test.t1
 SHOW FULL PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
 <ID>	root	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	SHOW FULL PROCESSLIST

=== modified file 'mysql-test/suite/funcs_1/r/processlist_val_ps.result'
--- a/mysql-test/suite/funcs_1/r/processlist_val_ps.result	2011-02-16 10:22:49 +0000
+++ b/mysql-test/suite/funcs_1/r/processlist_val_ps.result	2012-04-13 12:00:39 +0000
@@ -73,8 +73,8 @@ Has TIME a reasonable value?
 
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
-<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 <ID>	root	<HOST_NAME>	information_schema	Execute	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
+<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 SHOW FULL PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
 <ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	init	SHOW FULL PROCESSLIST
@@ -128,8 +128,8 @@ ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
 <ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 SHOW FULL PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
-<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 <ID>	test_user	<HOST_NAME>	information_schema	Query	<TIME>	init	SHOW FULL PROCESSLIST
+<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 # ----- switch to connection default (user = root) -----
 
 SELECT ID INTO @test_user_con2_id FROM INFORMATION_SCHEMA.PROCESSLIST
@@ -150,14 +150,14 @@ SELECT sleep(10), 17;
 
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
+<ID>	root	<HOST_NAME>	information_schema	Execute	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
 <ID>	test_user	<HOST_NAME>	information_schema	Query	<TIME>	User sleep	SELECT sleep(10), 17
 <ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
-<ID>	root	<HOST_NAME>	information_schema	Execute	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
 SHOW FULL PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
 <ID>	root	<HOST_NAME>	information_schema	Query	<TIME>	init	SHOW FULL PROCESSLIST
-<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 <ID>	test_user	<HOST_NAME>	information_schema	Query	<TIME>	User sleep	SELECT sleep(10), 17
+<ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
 SELECT STATE, TIME, INFO INTO @state, @time, @info
 FROM INFORMATION_SCHEMA.PROCESSLIST
 WHERE ID = @test_user_con2_id;
@@ -197,9 +197,9 @@ SELECT COUNT(*) FROM test.t1;
 
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
+<ID>	root	<HOST_NAME>	information_schema	Execute	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
 <ID>	test_user	<HOST_NAME>	information_schema	Query	<TIME>	Waiting for table metadata lock	SELECT COUNT(*) FROM test.t1
 <ID>	test_user	<HOST_NAME>	information_schema	Sleep	<TIME>		NULL
-<ID>	root	<HOST_NAME>	information_schema	Execute	<TIME>	executing	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
 UNLOCK TABLES;
 # ----- switch to connection con2 (user = test_user) -----
 
@@ -231,9 +231,9 @@ SELECT count(*),'BEGIN-This is the repre
 
 SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
 ID	USER	HOST	DB	COMMAND	TIME	STATE	INFO
-<ID>	test_user	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	SELECT count(*),'BEGIN-This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.-END' AS "Long string" FROM test.t1
-<ID>	test_user	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	NULL
 <ID>	root	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
+<ID>	test_user	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	NULL
+<ID>	test_user	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	SELECT count(*),'BEGIN-This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.This is the representative of a very long statement.-END' AS "Long string" FROM test.t1
 SHOW FULL PROCESSLIST;
 Id	User	Host	db	Command	Time	State	Info
 <ID>	root	<HOST_NAME>	information_schema	<COMMAND>	<TIME>	<STATE>	SHOW FULL PROCESSLIST

=== modified file 'mysql-test/t/show_check.test'
--- a/mysql-test/t/show_check.test	2011-10-19 21:49:22 +0000
+++ b/mysql-test/t/show_check.test	2012-04-13 12:00:39 +0000
@@ -1359,9 +1359,11 @@ let $wait_timeout= 10;
 let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%GET_LOCK%' AND ID != CONNECTION_ID();
 --source include/wait_condition.inc
 --replace_column 1 ### 3 ### 6 ### 7 ###
+--sorted_result
 SHOW PROCESSLIST;
 SET NAMES utf8;
 --replace_column 1 ### 3 ### 6 ### 7 ###
+--sorted_result
 SHOW PROCESSLIST;
 SELECT RELEASE_LOCK('t');
 --connection con1

=== modified file 'mysql-test/t/sp-threads.test'
--- a/mysql-test/t/sp-threads.test	2009-02-09 21:00:15 +0000
+++ b/mysql-test/t/sp-threads.test	2012-04-13 12:00:39 +0000
@@ -82,6 +82,7 @@ connection con2root;
 --sleep 2
 # There should be call statement in locked state.
 --replace_column 1 # 3 localhost 6 #
+--sorted_result
 show processlist;
 unlock tables;
 connection con1root;

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2012-03-29 16:55:06 +0000
+++ b/sql/binlog.cc	2012-04-13 12:00:39 +0000
@@ -25,6 +25,7 @@
 #include "rpl_info_factory.h"
 #include "rpl_utility.h"
 #include "debug_sync.h"
+#include "global_threads.h"
 #include "sql_parse.h"
 #include <list>
 #include <string>
@@ -1303,15 +1304,14 @@ static int binlog_savepoint_rollback(han
 
 static void adjust_linfo_offsets(my_off_t purge_offset)
 {
-  THD *tmp;
-
   mysql_mutex_lock(&LOCK_thread_count);
-  I_List_iterator<THD> it(threads);
 
-  while ((tmp=it++))
+  Thread_iterator it= global_thread_list_begin();
+  Thread_iterator end= global_thread_list_end();
+  for (; it != end; ++it)
   {
     LOG_INFO* linfo;
-    if ((linfo = tmp->current_linfo))
+    if ((linfo = (*it)->current_linfo))
     {
       mysql_mutex_lock(&linfo->lock);
       /*
@@ -1333,16 +1333,16 @@ static void adjust_linfo_offsets(my_off_
 static bool log_in_use(const char* log_name)
 {
   size_t log_name_len = strlen(log_name) + 1;
-  THD *tmp;
   bool result = 0;
 
   mysql_mutex_lock(&LOCK_thread_count);
-  I_List_iterator<THD> it(threads);
 
-  while ((tmp=it++))
+  Thread_iterator it= global_thread_list_begin();
+  Thread_iterator end= global_thread_list_end();
+  for (; it != end; ++it)
   {
     LOG_INFO* linfo;
-    if ((linfo = tmp->current_linfo))
+    if ((linfo = (*it)->current_linfo))
     {
       mysql_mutex_lock(&linfo->lock);
       result = !memcmp(log_name, linfo->log_file_name, log_name_len);
@@ -1711,6 +1711,8 @@ bool show_binlog_events(THD *thd, MYSQL_
   IO_CACHE log;
   File file = -1;
   int old_max_allowed_packet= thd->variables.max_allowed_packet;
+  LOG_INFO linfo;
+
   DBUG_ENTER("show_binlog_events");
 
   DBUG_ASSERT(thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS ||
@@ -1728,7 +1730,6 @@ bool show_binlog_events(THD *thd, MYSQL_
     char search_file_name[FN_REFLEN], *name;
     const char *log_file_name = lex_mi->log_file_name;
     mysql_mutex_t *log_lock = binary_log->get_log_lock();
-    LOG_INFO linfo;
     Log_event* ev;
 
     unit->set_limit(thd->lex->current_select);

=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc	2012-03-06 14:29:42 +0000
+++ b/sql/event_scheduler.cc	2012-04-13 12:00:39 +0000
@@ -135,8 +135,7 @@ post_init_event_thread(THD *thd)
   }
 
   mysql_mutex_lock(&LOCK_thread_count);
-  threads.push_front(thd);
-  thread_count++;
+  add_global_thread(thd);
   inc_thread_running();
   mysql_mutex_unlock(&LOCK_thread_count);
   return FALSE;
@@ -159,11 +158,10 @@ deinit_event_thread(THD *thd)
   net_end(&thd->net);
   DBUG_PRINT("exit", ("Event thread finishing"));
   mysql_mutex_lock(&LOCK_thread_count);
-  thread_count--;
+  remove_global_thread(thd);
   dec_thread_running();
-  delete thd;
-  mysql_cond_broadcast(&COND_thread_count);
   mysql_mutex_unlock(&LOCK_thread_count);
+  delete thd;
 }
 
 
@@ -434,11 +432,10 @@ Event_scheduler::start()
     DBUG_ASSERT(new_thd->net.buff != 0);
     net_end(&new_thd->net);
     mysql_mutex_lock(&LOCK_thread_count);
-    thread_count--;
+    remove_global_thread(new_thd);
     dec_thread_running();
-    delete new_thd;
-    mysql_cond_broadcast(&COND_thread_count);
     mysql_mutex_unlock(&LOCK_thread_count);
+    delete new_thd;
   }
 end:
   UNLOCK_DATA();
@@ -568,11 +565,10 @@ error:
     DBUG_ASSERT(new_thd->net.buff != 0);
     net_end(&new_thd->net);
     mysql_mutex_lock(&LOCK_thread_count);
-    thread_count--;
+    remove_global_thread(new_thd);
     dec_thread_running();
-    delete new_thd;
-    mysql_cond_broadcast(&COND_thread_count);
     mysql_mutex_unlock(&LOCK_thread_count);
+    delete new_thd;
   }
   delete event_name;
   DBUG_RETURN(TRUE);
@@ -683,14 +679,14 @@ end:
 uint
 Event_scheduler::workers_count()
 {
-  THD *tmp;
   uint count= 0;
 
   DBUG_ENTER("Event_scheduler::workers_count");
-  mysql_mutex_lock(&LOCK_thread_count);       // For unlink from list
-  I_List_iterator<THD> it(threads);
-  while ((tmp=it++))
-    if (tmp->system_thread == SYSTEM_THREAD_EVENT_WORKER)
+  mysql_mutex_lock(&LOCK_thread_count);
+  Thread_iterator it= global_thread_list_begin();
+  Thread_iterator end= global_thread_list_end();
+  for (; it != end; ++it)
+    if ((*it)->system_thread == SYSTEM_THREAD_EVENT_WORKER)
       ++count;
   mysql_mutex_unlock(&LOCK_thread_count);
   DBUG_PRINT("exit", ("%d", count));

=== modified file 'sql/global_threads.h'
--- a/sql/global_threads.h	2012-02-15 13:57:17 +0000
+++ b/sql/global_threads.h	2012-04-13 12:00:39 +0000
@@ -16,13 +16,39 @@
 #ifndef GLOBAL_THREADS_INCLUDED
 #define GLOBAL_THREADS_INCLUDED
 
+#include <my_global.h>
+#include <my_pthread.h>
+#include <set>
+
+class THD;
+
+extern mysql_mutex_t LOCK_thread_count;
+extern mysql_cond_t COND_thread_count;
+
 /*
-  TODO: Make a proper interface for keeping track of global threads.
+  We maintail a set of all registered threads.
+  We provide acccessors to iterate over all threads.
+
+  We also provide mutators for inserting, and removing an element:
+  add_global_thread() inserts a THD into the set, and increments the counter.
+  remove_global_thread() removes a THD from the set, and decrements the counter.
+  remove_global_thread() also broadcasts COND_thread_count.
+
+  All functions must be called with LOCK_thread_count.
  */
-#include "sql_list.h"
-#include "sql_class.h"
+typedef std::set<THD*>::iterator Thread_iterator;
+Thread_iterator global_thread_list_begin();
+Thread_iterator global_thread_list_end();
+void add_global_thread(THD *);
+void remove_global_thread(THD *);
 
-extern I_List<THD> threads;
-extern uint volatile thread_count;
+/*
+  We maintain a separate counter for the number of threads,
+  which can be accessed without LOCK_thread_count.
+  An un-locked read, means that the result is fuzzy of course.
+  This accessor is used by DBUG printing, by signal handlers,
+  and by the 'mysqladmin status' command.
+*/
+uint get_thread_count();
 
 #endif  // GLOBAL_THREADS_INCLUDED

=== modified file 'sql/log.h'
--- a/sql/log.h	2012-03-09 16:56:10 +0000
+++ b/sql/log.h	2012-04-13 12:00:39 +0000
@@ -152,6 +152,11 @@ extern TC_LOG_DUMMY tc_log_dummy;
 extern PSI_mutex_key key_LOG_INFO_lock;
 #endif
 
+/*
+  Note that we destroy the lock mutex in the desctructor here.
+  This means that object instances cannot be destroyed/go out of scope,
+  until we have reset thd->current_linfo to NULL;
+ */
 typedef struct st_log_info
 {
   char log_file_name[FN_REFLEN];

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2012-04-10 11:25:38 +0000
+++ b/sql/mysqld.cc	2012-04-13 12:00:39 +0000
@@ -18,6 +18,8 @@
 #include <vector>
 #include <algorithm>
 #include <functional>
+#include <list>
+#include <set>
 
 #include "sql_priv.h"
 #include "unireg.h"
@@ -349,10 +351,9 @@ static bool volatile select_thread_in_us
 volatile bool ready_to_exit;
 static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
 static my_bool opt_short_log_format= 0;
-static uint kill_cached_threads, wake_thread;
+static uint kill_blocked_pthreads_flag, wake_pthread;
 static ulong killed_threads;
        ulong max_used_connections;
-static volatile ulong cached_thread_count= 0;
 static char *mysqld_user, *mysqld_chroot;
 static char *default_character_set_name;
 static char *character_set_filesystem_name;
@@ -363,7 +364,6 @@ static char *default_collation_name;
 char *default_storage_engine;
 char *default_tmp_storage_engine;
 static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
-static I_List<THD> thread_cache;
 static bool binlog_format_used= false;
 
 LEX_STRING opt_init_connect, opt_init_slave;
@@ -392,8 +392,7 @@ ulong log_warnings;
 ulong slow_start_timeout;
 #endif
 /*
-  True if the bootstrap thread is running. Protected by LOCK_thread_count,
-  just like thread_count.
+  True if the bootstrap thread is running. Protected by LOCK_thread_count.
   Used in bootstrap() function to determine if the bootstrap thread
   has completed. Note, that we can't use 'thread_count' instead,
   since in 5.1, in presence of the Event Scheduler, there may be
@@ -490,7 +489,6 @@ ulong delay_key_write_options;
 uint protocol_version;
 uint lower_case_table_names;
 ulong tc_heuristic_recover= 0;
-uint volatile thread_count;
 int32 thread_running;
 ulong thread_created;
 ulong back_log, connect_timeout, concurrency, server_id;
@@ -505,7 +503,6 @@ ulong slave_exec_mode_options;
 ulonglong slave_type_conversions_options;
 ulong opt_mts_slave_parallel_workers;
 ulonglong opt_mts_pending_jobs_size_max;
-ulong thread_cache_size=0;
 ulong binlog_cache_size=0;
 ulonglong  max_binlog_cache_size=0;
 ulong binlog_stmt_cache_size=0;
@@ -649,7 +646,6 @@ Le_creator le_creator;
 MYSQL_FILE *bootstrap_file;
 int bootstrap_error;
 
-I_List<THD> threads;
 Rpl_filter* rpl_filter;
 Rpl_filter* binlog_filter;
 
@@ -747,12 +743,87 @@ static char **remaining_argv;
 int orig_argc;
 char **orig_argv;
 
+static volatile sig_atomic_t global_thread_count= 0;
+static std::set<THD*> *global_thread_list= NULL;
+
+ulong max_blocked_pthreads= 0;
+static ulong blocked_pthread_count= 0;
+static std::list<THD*> *waiting_thd_list= NULL;
+
+/*
+  global_thread_list and waiting_thd_list are both pointers to objects
+  on the heap, to avoid potential problems with running destructors atexit().
+ */
+static void delete_global_thread_list()
+{
+  delete global_thread_list;
+  delete waiting_thd_list;
+  global_thread_list= NULL;
+  waiting_thd_list= NULL;
+}
+
+Thread_iterator global_thread_list_begin()
+{
+  mysql_mutex_assert_owner(&LOCK_thread_count);
+  return global_thread_list->begin();
+}
+
+Thread_iterator global_thread_list_end()
+{
+  mysql_mutex_assert_owner(&LOCK_thread_count);
+  return global_thread_list->end();
+}
+
+void add_global_thread(THD *thd)
+{
+  DBUG_PRINT("info", ("add_global_thread %p", thd));
+  mysql_mutex_assert_owner(&LOCK_thread_count);
+  const bool have_thread=
+    global_thread_list->find(thd) != global_thread_list->end();
+  if (!have_thread)
+  {
+    ++global_thread_count;
+    global_thread_list->insert(thd);
+  }
+  // Adding the same THD twice is an error.
+  DBUG_ASSERT(!have_thread);
+}
+
+void remove_global_thread(THD *thd)
+{
+  DBUG_PRINT("info", ("remove_global_thread %p current_linfo %p",
+                      thd, thd->current_linfo));
+  mysql_mutex_assert_owner(&LOCK_thread_count);
+
+  const size_t num_erased= global_thread_list->erase(thd);
+  if (num_erased == 1)
+    --global_thread_count;
+  // Removing a THD that was never added is an error.
+  DBUG_ASSERT(1 == num_erased);
+
+  mysql_cond_broadcast(&COND_thread_count);
+}
+
+uint get_thread_count()
+{
+  return (uint) global_thread_count;
+}
+
+
 void set_remaining_args(int argc, char **argv)
 {
   remaining_argc= argc;
   remaining_argv= argv;
 }
 
+ulong sql_rnd_with_mutex()
+{
+  mysql_mutex_lock(&LOCK_thread_count);
+  ulong tmp=(ulong) (my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */
+  mysql_mutex_unlock(&LOCK_thread_count);
+  return tmp;
+}
+
 #ifdef HAVE_PSI_STATEMENT_INTERFACE
 PSI_statement_info stmt_info_new_packet;
 #endif
@@ -1147,9 +1218,9 @@ static void close_connections(void)
 #endif
   DBUG_ENTER("close_connections");
 
-  /* Clear thread cache */
-  kill_cached_threads++;
-  flush_thread_cache();
+  /* Kill blocked pthreads */
+  kill_blocked_pthreads_flag++;
+  kill_blocked_pthreads();
 
   /* kill connection thread */
 #if !defined(__WIN__)
@@ -1240,14 +1311,14 @@ static void close_connections(void)
 
   sql_print_information("Giving client threads a chance to die gracefully");
 
-  THD *tmp;
-  mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
+  mysql_mutex_lock(&LOCK_thread_count);
 
-  I_List_iterator<THD> it(threads);
-  while ((tmp=it++))
+  Thread_iterator it= global_thread_list->begin();
+  for (; it != global_thread_list->end(); ++it)
   {
+    THD *tmp= *it;
     DBUG_PRINT("quit",("Informing thread %ld that it's time to die",
-           tmp->thread_id));
+                       tmp->thread_id));
     /* We skip slave threads & scheduler on this first loop through. */
     if (tmp->slave_thread)
       continue;
@@ -1269,14 +1340,14 @@ static void close_connections(void)
     }
     mysql_mutex_unlock(&tmp->LOCK_thd_data);
   }
-  mysql_mutex_unlock(&LOCK_thread_count); // For unlink from list
+  mysql_mutex_unlock(&LOCK_thread_count);
 
   Events::deinit();
 
   sql_print_information("Shutting down slave threads");
   end_slave();
 
-  if (thread_count)
+  if (get_thread_count() > 0)
     sleep(2);         // Give threads time to die
 
   /*
@@ -1286,17 +1357,13 @@ static void close_connections(void)
   */
 
   sql_print_information("Forcefully disconnecting remaining clients");
-  for (;;)
+
+#ifndef __bsdi__ // Bug in BSDI kernel
+  DBUG_PRINT("quit", ("Locking LOCK_thread_count"));
+  mysql_mutex_lock(&LOCK_thread_count);
+  for (it= global_thread_list->begin(); it != global_thread_list->end(); ++it)
   {
-    DBUG_PRINT("quit",("Locking LOCK_thread_count"));
-    mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
-    if (!(tmp=threads.get()))
-    {
-      DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
-      mysql_mutex_unlock(&LOCK_thread_count);
-      break;
-    }
-#ifndef __bsdi__        // Bug in BSDI kernel
+    THD *tmp= *it;
     if (tmp->vio_ok())
     {
       if (log_warnings)
@@ -1306,17 +1373,19 @@ static void close_connections(void)
                            tmp->main_security_ctx.user : ""));
       close_connection(tmp);
     }
-#endif
-    DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
-    mysql_mutex_unlock(&LOCK_thread_count);
   }
+  DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
+  mysql_mutex_unlock(&LOCK_thread_count);
+#endif // Bug in BSDI kernel
+
   /* All threads has now been aborted */
-  DBUG_PRINT("quit",("Waiting for threads to die (count=%u)",thread_count));
+  DBUG_PRINT("quit",("Waiting for threads to die (count=%u)",
+                     get_thread_count()));
   mysql_mutex_lock(&LOCK_thread_count);
-  while (thread_count)
+  while (get_thread_count() > 0)
   {
     mysql_cond_wait(&COND_thread_count, &LOCK_thread_count);
-    DBUG_PRINT("quit",("One thread died (count=%u)",thread_count));
+    DBUG_PRINT("quit", ("One thread died (count=%u)", get_thread_count()));
   }
   mysql_mutex_unlock(&LOCK_thread_count);
 
@@ -1672,6 +1741,7 @@ void clean_up(bool print_message)
   mysql_cond_broadcast(&COND_thread_count);
   mysql_mutex_unlock(&LOCK_thread_count);
   sys_var_end();
+  delete_global_thread_list();
 
   my_free(const_cast<char*>(log_bin_basename));
   my_free(const_cast<char*>(log_bin_index));
@@ -2259,13 +2329,12 @@ void close_connection(THD *thd, uint sql
 extern "C" sig_handler end_thread_signal(int sig __attribute__((unused)))
 {
   THD *thd=current_thd;
-  DBUG_ENTER("end_thread_signal");
+  my_safe_printf_stderr("end_thread_signal %p", thd);
   if (thd && ! thd->bootstrap)
   {
     statistic_increment(killed_threads, &LOCK_status);
     MYSQL_CALLBACK(thread_scheduler, end_thread, (thd,0)); /* purecov: inspected */
   }
-  DBUG_VOID_RETURN;       /* purecov: deadcode */
 }
 
 
@@ -2307,85 +2376,54 @@ void dec_connection_count()
 
 void delete_thd(THD *thd)
 {
-  thread_count--;
+  mysql_mutex_assert_owner(&LOCK_thread_count);
+  remove_global_thread(thd);
   delete thd;
 }
 
 
-/*
-  Unlink thd from global list of available connections and free thd
-
-  SYNOPSIS
-    unlink_thd()
-    thd    Thread handler
+/**
+  Block the current pthread for reuse by new connections.
 
-  NOTES
-    LOCK_thread_count is locked and left locked
+  @retval false  Pthread was not blocked for reuse.
+  @retval true   Pthread is to be reused by new connection.
+                 (ie, caller should return, not abort with pthread_exit())
 */
 
-void unlink_thd(THD *thd)
+static bool block_until_new_connection()
 {
-  DBUG_ENTER("unlink_thd");
-  DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
-
-  thd_cleanup(thd);
-  dec_connection_count();
   mysql_mutex_lock(&LOCK_thread_count);
-  /*
-    Used by binlog_reset_master.  It would be cleaner to use
-    DEBUG_SYNC here, but that's not possible because the THD's debug
-    sync feature has been shut down at this point.
-  */
-  DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd", sleep(5););
-  delete_thd(thd);
-  DBUG_VOID_RETURN;
-}
-
-
-/*
-  Store thread in cache for reuse by new connections
-
-  SYNOPSIS
-    cache_thread()
-
-  NOTES
-    LOCK_thread_count has to be locked
-
-  RETURN
-    0  Thread was not put in cache
-    1  Thread is to be reused by new connection.
-       (ie, caller should return, not abort with pthread_exit())
-*/
-
-
-static bool cache_thread()
-{
-  mysql_mutex_assert_owner(&LOCK_thread_count);
-  if (cached_thread_count < thread_cache_size &&
-      ! abort_loop && !kill_cached_threads)
+  if (blocked_pthread_count < max_blocked_pthreads &&
+      !abort_loop && !kill_blocked_pthreads_flag)
   {
-    /* Don't kill the thread, just put it in cache for reuse */
-    DBUG_PRINT("info", ("Adding thread to cache"));
-    cached_thread_count++;
+    /* Don't kill the pthread, just block it for reuse */
+    DBUG_PRINT("info", ("Blocking pthread for reuse"));
+    blocked_pthread_count++;
 
 #ifdef HAVE_PSI_THREAD_INTERFACE
     /*
       Delete the instrumentation for the job that just completed,
-      before parking this pthread in the cache (blocked on COND_thread_cache).
+      before blocking this pthread (blocked on COND_thread_cache).
     */
     PSI_CALL(delete_current_thread)();
 #endif
 
-    while (!abort_loop && ! wake_thread && ! kill_cached_threads)
+    // Block pthread
+    while (!abort_loop && !wake_pthread && !kill_blocked_pthreads_flag)
       mysql_cond_wait(&COND_thread_cache, &LOCK_thread_count);
-    cached_thread_count--;
-    if (kill_cached_threads)
+
+    blocked_pthread_count--;
+    if (kill_blocked_pthreads_flag)
       mysql_cond_signal(&COND_flush_thread_cache);
-    if (wake_thread)
+    if (wake_pthread)
     {
       THD *thd;
-      wake_thread--;
-      thd= thread_cache.get();
+      wake_pthread--;
+      DBUG_ASSERT(!waiting_thd_list->empty());
+      thd= waiting_thd_list->front();
+      waiting_thd_list->pop_front();
+      DBUG_PRINT("info", ("waiting_thd_list->pop %p", thd));
+
       thd->thread_stack= (char*) &thd;          // For store_globals
       (void) thd->store_globals();
 
@@ -2406,42 +2444,55 @@ static bool cache_thread()
       */
       thd->mysys_var->abort= 0;
       thd->thr_create_utime= my_micro_time();
-      threads.push_front(thd);
-      return(1);
+      add_global_thread(thd);
+      mysql_mutex_unlock(&LOCK_thread_count);
+      return true;
     }
   }
-  return(0);
+  mysql_mutex_unlock(&LOCK_thread_count);
+  return false;
 }
 
 
-/*
+/**
   End thread for the current connection
 
-  SYNOPSIS
-    one_thread_per_connection_end()
-    thd     Thread handler
-    put_in_cache  Store thread in cache, if there is room in it
-                  Normally this is true in all cases except when we got
-                  out of resources initializing the current thread
-
-  NOTES
-    If thread is cached, we will wait until thread is scheduled to be
-    reused and then we will return.
-    If thread is not cached, we end the thread.
+  @param thd            Thread handler
+  @param block_pthread  Block the pthread so it can be reused later.
+                        Normally this is true in all cases except when we got
+                        out of resources initializing the current thread
+
+  @retval false  Signal to handle_one_connection to reuse connection
 
-  RETURN
-    0    Signal to handle_one_connection to reuse connection
+  @note If the pthread is blocked, we will wait until the pthread is
+        scheduled to be reused and then return.
+        If the pthread is not to be blocked, it will be ended.
 */
 
-bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
+bool one_thread_per_connection_end(THD *thd, bool block_pthread)
 {
   DBUG_ENTER("one_thread_per_connection_end");
-  unlink_thd(thd);
-  if (put_in_cache)
-    put_in_cache= cache_thread();
+  DBUG_PRINT("info", ("thd %p block_pthread %d", thd, (int) block_pthread));
+
+  thd->cleanup();
+  dec_connection_count();
+
+  mysql_mutex_lock(&LOCK_thread_count);
+  /*
+    Used by binlog_reset_master.  It would be cleaner to use
+    DEBUG_SYNC here, but that's not possible because the THD's debug
+    sync feature has been shut down at this point.
+  */
+  DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd", sleep(5););
+  remove_global_thread(thd);
   mysql_mutex_unlock(&LOCK_thread_count);
-  if (put_in_cache)
-    DBUG_RETURN(0);                             // Thread is reused
+  delete thd;
+
+  if (block_pthread)
+    block_pthread= block_until_new_connection();
+
+  if (block_pthread)
+    DBUG_RETURN(false);                         // Pthread is reused
 
   /* It's safe to broadcast outside a lock (COND... is not deleted here) */
   DBUG_PRINT("signal", ("Broadcasting COND_thread_count"));
@@ -2450,20 +2501,20 @@ bool one_thread_per_connection_end(THD *
   mysql_cond_broadcast(&COND_thread_count);
 
   pthread_exit(0);
-  return 0;                                     // Avoid compiler warnings
+  return false;                                 // Avoid compiler warnings
 }
 
 
-void flush_thread_cache()
+void kill_blocked_pthreads()
 {
   mysql_mutex_lock(&LOCK_thread_count);
-  kill_cached_threads++;
-  while (cached_thread_count)
+  kill_blocked_pthreads_flag++;
+  while (blocked_pthread_count)
   {
     mysql_cond_broadcast(&COND_thread_cache);
     mysql_cond_wait(&COND_flush_thread_cache, &LOCK_thread_count);
   }
-  kill_cached_threads--;
+  kill_blocked_pthreads_flag--;
   mysql_mutex_unlock(&LOCK_thread_count);
 }
 
@@ -2871,19 +2922,19 @@ pthread_handler_t signal_hand(void *arg 
       DBUG_PRINT("info",("Got signal: %d  abort_loop: %d",sig,abort_loop));
       if (!abort_loop)
       {
-  abort_loop=1;       // mark abort for threads
+        abort_loop=1;       // mark abort for threads
 #ifdef HAVE_PSI_THREAD_INTERFACE
         /* Delete the instrumentation for the signal thread */
         PSI_CALL(delete_current_thread)();
 #endif
 #ifdef USE_ONE_SIGNAL_HAND
-  pthread_t tmp;
+        pthread_t tmp;
         if (mysql_thread_create(0, /* Not instrumented */
                                 &tmp, &connection_attrib, kill_server_thread,
                                 (void*) &sig))
-    sql_print_error("Can't create thread to kill server");
+          sql_print_error("Can't create thread to kill server");
 #else
-  kill_server((void*) sig); // MIT THREAD has a alarm thread
+        kill_server((void*) sig); // MIT THREAD has a alarm thread
 #endif
       }
       break;
@@ -5185,6 +5236,12 @@ int mysqld_main(int argc, char **argv)
   if (opt_bootstrap)
   {
     select_thread_in_use= 0;                    // Allow 'kill' to work
+    /* Signal threads waiting for server to be started */
+    mysql_mutex_lock(&LOCK_server_started);
+    mysqld_server_started= 1;
+    mysql_cond_signal(&COND_server_started);
+    mysql_mutex_unlock(&LOCK_server_started);
+
     bootstrap(mysql_stdin);
     unireg_abort(bootstrap_error ? 1 : 0);
   }
@@ -5507,7 +5564,7 @@ static void bootstrap(MYSQL_FILE *file)
   thd->max_client_packet_length= thd->net.max_packet;
   thd->security_ctx->master_access= ~(ulong)0;
   thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
-  thread_count++;
+
   in_bootstrap= TRUE;
 
   bootstrap_file=file;
@@ -5525,7 +5582,7 @@ static void bootstrap(MYSQL_FILE *file)
   while (in_bootstrap)
   {
     mysql_cond_wait(&COND_thread_count, &LOCK_thread_count);
-    DBUG_PRINT("quit",("One thread died (count=%u)",thread_count));
+    DBUG_PRINT("quit", ("One thread died (count=%u)", get_thread_count()));
   }
   mysql_mutex_unlock(&LOCK_thread_count);
 #else
@@ -5574,14 +5631,14 @@ void inc_thread_created(void)
      This is only used for debugging, when starting mysqld with
      --thread-handling=no-threads or --one-thread
 
-     When we enter this function, LOCK_thread_count is hold!
+     When we enter this function, LOCK_thread_count is held!
 */
 
 void handle_connection_in_main_thread(THD *thd)
 {
   mysql_mutex_assert_owner(&LOCK_thread_count);
-  thread_cache_size=0;      // Safety
-  threads.push_front(thd);
+  max_blocked_pthreads= 0;      // Safety
+  add_global_thread(thd);
   mysql_mutex_unlock(&LOCK_thread_count);
   thd->start_utime= my_micro_time();
   do_handle_one_connection(thd);
@@ -5594,11 +5651,13 @@ void handle_connection_in_main_thread(TH
 
 void create_thread_to_handle_connection(THD *thd)
 {
-  if (cached_thread_count > wake_thread)
+  mysql_mutex_assert_owner(&LOCK_thread_count);
+  if (blocked_pthread_count >  wake_pthread)
   {
-    /* Get thread from cache */
-    thread_cache.push_front(thd);
-    wake_thread++;
+    /* Wake up blocked pthread */
+    DBUG_PRINT("info", ("waiting_thd_list->push %p", thd));
+    waiting_thd_list->push_front(thd);
+    wake_pthread++;
     mysql_cond_signal(&COND_thread_cache);
   }
   else
@@ -5607,7 +5666,7 @@ void create_thread_to_handle_connection(
     /* Create new thread to handle connection */
     int error;
     thread_created++;
-    threads.push_front(thd);
+    add_global_thread(thd);
     DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id));
     thd->prior_thr_create_utime= thd->start_utime= my_micro_time();
     if ((error= mysql_thread_create(key_thread_one_connection,
@@ -5619,7 +5678,7 @@ void create_thread_to_handle_connection(
       DBUG_PRINT("error",
                  ("Can't create thread to handle request (error %d)",
                   error));
-      thread_count--;
+      remove_global_thread(thd);
       thd->killed= THD::KILL_CONNECTION;      // Safety
       mysql_mutex_unlock(&LOCK_thread_count);
 
@@ -5634,9 +5693,7 @@ void create_thread_to_handle_connection(
                   ER_THD(thd, ER_CANT_CREATE_THREAD), error);
       net_send_error(thd, ER_CANT_CREATE_THREAD, error_message_buff, NULL);
       close_connection(thd);
-      mysql_mutex_lock(&LOCK_thread_count);
       delete thd;
-      mysql_mutex_unlock(&LOCK_thread_count);
       return;
       /* purecov: end */
     }
@@ -5651,7 +5708,6 @@ void create_thread_to_handle_connection(
 
     This function will create new thread to handle the incoming
     connection.  If there are idle cached threads one will be used.
-    'thd' will be pushed into 'threads'.
 
     In single-threaded mode (\#define ONE_THREAD) connection will be
     handled inside this function.
@@ -5711,8 +5767,6 @@ static void create_new_thread(THD *thd)
   */
   thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
 
-  thread_count++;
-
   MYSQL_CALLBACK(thread_scheduler, add_connection, (thd));
 
   DBUG_VOID_RETURN;
@@ -7389,7 +7443,7 @@ SHOW_VAR status_vars[]= {
   {"Tc_log_page_size",         (char*) &tc_log_page_size,       SHOW_LONG},
   {"Tc_log_page_waits",        (char*) &tc_log_page_waits,      SHOW_LONG},
 #endif
-  {"Threads_cached",           (char*) &cached_thread_count,    SHOW_LONG_NOFLUSH},
+  {"Threads_cached",           (char*) &blocked_pthread_count,    SHOW_LONG_NOFLUSH},
   {"Threads_connected",        (char*) &connection_count,       SHOW_INT},
   {"Threads_created",        (char*) &thread_created,   SHOW_LONG_NOFLUSH},
   {"Threads_running",          (char*) &thread_running,         SHOW_INT},
@@ -7546,9 +7600,9 @@ static int mysql_init_variables(void)
   cleanup_done= 0;
   server_id_supplied= 0;
   test_flags= select_errors= dropping_tables= ha_open_options=0;
-  thread_count= thread_running= kill_cached_threads= wake_thread=0;
+  global_thread_count= thread_running= kill_blocked_pthreads_flag= wake_pthread=0;
   slave_open_temp_tables= 0;
-  cached_thread_count= 0;
+  blocked_pthread_count= 0;
   opt_endinfo= using_udf_functions= 0;
   opt_using_transactions= 0;
   abort_loop= select_thread_in_use= signal_thread_in_use= 0;
@@ -7593,8 +7647,8 @@ static int mysql_init_variables(void)
   my_atomic_rwlock_init(&global_query_id_lock);
   my_atomic_rwlock_init(&thread_running_lock);
   strmov(server_version, MYSQL_SERVER_VERSION);
-  threads.empty();
-  thread_cache.empty();
+  global_thread_list= new std::set<THD*>;
+  waiting_thd_list= new std::list<THD*>;
   key_caches.empty();
   if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str,
                                                 default_key_cache_base.length)))
@@ -8614,7 +8668,7 @@ void refresh_status(THD *thd)
     not exact anyway.
   */
   mysql_mutex_lock(&LOCK_thread_count);
-  max_used_connections= thread_count-delayed_insert_threads;
+  max_used_connections= get_thread_count() - delayed_insert_threads;
   mysql_mutex_unlock(&LOCK_thread_count);
 }
 

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2012-03-31 18:30:05 +0000
+++ b/sql/mysqld.h	2012-04-13 12:00:39 +0000
@@ -68,11 +68,12 @@ void kill_mysql(void);
 void close_connection(THD *thd, uint sql_errno= 0);
 void handle_connection_in_main_thread(THD *thd);
 void create_thread_to_handle_connection(THD *thd);
-void unlink_thd(THD *thd);
-bool one_thread_per_connection_end(THD *thd, bool put_in_cache);
-void flush_thread_cache();
+void delete_thd(THD *thd);
+bool one_thread_per_connection_end(THD *thd, bool block_pthread);
+void kill_blocked_pthreads();
 void refresh_status(THD *thd);
 bool is_secure_file_path(char *path);
+void dec_connection_count();
 
 // These are needed for unit testing.
 void set_remaining_args(int argc, char **argv);
@@ -216,7 +217,7 @@ extern ulong gtid_mode;
 extern const char *gtid_mode_names[];
 extern TYPELIB gtid_mode_typelib;
 
-extern ulong thread_cache_size;
+extern ulong max_blocked_pthreads;
 extern ulong stored_program_cache_size;
 extern ulong back_log;
 extern char language[FN_REFLEN];
@@ -517,7 +518,6 @@ extern mysql_mutex_t
        LOCK_slave_list, LOCK_active_mi, LOCK_manager,
        LOCK_global_system_variables, LOCK_user_conn, LOCK_log_throttle_qni,
        LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count;
-extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_thread_count;
 #ifdef HAVE_OPENSSL
 extern mysql_mutex_t LOCK_des_key_file;
 #endif
@@ -525,7 +525,6 @@ extern mysql_mutex_t LOCK_server_started
 extern mysql_cond_t COND_server_started;
 extern mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
 extern mysql_rwlock_t LOCK_system_variables_hash;
-extern mysql_cond_t COND_thread_count;
 extern mysql_cond_t COND_manager;
 extern int32 thread_running;
 extern my_atomic_rwlock_t thread_running_lock;
@@ -661,13 +660,7 @@ inline void table_case_convert(char * na
                                      name, length, name, length);
 }
 
-inline ulong sql_rnd_with_mutex()
-{
-  mysql_mutex_lock(&LOCK_thread_count);
-  ulong tmp=(ulong) (my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */
-  mysql_mutex_unlock(&LOCK_thread_count);
-  return tmp;
-}
+ulong sql_rnd_with_mutex();
 
 inline int32
 inc_thread_running()

=== modified file 'sql/rpl_master.cc'
--- a/sql/rpl_master.cc	2012-03-14 09:52:49 +0000
+++ b/sql/rpl_master.cc	2012-04-13 12:00:39 +0000
@@ -1644,18 +1644,19 @@ void kill_zombie_dump_threads(String *sl
   DBUG_ASSERT(slave_uuid->length() == UUID_LENGTH);
 
   mysql_mutex_lock(&LOCK_thread_count);
-  I_List_iterator<THD> it(threads);
-  THD *tmp;
-
-  while ((tmp=it++))
+  THD *tmp= NULL;
+  Thread_iterator it= global_thread_list_begin();
+  Thread_iterator end= global_thread_list_end();
+  for (; it != end; ++it)
   {
-    if (tmp != current_thd && (tmp->get_command() == COM_BINLOG_DUMP ||
-        tmp->get_command() == COM_BINLOG_DUMP_GTID))
+    if ((*it) != current_thd && ((*it)->get_command() == COM_BINLOG_DUMP ||
+                                 (*it)->get_command() == COM_BINLOG_DUMP_GTID))
     {
       String tmp_uuid;
-      if (get_slave_uuid(tmp, &tmp_uuid) != NULL &&
+      if (get_slave_uuid((*it), &tmp_uuid) != NULL &&
           !strncmp(slave_uuid->c_ptr(), tmp_uuid.c_ptr(), UUID_LENGTH))
       {
+        tmp= *it;
         mysql_mutex_lock(&tmp->LOCK_thd_data);	// Lock from delete
         break;
       }

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2012-04-11 16:52:28 +0000
+++ b/sql/rpl_slave.cc	2012-04-13 12:00:39 +0000
@@ -53,6 +53,7 @@
                                                 // Format_description_log_event
 #include "dynamic_ids.h"
 #include "rpl_rli_pdb.h"
+#include "global_threads.h"
 
 #ifdef HAVE_REPLICATION
 
@@ -3803,6 +3804,7 @@ static int try_to_reconnect(THD *thd, MY
 pthread_handler_t handle_slave_io(void *arg)
 {
   THD *thd= NULL; // needs to be first for thread_stack
+  bool thd_added= false;
   MYSQL *mysql;
   Master_info *mi = (Master_info*)arg;
   Relay_log_info *rli= mi->rli;
@@ -3843,9 +3845,12 @@ pthread_handler_t handle_slave_io(void *
     sql_print_error("Failed during slave I/O thread initialization");
     goto err;
   }
+
   mysql_mutex_lock(&LOCK_thread_count);
-  threads.push_front(thd);
+  add_global_thread(thd);
+  thd_added= true;
   mysql_mutex_unlock(&LOCK_thread_count);
+
   mi->slave_running = 1;
   mi->abort_slave = 0;
   mysql_mutex_unlock(&mi->run_lock);
@@ -4173,8 +4178,10 @@ err:
   net_end(&thd->net); // destructor will not free it, because net.vio is 0
   mysql_mutex_lock(&LOCK_thread_count);
   THD_CHECK_SENTRY(thd);
-  delete thd;
+  if (thd_added)
+    remove_global_thread(thd);
   mysql_mutex_unlock(&LOCK_thread_count);
+  delete thd;
   mi->abort_slave= 0;
   mi->slave_running= 0;
   mi->info_thd= 0;
@@ -4246,6 +4253,7 @@ int check_temp_dir(char* tmp_file)
 pthread_handler_t handle_slave_worker(void *arg)
 {
   THD *thd;                     /* needs to be first for thread_stack */
+  bool thd_added= false;
   int error= 0;
   Slave_worker *w= (Slave_worker *) arg;
   Relay_log_info* rli= w->c_rli;
@@ -4273,8 +4281,10 @@ pthread_handler_t handle_slave_worker(vo
     goto err;
   }
   thd->init_for_queries();
+
   mysql_mutex_lock(&LOCK_thread_count);
-  threads.push_front(thd);
+  add_global_thread(thd);
+  thd_added= true;
   mysql_mutex_unlock(&LOCK_thread_count);
 
   if (w->update_is_transactional())
@@ -4360,8 +4370,10 @@ err:
       are Coordinator's burden.
     */
     thd->system_thread= NON_SYSTEM_THREAD;
-    delete thd;
+    if (thd_added)
+      remove_global_thread(thd);
     mysql_mutex_unlock(&LOCK_thread_count);
+    delete thd;
   }
 
   my_thread_end();
@@ -5112,6 +5124,7 @@ end:
 pthread_handler_t handle_slave_sql(void *arg)
 {
   THD *thd;                     /* needs to be first for thread_stack */
+  bool thd_added= false;
   char llbuff[22],llbuff1[22];
   char saved_log_name[FN_REFLEN];
   char saved_master_log_name[FN_REFLEN];
@@ -5160,8 +5173,10 @@ pthread_handler_t handle_slave_sql(void 
   thd->init_for_queries();
   thd->temporary_tables = rli->save_temporary_tables; // restore temp tables
   set_thd_in_use_temporary_tables(rli);   // (re)set sql_thd in use for saved temp tables
+
   mysql_mutex_lock(&LOCK_thread_count);
-  threads.push_front(thd);
+  add_global_thread(thd);
+  thd_added= true;
   mysql_mutex_unlock(&LOCK_thread_count);
 
   /* MTS: starting the worker pool */
@@ -5478,8 +5493,10 @@ llstr(rli->get_group_master_log_pos(), l
   set_thd_in_use_temporary_tables(rli);  // (re)set info_thd in use for saved temp tables
   mysql_mutex_lock(&LOCK_thread_count);
   THD_CHECK_SENTRY(thd);
-  delete thd;
+  if (thd_added)
+    remove_global_thread(thd);
   mysql_mutex_unlock(&LOCK_thread_count);
+  delete thd;
  /*
   Note: the order of the broadcast and unlock calls below (first broadcast, then unlock)
   is important. Otherwise a killer_thread can execute between the calls and

=== modified file 'sql/rpl_slave.h'
--- a/sql/rpl_slave.h	2012-04-11 16:52:28 +0000
+++ b/sql/rpl_slave.h	2012-04-13 12:00:39 +0000
@@ -248,8 +248,6 @@ extern my_bool master_ssl;
 extern char *master_ssl_ca, *master_ssl_capath, *master_ssl_cert;
 extern char *master_ssl_cipher, *master_ssl_key;
        
-extern I_List<THD> threads;
-
 int mts_recovery_groups(Relay_log_info *rli);
 bool mts_checkpoint_routine(Relay_log_info *rli, ulonglong period,
                             bool force, bool locked);

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2011-09-07 10:08:09 +0000
+++ b/sql/scheduler.cc	2012-04-13 12:00:39 +0000
@@ -23,6 +23,8 @@
 #include "sql_connect.h"         // init_new_connection_handler_thread
 #include "scheduler.h"
 #include "sql_callback.h"
+#include "global_threads.h"
+#include "mysql/thread_pool_priv.h"
 
 /*
   End connection, in case when we are using 'no-threads'
@@ -30,8 +32,14 @@
 
 static bool no_threads_end(THD *thd, bool put_in_cache)
 {
-  unlink_thd(thd);
+  thd_cleanup(thd);
+  dec_connection_count();
+
+  // THD is an incomplete type here, so use delete_thd() to delete it.
+  mysql_mutex_lock(&LOCK_thread_count);
+  delete_thd(thd);
   mysql_mutex_unlock(&LOCK_thread_count);
+
   return 1;                                     // Abort handle_one_connection
 }
 

=== modified file 'sql/signal_handler.cc'
--- a/sql/signal_handler.cc	2012-03-06 12:56:57 +0000
+++ b/sql/signal_handler.cc	2012-04-13 12:00:39 +0000
@@ -114,7 +114,7 @@ extern "C" sig_handler handle_fatal_sign
   my_safe_printf_stderr("max_threads=%u\n",
                         (uint) thread_scheduler->max_threads);
 
-  my_safe_printf_stderr("thread_count=%u\n", (uint) thread_count);
+  my_safe_printf_stderr("thread_count=%u\n", get_thread_count());
 
   my_safe_printf_stderr("connection_count=%u\n", (uint) connection_count);
 

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2012-04-12 15:31:01 +0000
+++ b/sql/sp_head.cc	2012-04-13 12:00:39 +0000
@@ -38,6 +38,7 @@
 #include "sql_base.h"                           // close_thread_tables
 #include "transaction.h"       // trans_commit_stmt
 #include "opt_trace.h"         // opt_trace_disable_etc
+#include "global_threads.h"
 
 #include <algorithm>
 

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2012-03-30 15:38:01 +0000
+++ b/sql/sql_class.cc	2012-04-13 12:00:39 +0000
@@ -336,11 +336,15 @@ THD *thd_get_current_thd()
 
   thd_new_connection_setup
 
+  @note Must be called with LOCK_thread_count locked.
+
   @param              thd            THD object
   @param              stack_start    Start of stack for connection
 */
 void thd_new_connection_setup(THD *thd, char *stack_start)
 {
+  DBUG_ENTER("thd_new_connection_setup");
+  mysql_mutex_assert_owner(&LOCK_thread_count);
 #ifdef HAVE_PSI_INTERFACE
   thd_set_psi(thd,
               PSI_CALL(new_thread)(key_thread_one_connection,
@@ -350,11 +354,14 @@ void thd_new_connection_setup(THD *thd, 
   thd->set_time();
   thd->prior_thr_create_utime= thd->thr_create_utime= thd->start_utime=
     my_micro_time();
-  threads.push_front(thd);
-  thd_unlock_thread_count(thd);
+
+  add_global_thread(thd);
+  mysql_mutex_unlock(&LOCK_thread_count);
+
   DBUG_PRINT("info", ("init new connection. thd: 0x%lx fd: %d",
           (ulong)thd, mysql_socket_getfd(thd->net.vio->mysql_socket)));
   thd_set_thread_stack(thd, stack_start);
+  DBUG_VOID_RETURN;
 }
 
 /**
@@ -1397,6 +1404,7 @@ THD::~THD()
 {
   THD_CHECK_SENTRY(this);
   DBUG_ENTER("~THD()");
+  DBUG_PRINT("info", ("THD dtor, this %p", this));
   /* Ensure that no one is using THD */
   mysql_mutex_lock(&LOCK_thd_data);
   mysys_var=0;					// Safety (shouldn't be needed)

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2012-04-12 14:29:14 +0000
+++ b/sql/sql_class.h	2012-04-13 12:00:39 +0000
@@ -2163,10 +2163,9 @@ my_micro_time_to_timeval(ulonglong micro
   a thread/connection descriptor
 */
 
-class THD :public ilink<THD>,
+class THD :public MDL_context_owner,
            public Statement,
-           public Open_tables_state,
-           public MDL_context_owner
+           public Open_tables_state
 {
 private:
   inline bool is_stmt_prepare() const

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2012-03-20 08:01:58 +0000
+++ b/sql/sql_insert.cc	2012-04-13 12:00:39 +0000
@@ -2073,13 +2073,11 @@ public:
     mysql_mutex_destroy(&mutex);
     mysql_cond_destroy(&cond);
     mysql_cond_destroy(&cond_client);
-    thd.unlink();				// Must be unlinked under lock
+    remove_global_thread(&thd);         // Must be removed under lock
     my_free(table_list.table_name);
     thd.security_ctx->user= thd.security_ctx->host=0;
-    thread_count--;
     delayed_insert_threads--;
     mysql_mutex_unlock(&LOCK_thread_count);
-    mysql_cond_broadcast(&COND_thread_count); /* Tell main we are ready */
   }
 
   /* The following is for checking when we can delete ourselves */
@@ -2218,9 +2216,6 @@ bool delayed_get_table(THD *thd, MDL_req
     {
       if (!(di= new Delayed_insert()))
         goto end_create;
-      mysql_mutex_lock(&LOCK_thread_count);
-      thread_count++;
-      mysql_mutex_unlock(&LOCK_thread_count);
       di->table_list= *table_list;			// Needed to open table
       /* Replace volatile strings with local copies */
       di->thd.set_db(table_list->db, (uint) strlen(table_list->db));
@@ -2703,7 +2698,7 @@ pthread_handler_t handle_delayed_insert(
   mysql_mutex_lock(&LOCK_thread_count);
   thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
   thd->set_current_time();
-  threads.push_front(thd);
+  add_global_thread(thd);
   thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
   mysql_mutex_unlock(&LOCK_thread_count);
 

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2012-04-04 07:06:53 +0000
+++ b/sql/sql_parse.cc	2012-04-13 12:00:39 +0000
@@ -778,6 +778,7 @@ pthread_handler_t handle_bootstrap(void 
 
 void do_handle_bootstrap(THD *thd)
 {
+  bool thd_added= false;
   /* The following must be called before DBUG_ENTER */
   thd->thread_stack= (char*) &thd;
   if (my_thread_init() || thd->store_globals())
@@ -789,19 +790,30 @@ void do_handle_bootstrap(THD *thd)
     goto end;
   }
 
+  mysql_mutex_lock(&LOCK_thread_count);
+  thd_added= true;
+  add_global_thread(thd);
+  mysql_mutex_unlock(&LOCK_thread_count);
+
   handle_bootstrap_impl(thd);
 
 end:
   net_end(&thd->net);
   thd->cleanup();
-  delete thd;
 
-#ifndef EMBEDDED_LIBRARY
+  /*
+    Here we delete the thd while holding the LOCK_thread_count.
+    The reason is that we have to call ha_close_connection(thd)
+    before shutting down InnoDB (this is done by THD::~THD())
+  */
   mysql_mutex_lock(&LOCK_thread_count);
-  thread_count--;
+  if (thd_added)
+    remove_global_thread(thd);
   in_bootstrap= FALSE;
-  mysql_cond_broadcast(&COND_thread_count);
+  delete thd;
   mysql_mutex_unlock(&LOCK_thread_count);
+
+#ifndef EMBEDDED_LIBRARY
   my_thread_end();
   pthread_exit(0);
 #endif
@@ -1547,7 +1559,7 @@ bool dispatch_command(enum enum_server_c
                         "Slow queries: %llu  Opens: %llu  Flush tables: %lu  "
                         "Open tables: %u  Queries per second avg: %u.%03u",
                         uptime,
-                        (int) thread_count, (ulong) thd->query_id,
+                        (int) get_thread_count(), (ulong) thd->query_id,
                         current_global_status_var.long_query_count,
                         current_global_status_var.opened_tables,
                         refresh_version,
@@ -6861,18 +6873,21 @@ void add_join_natural(TABLE_LIST *a, TAB
 
 uint kill_one_thread(THD *thd, ulong id, bool only_kill_query)
 {
-  THD *tmp;
+  THD *tmp= NULL;
   uint error=ER_NO_SUCH_THREAD;
   DBUG_ENTER("kill_one_thread");
   DBUG_PRINT("enter", ("id=%lu only_kill=%d", id, only_kill_query));
-  mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
-  I_List_iterator<THD> it(threads);
-  while ((tmp=it++))
+
+  mysql_mutex_lock(&LOCK_thread_count);
+  Thread_iterator it= global_thread_list_begin();
+  Thread_iterator end= global_thread_list_end();
+  for (; it != end; ++it)
   {
-    if (tmp->get_command() == COM_DAEMON)
+    if ((*it)->get_command() == COM_DAEMON)
       continue;
-    if (tmp->thread_id == id)
+    if ((*it)->thread_id == id)
     {
+      tmp= *it;
       mysql_mutex_lock(&tmp->LOCK_thd_data);    // Lock from delete
       break;
     }

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2012-03-31 18:30:05 +0000
+++ b/sql/sql_plugin.cc	2012-04-13 12:00:39 +0000
@@ -757,9 +757,8 @@ static plugin_ref intern_plugin_lock(LEX
     *plugin= pi;
 #endif
     pi->ref_count++;
-    DBUG_PRINT("info",("thd: 0x%lx, plugin: \"%s\", ref_count: %d",
-                       (long) current_thd, pi->name.str, pi->ref_count));
-
+    DBUG_PRINT("info",("thd: %p, plugin: \"%s\", ref_count: %d",
+                       current_thd, pi->name.str, pi->ref_count));
     if (lex)
       insert_dynamic(&lex->plugins, &plugin);
     DBUG_RETURN(plugin);

=== modified file 'sql/sql_reload.cc'
--- a/sql/sql_reload.cc	2012-03-14 09:52:49 +0000
+++ b/sql/sql_reload.cc	2012-04-13 12:00:39 +0000
@@ -286,7 +286,7 @@ bool reload_acl_and_cache(THD *thd, unsi
   if (thd && (options & REFRESH_STATUS))
     refresh_status(thd);
   if (options & REFRESH_THREADS)
-    flush_thread_cache();
+    kill_blocked_pthreads();
 #ifdef HAVE_REPLICATION
   if (options & REFRESH_MASTER)
   {

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2012-03-30 15:38:01 +0000
+++ b/sql/sql_show.cc	2012-04-13 12:00:39 +0000
@@ -2066,13 +2066,14 @@ void mysqld_list_processes(THD *thd,cons
                             Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
     DBUG_VOID_RETURN;
 
-  mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
   if (!thd->killed)
   {
-    I_List_iterator<THD> it(threads);
-    THD *tmp;
-    while ((tmp=it++))
+    mysql_mutex_lock(&LOCK_thread_count);
+    Thread_iterator it= global_thread_list_begin();
+    Thread_iterator end= global_thread_list_end();
+    for (; it != end; ++it)
     {
+      THD *tmp= *it;
       Security_context *tmp_sctx= tmp->security_ctx;
       struct st_my_thread_var *mysys_var;
       if ((tmp->vio_ok() || tmp->system_thread) &&
@@ -2120,8 +2121,8 @@ void mysqld_list_processes(THD *thd,cons
         thread_infos.push_front(thd_info);
       }
     }
+    mysql_mutex_unlock(&LOCK_thread_count);
   }
-  mysql_mutex_unlock(&LOCK_thread_count);
 
   thread_info *thd_info;
   time_t now= my_time(0);
@@ -2161,15 +2162,14 @@ int fill_schema_processlist(THD* thd, TA
   user= thd->security_ctx->master_access & PROCESS_ACL ?
         NullS : thd->security_ctx->priv_user;
 
-  mysql_mutex_lock(&LOCK_thread_count);
-
   if (!thd->killed)
   {
-    I_List_iterator<THD> it(threads);
-    THD* tmp;
-
-    while ((tmp= it++))
+    mysql_mutex_lock(&LOCK_thread_count);
+    Thread_iterator it= global_thread_list_begin();
+    Thread_iterator end= global_thread_list_end();
+    for (; it != end; ++it)
     {
+      THD* tmp= *it;
       Security_context *tmp_sctx= tmp->security_ctx;
       struct st_my_thread_var *mysys_var;
       const char *val;
@@ -2245,9 +2245,9 @@ int fill_schema_processlist(THD* thd, TA
         DBUG_RETURN(1);
       }
     }
+    mysql_mutex_unlock(&LOCK_thread_count);
   }
 
-  mysql_mutex_unlock(&LOCK_thread_count);
   DBUG_RETURN(0);
 }
 
@@ -2620,17 +2620,16 @@ void calc_sum_of_all_status(STATUS_VAR *
   DBUG_ENTER("calc_sum_of_all_status");
 
   /* Ensure that thread id not killed during loop */
-  mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
+  mysql_mutex_lock(&LOCK_thread_count);
 
-  I_List_iterator<THD> it(threads);
-  THD *tmp;
-  
+  Thread_iterator it= global_thread_list_begin();
+  Thread_iterator end= global_thread_list_end();
   /* Get global values as base */
   *to= global_status_var;
   
   /* Add to this status from existing threads */
-  while ((tmp= it++))
-    add_to_status(to, &tmp->status_var);
+  for (; it != end; ++it)
+    add_to_status(to, &(*it)->status_var);
   
   mysql_mutex_unlock(&LOCK_thread_count);
   DBUG_VOID_RETURN;

=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc	2012-03-06 14:29:42 +0000
+++ b/sql/sql_test.cc	2012-04-13 12:00:39 +0000
@@ -524,7 +524,7 @@ void mysql_print_status()
   printf("\nStatus information:\n\n");
   (void) my_getwd(current_dir, sizeof(current_dir),MYF(0));
   printf("Current dir: %s\n", current_dir);
-  printf("Running threads: %d  Stack size: %ld\n", thread_count,
+  printf("Running threads: %u  Stack size: %ld\n", get_thread_count(),
 	 (long) my_thread_stack_size);
   thr_print_locks();				// Write some debug info
 #ifndef DBUG_OFF
@@ -596,7 +596,8 @@ Estimated memory (with thread stack):   
 	 (int) info.uordblks,
 	 (int) info.fordblks,
 	 (int) info.keepcost,
-	 (long) (thread_count * my_thread_stack_size + info.hblkhd + info.arena));
+	 (long) (get_thread_count() * my_thread_stack_size +
+                 info.hblkhd + info.arena));
 #endif
 
 #ifdef HAVE_EVENT_SCHEDULER

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2012-04-13 08:09:09 +0000
+++ b/sql/sys_vars.cc	2012-04-13 12:00:39 +0000
@@ -2722,7 +2722,7 @@ static Sys_var_ulong Sys_table_cache_siz
 static Sys_var_ulong Sys_thread_cache_size(
        "thread_cache_size",
        "How many threads we should keep in a cache for reuse",
-       GLOBAL_VAR(thread_cache_size), CMD_LINE(REQUIRED_ARG),
+       GLOBAL_VAR(max_blocked_pthreads), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(0, 16384), DEFAULT(0), BLOCK_SIZE(1));
 
 /**

=== modified file 'storage/perfschema/pfs_check.cc'
--- a/storage/perfschema/pfs_check.cc	2010-07-16 01:28:30 +0000
+++ b/storage/perfschema/pfs_check.cc	2012-04-13 12:00:39 +0000
@@ -56,6 +56,8 @@ void check_performance_schema()
   PFS_engine_table_share::check_all_tables(thd);
 
   delete thd;
+  /* Remember that we don't have a THD */
+  my_pthread_setspecific_ptr(THR_THD,  0);
   DBUG_VOID_RETURN;
 }
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (tor.didriksen:3876 to 3877) WL#6221Tor Didriksen13 Apr