List:Commits« Previous MessageNext Message »
From:knielsen Date:May 13 2007 7:26pm
Subject:bk commit into 5.1 tree (knielsen:1.2509)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of knielsen. When knielsen 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-05-13 21:26:26+02:00, knielsen@ymer.(none) +2 -0
  WL#2223: NdbRecord.
  Bitfield and comment fixes.

  storage/ndb/include/ndbapi/NdbTransaction.hpp@stripped, 2007-05-13 21:26:23+02:00, knielsen@ymer.(none) +8 -6
    Improve comment docs.

  storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp@stripped, 2007-05-13 21:26:23+02:00, knielsen@ymer.(none) +29 -31
    Fix mysqld bitfield storage (it was byte-swapped).

# 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:	knielsen
# Host:	ymer.(none)
# Root:	/usr/local/mysql/mysql-5.1-ndb-ndbrecord

--- 1.63/storage/ndb/include/ndbapi/NdbTransaction.hpp	2007-05-13 21:26:34 +02:00
+++ 1.64/storage/ndb/include/ndbapi/NdbTransaction.hpp	2007-05-13 21:26:34 +02:00
@@ -574,8 +574,9 @@ public:
     tuple, and must remain valid until execute() is called.
 
     The mask, if != NULL, defines a subset of attributes to read, update, or
-    insert. It is copied by the methods, so need not remain valid after the
-    call returns.
+    insert. Only if (mask[attrId >> 3] & (1<<(attrId & 7))) is set is the
+    column affected. The mask is copied by the methods, so need not remain
+    valid after the call returns.
 
     For unique index operations, the attr_rec must refer to the underlying
     table of the index.
@@ -601,10 +602,11 @@ public:
     The result_record pointer must remain valid until after the call to
     execute().
 
-    The result_mask pointer is optional, if present only columns for which
-    the corresponding bit in result_mask is set will be retrieved in the
-    scan. The result_mask is copied internally, so in contrast to
-    result_record need not be valid at execute().
+    The result_mask pointer is optional, if present only columns for
+    which the corresponding bit (by attribute id order) in result_mask
+    is set will be retrieved in the scan. The result_mask is copied
+    internally, so in contrast to result_record need not be valid at
+    execute().
 
     The parallel argument is the desired parallelism, or 0 for maximum
     parallelism (receiving rows from all fragments in parallel).

--- 1.166/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2007-05-13 21:26:34 +02:00
+++ 1.167/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2007-05-13 21:26:34 +02:00
@@ -5048,38 +5048,39 @@ void
 NdbRecord::Attr::get_mysqld_bitfield(const char *src_row, char *dst_buffer) const
 {
   assert(flags & IsMysqldBitfield);
-  Uint64 bits= 0;
-  Uint32 shift= 0;
-
-  /* Copy whole bytes. */
+  Uint64 bits;
   Uint32 remaining_bits= bitCount;
-  assert(remaining_bits <= 64);
-  const unsigned char *src_ptr= (const unsigned char *)&src_row[offset];
-  while (remaining_bits >= 8)
-  {
-    bits|= (Uint64)(*src_ptr++) << shift;
-    shift+= 8;
-    remaining_bits-= 8;
-  }
+  Uint32 fractional_bitcount= remaining_bits % 8;
 
   /* Copy fractional bits, if any. */
-  if (remaining_bits > 0)
+  if (fractional_bitcount > 0)
   {
     Uint32 fractional_shift= nullbit_bit_in_byte + ((flags & IsNullable) != 0);
     Uint32 fractional_bits= (unsigned char)(src_row[nullbit_byte_offset]);
-    if (fractional_shift + remaining_bits > 8)
+    if (fractional_shift + fractional_bitcount > 8)
       fractional_bits|= (unsigned char)(src_row[nullbit_byte_offset+1]) << 8;
     fractional_bits=
-      (fractional_bits >> fractional_shift) & ((1 << remaining_bits) - 1);
-    bits|= (Uint64)fractional_bits << shift;
+      (fractional_bits >> fractional_shift) & ((1 << fractional_bitcount) - 1);
+    bits= fractional_bits;
+  }
+  else
+    bits= 0;
+
+  /* Copy whole bytes. The mysqld format stored bit fields big-endian. */
+  assert(remaining_bits <= 64);
+  const unsigned char *src_ptr= (const unsigned char *)&src_row[offset];
+  while (remaining_bits >= 8)
+  {
+    bits= (bits << 8) | (*src_ptr++);
+    remaining_bits-= 8;
   }
 
+  Uint32 small_bits= bits;
+  memcpy(dst_buffer, &small_bits, 4);
   if (maxSize > 4)
-    memcpy(dst_buffer, &bits, 8);
-  else
   {
-    Uint32 small_bits= bits;
-    memcpy(dst_buffer, &small_bits, 4);
+    small_bits= bits >> 32;
+    memcpy(dst_buffer+4, &small_bits, 4);
   }
 }
 
@@ -5089,25 +5090,22 @@ NdbRecord::Attr::put_mysqld_bitfield(cha
   assert(flags & IsMysqldBitfield);
   char *dst_ptr= &dst_row[offset];
   Uint64 bits;
+  Uint32 small_bits;
+  memcpy(&small_bits, src_buffer, 4);
+  bits= small_bits;
   if (maxSize > 4)
   {
-    memcpy(&bits, src_buffer, 8);
-    bzero(dst_ptr, 8);
-  }
-  else
-  {
-    Uint32 small_bits;
-    memcpy (&small_bits, src_buffer, 4);
-    bits= small_bits;
-    bzero(dst_ptr, 4);
+    memcpy(&small_bits, src_buffer+4, 4);
+    bits|= ((Uint64)small_bits) << 32;
   }
 
-  /* Copy whole bytes. */
+  /* Copy whole bytes. The mysqld format stores bitfields big-endian. */
   Uint32 remaining_bits= bitCount;
   assert(remaining_bits <= 64);
+  dst_ptr+= remaining_bits/8;
   while (remaining_bits >= 8)
   {
-    *dst_ptr++= bits & 0xff;
+    *--dst_ptr= bits & 0xff;
     bits>>= 8;
     remaining_bits-= 8;
   }
Thread
bk commit into 5.1 tree (knielsen:1.2509)knielsen13 May