List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:March 20 2007 1:13pm
Subject:bk commit into 5.1 tree (mats:1.2478) BUG#26969
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats 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-03-20 14:13:07+01:00, mats@romeo.(none) +2 -0
  BUG#26969:
    Field_bit::pack() and Field_bit::unpack() does not work correctly
  
  Fixing code for Field_bit packing and unpacking to work with arbitrary
  pointers instead of requiring Field::ptr

  sql/field.cc@stripped, 2007-03-20 14:13:02+01:00, mats@romeo.(none) +30 -4
    Fixing Field_bit::pack() and Field_bit::unpack() so that they accept
    an arbitrary pointer to pack/unpack to/from.

  sql/sql_class.cc@stripped, 2007-03-20 14:13:02+01:00, mats@romeo.(none) +1 -3
    Removing unneeded move_field_offset() nefore packing field.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mats
# Host:	romeo.(none)
# Root:	/home/bk/b22583-mysql-5.1-new-rpl

--- 1.378/sql/field.cc	2007-03-20 14:13:18 +01:00
+++ 1.379/sql/field.cc	2007-03-20 14:13:18 +01:00
@@ -8505,9 +8505,28 @@
 {
   DBUG_ASSERT(max_length);
   uint length;
-  if (bit_len)
+  if (bit_len > 0)
   {
-    uchar bits= get_rec_bits(bit_ptr, bit_ofs, bit_len);
+    /*
+      We have the following:
+
+      ptr        Points into a field in record R1
+      from       Points to a field in a record R2
+      bit_ptr    Points to the byte (in the null bytes) that holds the
+                 odd bits of R1
+      from_bitp  Points to the byte that holds the odd bits of R2
+
+      We have the following:
+
+          ptr - bit_ptr = from - from_bitp
+
+      We want to isolate 'from_bitp', so this gives:
+
+          ptr - bit_ptr - from = - from_bitp
+          - ptr + bit_ptr + from = from_bitp
+          bit_ptr + from - ptr = from_bitp
+     */
+    uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len);
     *to++= bits;
   }
   length= min(bytes_in_rec, max_length - (bit_len > 0));
@@ -8518,9 +8537,16 @@
 
 const char *Field_bit::unpack(char *to, const char *from)
 {
-  if (bit_len)
+  if (bit_len > 0)
   {
-    set_rec_bits(*from, bit_ptr, bit_ofs, bit_len);
+    /*
+      set_rec_bits is a macro, don't put the post-increment in the
+      argument since that might cause strange side-effects.
+
+      For the choice of the second argument, see the explanation for
+      Field_bit::pack().
+    */
+    set_rec_bits(*from, bit_ptr + (to - ptr), bit_ofs, bit_len);
     from++;
   }
   memcpy(to, from, bytes_in_rec);

--- 1.320/sql/sql_class.cc	2007-03-20 14:13:18 +01:00
+++ 1.321/sql/sql_class.cc	2007-03-20 14:13:18 +01:00
@@ -2619,9 +2619,7 @@
         /*
           We only store the data of the field if it is non-null
          */
-        field->move_field_offset(offset);
-        pack_ptr= (byte*)field->pack((char *) pack_ptr, field->ptr);
-        field->move_field_offset(-offset);
+        pack_ptr= (byte*)field->pack((char *) pack_ptr, field->ptr + offset);
       }
 
       null_mask <<= 1;
Thread
bk commit into 5.1 tree (mats:1.2478) BUG#26969Mats Kindahl20 Mar