Below is the list of changes that have just been committed into a local
5.1 repository of anozdrin. When anozdrin does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-02-12 20:59:09+03:00, anozdrin@quad. +3 -0
Fix for Bug#31222: com_% global status counters
behave randomly with mysql_change_user.
The problem was that global status variables were not updated
in THD::check_user(), so thread statistics were lost after
COM_CHANGE_USER.
The fix is to update global status variables with the thread ones
before preparing the thread for new user.
mysql-test/r/change_user.result@stripped, 2008-02-12 20:59:08+03:00, anozdrin@quad. +7 -0
Update result file.
mysql-test/t/change_user.test@stripped, 2008-02-12 20:59:08+03:00, anozdrin@quad. +28 -0
Add a test case for Bug#31222: com_% global status counters
behave randomly with mysql_change_user.
sql/sql_class.cc@stripped, 2008-02-12 20:59:08+03:00, anozdrin@quad. +4 -0
Update global status variables when we're handling
COM_CHANGE_USER for a thread.
diff -Nrup a/mysql-test/r/change_user.result b/mysql-test/r/change_user.result
--- a/mysql-test/r/change_user.result 2007-12-10 10:12:40 +03:00
+++ b/mysql-test/r/change_user.result 2008-02-12 20:59:08 +03:00
@@ -44,3 +44,10 @@ IS_FREE_LOCK('bug31418')
SELECT IS_USED_LOCK('bug31418');
IS_USED_LOCK('bug31418')
NULL
+FLUSH STATUS;
+SHOW GLOBAL STATUS LIKE 'com_select';
+Variable_name Value
+Com_select 112
+SHOW GLOBAL STATUS LIKE 'com_select';
+Variable_name Value
+Com_select 112
diff -Nrup a/mysql-test/t/change_user.test b/mysql-test/t/change_user.test
--- a/mysql-test/t/change_user.test 2007-10-17 23:43:26 +04:00
+++ b/mysql-test/t/change_user.test 2008-02-12 20:59:08 +03:00
@@ -33,3 +33,31 @@ SELECT IS_USED_LOCK('bug31418') = CONNEC
--change_user
SELECT IS_FREE_LOCK('bug31418');
SELECT IS_USED_LOCK('bug31418');
+
+#
+# Bug#31222: com_% global status counters behave randomly with
+# mysql_change_user.
+#
+
+FLUSH STATUS;
+
+--disable_result_log
+--disable_query_log
+
+let $i = 100;
+
+while ($i)
+{
+ dec $i;
+
+ SELECT 1;
+}
+
+--enable_query_log
+--enable_result_log
+
+SHOW GLOBAL STATUS LIKE 'com_select';
+
+--change_user
+
+SHOW GLOBAL STATUS LIKE 'com_select';
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc 2008-02-09 10:31:19 +03:00
+++ b/sql/sql_class.cc 2008-02-12 20:59:08 +03:00
@@ -769,6 +769,10 @@ void THD::init_for_queries()
void THD::change_user(void)
{
+ pthread_mutex_lock(&LOCK_status);
+ add_to_status(&global_status_var, &status_var);
+ pthread_mutex_unlock(&LOCK_status);
+
cleanup();
killed= NOT_KILLED;
cleanup_done= 0;
| Thread |
|---|
| • bk commit into 5.1 tree (anozdrin:1.2546) BUG#31222 | Alexander Nozdrin | 12 Feb |