summaryrefslogtreecommitdiff
path: root/sql/key.cc
diff options
context:
space:
mode:
authormattiasj@witty.ndb.mysql.com <>2008-02-07 15:09:59 +0100
committermattiasj@witty.ndb.mysql.com <>2008-02-07 15:09:59 +0100
commitd5364e38c5e97d818438399227e2cc266acbed1a (patch)
treeee64f23daaa021257a0b2c1b18a69f3c2e92c1cb /sql/key.cc
parent6053cfc5e6021599f748488d7c8d5dd6e9c215fc (diff)
downloadmariadb-git-d5364e38c5e97d818438399227e2cc266acbed1a.tar.gz
Bug#34358: Cannot find specified bit row in partitioned table
Problem was incorrect data length in the key_restore function resulting in overwriting the search key. Solution, remove one byte in length if uneven bits are used.
Diffstat (limited to 'sql/key.cc')
-rw-r--r--sql/key.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/key.cc b/sql/key.cc
index 7f075674ab6..47e5c5ebdd7 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -168,6 +168,7 @@ void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
}
for (key_part= key_info->key_part ; (int) key_length > 0 ; key_part++)
{
+ uchar used_uneven_bits= 0;
if (key_part->null_bit)
{
if (*from_key++)
@@ -186,6 +187,8 @@ void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
set_rec_bits(bits, to_record + key_part->null_offset +
(key_part->null_bit == 128),
field->bit_ofs, field->bit_len);
+ /* we have now used the byte with 'uneven' bits */
+ used_uneven_bits= 1;
}
}
if (key_part->key_part_flag & HA_BLOB_PART)
@@ -222,7 +225,9 @@ void key_restore(uchar *to_record, uchar *from_key, KEY *key_info,
else
{
length= min(key_length, key_part->length);
- memcpy(to_record + key_part->offset, from_key, (size_t) length);
+ /* skip the byte with 'uneven' bits, if used */
+ memcpy(to_record + key_part->offset, from_key + used_uneven_bits
+ , (size_t) length - used_uneven_bits);
}
from_key+= length;
key_length-= length;