[Commits] Rev 2832: Fix for LP BUG#606013: Adding bit field support for heap tables. in file:///home/bell/maria/bzr/work-maria-5.3-lp606013/

sanja at askmonty.org sanja at askmonty.org
Tue Nov 16 23:03:27 EET 2010


At file:///home/bell/maria/bzr/work-maria-5.3-lp606013/

------------------------------------------------------------
revno: 2832
revision-id: sanja at askmonty.org-20101116210326-b0v3w6hdo7suo2id
parent: psergey at askmonty.org-20101018122305-iall1tv8ndmsebvh
committer: sanja at askmonty.org
branch nick: work-maria-5.3-lp606013
timestamp: Tue 2010-11-16 23:03:26 +0200
message:
  Fix for LP BUG#606013: Adding bit field support for heap tables.
-------------- next part --------------
=== modified file 'storage/heap/ha_heap.cc'
--- a/storage/heap/ha_heap.cc	2010-04-01 14:34:51 +0000
+++ b/storage/heap/ha_heap.cc	2010-11-16 21:03:26 +0000
@@ -654,7 +654,8 @@ int ha_heap::create(const char *name, TA
             seg->type != HA_KEYTYPE_VARTEXT1 &&
             seg->type != HA_KEYTYPE_VARTEXT2 &&
             seg->type != HA_KEYTYPE_VARBINARY1 &&
-            seg->type != HA_KEYTYPE_VARBINARY2)
+            seg->type != HA_KEYTYPE_VARBINARY2 &&
+            seg->type != HA_KEYTYPE_BIT)
           seg->type= HA_KEYTYPE_BINARY;
       }
       seg->start=   (uint) key_part->offset;
@@ -686,6 +687,15 @@ int ha_heap::create(const char *name, TA
         auto_key= key+ 1;
 	auto_key_type= field->key_type();
       }
+      if (seg->type == HA_KEYTYPE_BIT)
+      {
+        seg->bit_length= ((Field_bit *) field)->bit_len;
+        seg->bit_start= ((Field_bit *) field)->bit_ofs;
+        seg->bit_pos= (uint) (((Field_bit *) field)->bit_ptr -
+                                          (uchar*) table_arg->record[0]);
+      }
+      else
+        seg->bit_length= seg->bit_start= seg->bit_pos= 0;
     }
   }
   mem_per_row+= MY_ALIGN(share->reclength + 1, sizeof(char*));

=== modified file 'storage/heap/hp_create.c'
--- a/storage/heap/hp_create.c	2010-08-05 19:56:11 +0000
+++ b/storage/heap/hp_create.c	2010-11-16 21:03:26 +0000
@@ -104,6 +104,13 @@ int heap_create(const char *name, uint k
           */
           keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1;
           break;
+        case HA_KEYTYPE_BIT:
+          /*
+            The odd bits which stored separately (if they are present
+            (bit_pos, bit_length)) are already present in seg[j].length as
+            additional byte.
+          */
+          break;
 	default:
 	  break;
 	}

=== modified file 'storage/heap/hp_hash.c'
--- a/storage/heap/hp_hash.c	2010-08-27 14:12:44 +0000
+++ b/storage/heap/hp_hash.c	2010-11-16 21:03:26 +0000
@@ -349,6 +349,15 @@ ulong hp_rec_hashnr(register HP_KEYDEF *
     }
     else
     {
+      if (seg->type == HA_KEYTYPE_BIT && seg->bit_length)
+      {
+        uchar bits= get_rec_bits(rec + seg->bit_pos,
+                                 seg->bit_start, seg->bit_length);
+	nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) bits))+ (nr << 8);
+	nr2+=3;
+        end--;
+      }
+
       for (; pos < end ; pos++)
       {
 	nr^=(ulong) ((((uint) nr & 63)+nr2)*((uint) *pos))+ (nr << 8);
@@ -465,6 +474,14 @@ ulong hp_rec_hashnr(register HP_KEYDEF *
     else
     {
       uchar *end= pos+seg->length;
+      if (seg->type == HA_KEYTYPE_BIT && seg->bit_length)
+      {
+        uchar bits= get_rec_bits(rec + seg->bit_pos,
+                                 seg->bit_start, seg->bit_length);
+	nr *=16777619;
+	nr ^=(uint) bits;
+        end--;
+      }
       for ( ; pos < end ; pos++)
       {
 	nr *=16777619; 
@@ -577,7 +594,18 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, co
     }
     else
     {
-      if (bcmp(rec1+seg->start,rec2+seg->start,seg->length))
+      uint dec= 0;
+      if (seg->type == HA_KEYTYPE_BIT && seg->bit_length)
+      {
+        uchar bits1= get_rec_bits(rec1 + seg->bit_pos,
+                                  seg->bit_start, seg->bit_length);
+        uchar bits2= get_rec_bits(rec2 + seg->bit_pos,
+                                  seg->bit_start, seg->bit_length);
+        if (bits1 != bits2)
+          return 1;
+        dec= 1;
+      }
+      if (bcmp(rec1 + seg->start, rec2 + seg->start, seg->length - dec))
 	return 1;
     }
   }
@@ -660,7 +688,18 @@ int hp_key_cmp(HP_KEYDEF *keydef, const
     }
     else
     {
-      if (bcmp(rec+seg->start,key,seg->length))
+      uint dec= 0;
+      if (seg->type == HA_KEYTYPE_BIT && seg->bit_length)
+      {
+        uchar bits= get_rec_bits(rec + seg->bit_pos,
+                                 seg->bit_start, seg->bit_length);
+        if (bits != (*key))
+          return 1;
+        dec= 1;
+        key++;
+      }
+
+      if (bcmp(rec + seg->start, key, seg->length - dec))
 	return 1;
     }
   }
@@ -689,6 +728,12 @@ void hp_make_key(HP_KEYDEF *keydef, ucha
     }
     if (seg->type == HA_KEYTYPE_VARTEXT1)
       char_length+= seg->bit_start;             /* Copy also length */
+    else if (seg->type == HA_KEYTYPE_BIT && seg->bit_length)
+    {
+      *key++= get_rec_bits(rec + seg->bit_pos,
+                           seg->bit_start, seg->bit_length);
+      char_length--;
+    }
     memcpy(key,rec+seg->start,(size_t) char_length);
     key+= char_length;
   }
@@ -720,7 +765,8 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, u
     {
       uint length= seg->length;
       uchar *pos= (uchar*) rec + seg->start;
-      
+      DBUG_ASSERT(seg->type != HA_KEYTYPE_BIT);
+
 #ifdef HAVE_ISNAN
       if (seg->type == HA_KEYTYPE_FLOAT)
       {
@@ -784,6 +830,12 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, u
         seg->charset->cset->fill(seg->charset, (char*) key + char_length,
                                  seg->length - char_length, ' ');
     }
+    if (seg->type == HA_KEYTYPE_BIT && seg->bit_length)
+    {
+      *key++= get_rec_bits(rec + seg->bit_pos,
+                           seg->bit_start, seg->bit_length);
+      char_length--;
+    }
     memcpy(key, rec + seg->start, (size_t) char_length);
     key+= seg->length;
   }



More information about the commits mailing list