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

ChangeSet@stripped, 2007-11-30 22:17:11+04:00, holyfoot@stripped +4 -0
  Bug #30430 crash:./mtr --embedded-server --ps-protocol cache_innodb func_misc...
  
  PS-protocol data is stored in different format - the MYSQL_RECORDS->data
  contains the link to the record content, not to array of the links to
  the field's contents. So we have to handle it separately for
  embedded-server query cache.

  libmysqld/emb_qcache.cc@stripped, 2007-11-30 22:17:10+04:00, holyfoot@stripped +69 -34
    Bug #30430 crash:./mtr --embedded-server --ps-protocol cache_innodb func_misc...
    
    ps_protocol data now stored in it's particular way.

  libmysqld/emb_qcache.h@stripped, 2007-11-30 22:17:10+04:00, holyfoot@stripped +2 -2
    Bug #30430 crash:./mtr --embedded-server --ps-protocol cache_innodb func_misc...
    
    Querycache_stream::load_char/store_char  ->
      load_uchar/store_uchar

  mysql-test/r/func_misc.result@stripped, 2007-11-30 22:17:10+04:00, holyfoot@stripped +1 -1
    Bug #30430 crash:./mtr --embedded-server --ps-protocol cache_innodb func_misc...
    
    test result

  mysql-test/t/func_misc.test@stripped, 2007-11-30 22:17:10+04:00, holyfoot@stripped +1 -1
    Bug #30430 crash:./mtr --embedded-server --ps-protocol cache_innodb func_misc...
    
    the test uses t2 table, so let's make sure it doesn't exist befor the start

diff -Nrup a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc
--- a/libmysqld/emb_qcache.cc	2007-05-10 14:59:24 +05:00
+++ b/libmysqld/emb_qcache.cc	2007-11-30 22:17:10 +04:00
@@ -19,7 +19,7 @@
 #include "emb_qcache.h"
 #include "embedded_priv.h"
 
-void Querycache_stream::store_char(char c)
+void Querycache_stream::store_uchar(uchar c)
 {
   if (data_end == cur_data)
     use_next_block(TRUE);
@@ -142,7 +142,7 @@ void Querycache_stream::store_safe_str(c
     store_int(0);
 }
 
-char Querycache_stream::load_char()
+uchar Querycache_stream::load_uchar()
 {
   if (cur_data == data_end)
     use_next_block(FALSE);
@@ -301,8 +301,8 @@ uint emb_count_querycache_size(THD *thd)
   *data->embedded_info->prev_ptr= NULL; // this marks the last record
   cur_row= data->data;
   n_rows= data->rows;
-  /* n_fields + n_rows + (field_info + strlen * n_rows) * n_fields */
-  result+= (uint) (4+8 + (42 + 4*n_rows)*data->fields);
+  /* n_fields + n_rows + field_info * n_fields */
+  result+= (uint) (4+8 + 42*data->fields);
 
   for(; field < field_end; field++)
   {
@@ -313,13 +313,23 @@ uint emb_count_querycache_size(THD *thd)
       result+= field->def_length;
   }
   
-  for (; cur_row; cur_row=cur_row->next)
+  if (thd->protocol == &thd->protocol_binary)
   {
-    MYSQL_ROW col= cur_row->data;
-    MYSQL_ROW col_end= col + data->fields;
-    for (; col < col_end; col++)
-      if (*col)
-        result+= *(uint *)((*col) - sizeof(uint));
+    result+= (uint) (4*n_rows);
+    for (; cur_row; cur_row=cur_row->next)
+      result+= cur_row->length;
+  }
+  else
+  {
+    result+= (uint) (4*n_rows*data->fields);
+    for (; cur_row; cur_row=cur_row->next)
+    {
+      MYSQL_ROW col= cur_row->data;
+      MYSQL_ROW col_end= col + data->fields;
+      for (; col < col_end; col++)
+        if (*col)
+          result+= *(uint *)((*col) - sizeof(uint));
+    }
   }
   return result;
 }
@@ -353,10 +363,10 @@ void emb_store_querycache_result(Queryca
   {
     dst->store_int((uint)field->length);
     dst->store_int((uint)field->max_length);
-    dst->store_char((char)field->type);
+    dst->store_uchar((uchar)field->type);
     dst->store_short((ushort)field->flags);
     dst->store_short((ushort)field->charsetnr);
-    dst->store_char((char)field->decimals);
+    dst->store_uchar((uchar)field->decimals);
     dst->store_str(field->name, field->name_length);
     dst->store_str(field->table, field->table_length);
     dst->store_str(field->org_name, field->org_name_length);
@@ -366,14 +376,22 @@ void emb_store_querycache_result(Queryca
     dst->store_safe_str(field->def, field->def_length);
   }
   
-  for (; cur_row; cur_row=cur_row->next)
+  if (thd->protocol == &thd->protocol_binary)
   {
-    MYSQL_ROW col= cur_row->data;
-    MYSQL_ROW col_end= col + data->fields;
-    for (; col < col_end; col++)
+    for (; cur_row; cur_row=cur_row->next)
+      dst->store_str((char *) cur_row->data, cur_row->length);
+  }
+  else
+  {
+    for (; cur_row; cur_row=cur_row->next)
     {
-      uint len= *col ? *(uint *)((*col) - sizeof(uint)) : 0;
-      dst->store_safe_str(*col, len);
+      MYSQL_ROW col= cur_row->data;
+      MYSQL_ROW col_end= col + data->fields;
+      for (; col < col_end; col++)
+      {
+        uint len= *col ? *(uint *)((*col) - sizeof(uint)) : 0;
+        dst->store_safe_str(*col, len);
+      }
     }
   }
   DBUG_ASSERT(emb_count_querycache_size(thd) == dst->stored_size);
@@ -408,10 +426,10 @@ int emb_load_querycache_result(THD *thd,
   {
     field->length= src->load_int();
     field->max_length= (unsigned int)src->load_int();
-    field->type= (enum enum_field_types)src->load_char();
+    field->type= (enum enum_field_types)src->load_uchar();
     field->flags= (unsigned int)src->load_short();
     field->charsetnr= (unsigned int)src->load_short();
-    field->decimals= (unsigned int)src->load_char();
+    field->decimals= src->load_uchar();
 
     if (!(field->name= src->load_str(f_alloc, &field->name_length))         
||
         !(field->table= src->load_str(f_alloc,&field->table_length))        
||
@@ -423,26 +441,43 @@ int emb_load_querycache_result(THD *thd,
       goto err;
   }
   
-  row= (MYSQL_ROWS *)alloc_root(&data->alloc,
-                                (uint) (rows * sizeof(MYSQL_ROWS) +
-                                        rows*(data->fields+1)*sizeof(char*)));
-  end_row= row + rows;
-  columns= (MYSQL_ROW)end_row;
-  
   data->rows= rows;
-  data->data= row;
   if (!rows)
     goto return_ok;
+  if (thd->protocol == &thd->protocol_binary)
+  {
+    uint length;
+    row= (MYSQL_ROWS *)alloc_root(&data->alloc, rows * sizeof(MYSQL_ROWS));
+    end_row= row + rows;
+    data->data= row;
 
-  for (prev_row= &row->next; row < end_row; prev_row= &row->next, row++)
+    for (prev_row= &row->next; row < end_row; prev_row= &row->next,
row++)
+    {
+      *prev_row= row;
+      row->data= (MYSQL_ROW) src->load_str(&data->alloc, &length);
+      row->length= length;
+    }
+  }
+  else
   {
-    *prev_row= row;
-    row->data= columns;
-    MYSQL_ROW col_end= columns + data->fields;
-    for (; columns < col_end; columns++)
-      src->load_column(&data->alloc, columns);
+    row= (MYSQL_ROWS *)alloc_root(&data->alloc,
+        (uint) (rows * sizeof(MYSQL_ROWS) +
+          rows*(data->fields+1)*sizeof(char*)));
+    end_row= row + rows;
+    columns= (MYSQL_ROW)end_row;
 
-    *(columns++)= NULL;
+    data->data= row;
+
+    for (prev_row= &row->next; row < end_row; prev_row= &row->next,
row++)
+    {
+      *prev_row= row;
+      row->data= columns;
+      MYSQL_ROW col_end= columns + data->fields;
+      for (; columns < col_end; columns++)
+        src->load_column(&data->alloc, columns);
+
+      *(columns++)= NULL;
+    }
   }
   *prev_row= NULL;
   data->embedded_info->prev_ptr= prev_row;
diff -Nrup a/libmysqld/emb_qcache.h b/libmysqld/emb_qcache.h
--- a/libmysqld/emb_qcache.h	2007-05-10 14:59:24 +05:00
+++ b/libmysqld/emb_qcache.h	2007-11-30 22:17:10 +04:00
@@ -58,7 +58,7 @@ public:
     data_end= cur_data + (block->used-headers_len);
   }
 
-  void store_char(char c);
+  void store_uchar(uchar c);
   void store_short(ushort s);
   void store_int(uint i);
   void store_ll(ulonglong ll);
@@ -66,7 +66,7 @@ public:
   void store_str(const char *str, uint str_len);
   void store_safe_str(const char *str, uint str_len);
 
-  char load_char();
+  uchar load_uchar();
   ushort load_short();
   uint load_int();
   ulonglong load_ll();
diff -Nrup a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
--- a/mysql-test/r/func_misc.result	2007-10-09 14:37:41 +05:00
+++ b/mysql-test/r/func_misc.result	2007-11-30 22:17:10 +04:00
@@ -1,4 +1,4 @@
-DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1, t2;
 select
format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.55555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2);
 format(1.5555,0)	format(123.5555,1)	format(1234.5555,2)	format(12345.55555,3)	format(123456.5555,4)	format(1234567.5555,5)	format("12345.2399",2)
 2	123.6	1,234.56	12,345.556	123,456.5555	1,234,567.55550	12,345.24
diff -Nrup a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
--- a/mysql-test/t/func_misc.test	2007-10-09 14:37:41 +05:00
+++ b/mysql-test/t/func_misc.test	2007-11-30 22:17:10 +04:00
@@ -3,7 +3,7 @@
 #
 
 --disable_warnings
-DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1, t2;
 --enable_warnings
 
 select
format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.55555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2);
Thread
bk commit into 5.1 tree (holyfoot:1.2637) BUG#30430holyfoot30 Nov