List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:July 7 2010 1:58pm
Subject:bzr commit into mysql-5.1-bugteam branch (Georgi.Kodinov:3465) Bug#53493
View as plain text  
#At file:///home/kgeorge/mysql/work/B53493-5.1-bugteam/ based on revid:georgi.kodinov@stripped

 3465 Georgi Kodinov	2010-07-07
      Bug #53493 : add_to_status does not handle the longlong fields in STATUS_VAR
      
      Created a provision to handle correctly a set of ulonglong status variables
      in addition to the ulong status variables. Moved bytes_received/bytes_sent
      into the new ulonglong group, so that add_to_status()/add_diff_to_status()
      can handle them correctly.

    modified:
      sql/sql_class.cc
      sql/sql_class.h
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-07-04 04:02:49 +0000
+++ b/sql/sql_class.cc	2010-07-07 13:58:24 +0000
@@ -1057,12 +1057,27 @@ THD::~THD()
 void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
 {
   ulong *end= (ulong*) ((uchar*) to_var +
-                        offsetof(STATUS_VAR, last_system_status_var) +
+                        offsetof(STATUS_VAR, last_ulong_system_status_var) +
 			sizeof(ulong));
   ulong *to= (ulong*) to_var, *from= (ulong*) from_var;
 
+  ulonglong *ull_to= (ulonglong *)
+    ((uchar*) to_var +
+     offsetof(STATUS_VAR, first_ulonglong_system_status_var));
+
+  ulonglong *ull_from= (ulonglong *)
+    ((uchar*) from_var +
+     offsetof(STATUS_VAR, first_ulonglong_system_status_var));
+
+  ulonglong *ull_end= (ulonglong *)
+    ((uchar*) to_var +
+     offsetof(STATUS_VAR, last_ulonglong_system_status_var) + 
+     sizeof(ulonglong));
+
   while (to != end)
     *(to++)+= *(from++);
+  while (ull_to != ull_end)
+    *(ull_to++)+= *(ull_from++);
 }
 
 /*
@@ -1081,13 +1096,33 @@ void add_to_status(STATUS_VAR *to_var, S
 void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
                         STATUS_VAR *dec_var)
 {
-  ulong *end= (ulong*) ((uchar*) to_var + offsetof(STATUS_VAR,
-						  last_system_status_var) +
+  ulong *end= (ulong*) ((uchar*) to_var + 
+                        offsetof(STATUS_VAR, last_ulong_system_status_var) +
 			sizeof(ulong));
   ulong *to= (ulong*) to_var, *from= (ulong*) from_var, *dec= (ulong*) dec_var;
 
+  ulonglong *ull_to= (ulonglong *)
+    ((uchar*) to_var +
+     offsetof(STATUS_VAR, first_ulonglong_system_status_var));
+
+  ulonglong *ull_from= (ulonglong *)
+    ((uchar*) from_var +
+     offsetof(STATUS_VAR, first_ulonglong_system_status_var));
+
+  ulonglong *ull_dec= (ulonglong *)
+    ((uchar*) dec_var +
+     offsetof(STATUS_VAR, first_ulonglong_system_status_var));
+
+  ulonglong *ull_end= (ulonglong *)
+    ((uchar*) to_var +
+     offsetof(STATUS_VAR, last_ulonglong_system_status_var) + 
+     sizeof(ulonglong));
+
   while (to != end)
     *(to++)+= *(from++) - *(dec++);
+
+  while (ull_to != ull_end)
+    *(ull_to++)+= *(ull_from++) - *(ull_dec++);
 }
 
 

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-07-04 04:02:49 +0000
+++ b/sql/sql_class.h	2010-07-07 13:58:24 +0000
@@ -405,12 +405,15 @@ struct system_variables
 };
 
 
-/* per thread status variables */
+/**
+  Per thread status variables.
+  Must be long/ulong up to last_ulong_system_status_var and longlong/ulonglong from
+  first_ulonglong_system_status_var to last_ulonglong_system_status_var so that
+  add_to_status/add_diff_to_status can work.
+*/
 
 typedef struct system_status_var
 {
-  ulonglong bytes_received;
-  ulonglong bytes_sent;
   ulong com_other;
   ulong com_stat[(uint) SQLCOM_END];
   ulong created_tmp_disk_tables;
@@ -466,24 +469,26 @@ typedef struct system_status_var
     Number of statements sent from the client
   */
   ulong questions;
+  ulonglong bytes_received;
+  ulonglong bytes_sent;
   /*
     IMPORTANT!
     SEE last_system_status_var DEFINITION BELOW.
-    Below 'last_system_status_var' are all variables which doesn't make any
-    sense to add to the /global/ status variable counter.
-    Status variables which it does not make sense to add to
-    global status variable counter
+    Below 'last_system_status_var' are all variables that cannot be handled
+    by add_to_status()/add_diff_to_status().
   */
   double last_query_cost;
 } STATUS_VAR;
 
 /*
-  This is used for 'SHOW STATUS'. It must be updated to the last ulong
-  variable in system_status_var which is makes sens to add to the global
-  counter
+  These are used for 'SHOW STATUS'. They must be updated to the last ulong
+  variable, the first and the last ulonglong variable in system_status_var 
+  which is makes sens to add to the global counter
 */
 
-#define last_system_status_var questions
+#define last_ulong_system_status_var questions
+#define first_ulonglong_system_status_var bytes_received
+#define last_ulonglong_system_status_var bytes_sent
 
 void mark_transaction_to_rollback(THD *thd, bool all);
 


Attachment: [text/bzr-bundle] bzr/georgi.kodinov@oracle.com-20100707135824-07clmc9c36jryj2y.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (Georgi.Kodinov:3465) Bug#53493Georgi Kodinov7 Jul
  • Re: bzr commit into mysql-5.1-bugteam branch (Georgi.Kodinov:3465)Bug#53493Davi Arnaut13 Jul