summaryrefslogtreecommitdiff
path: root/sql/key.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2010-12-26 16:31:03 -0800
committerIgor Babaev <igor@askmonty.org>2010-12-26 16:31:03 -0800
commit18dc64eca2bbe29697043dc0ae51ae21d19af365 (patch)
tree74b31ca28accca2bba1ed46f32fde183564ddcd3 /sql/key.cc
parent1eb21dc4be059b808f79de4702aaa9204ae4a41e (diff)
downloadmariadb-git-18dc64eca2bbe29697043dc0ae51ae21d19af365.tar.gz
Fixed LP bug #694443.
One of the hash functions employed by the BNLH join algorithm calculates the the value of hash index for key value utilizing every byte of the key buffer. To make this calculation valid one has to ensure that for any key value unused bytes of the buffer are filled with with a certain filler. We choose 0 as a filler for these bytes. Added an optional boolean parameter with_zerofill to the function key_copy. If the value of the parameter is TRUE all unused bytes of the key buffer is filled with 0.
Diffstat (limited to 'sql/key.cc')
-rw-r--r--sql/key.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/key.cc b/sql/key.cc
index 0de1d1fd642..780cc6733c1 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -103,10 +103,11 @@ int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field,
@param from_record full record to be copied from
@param key_info descriptor of the index
@param key_length specifies length of all keyparts that will be copied
+ @param with_zerofill skipped bytes in the key buffer to be filled with 0
*/
void key_copy(uchar *to_key, uchar *from_record, KEY *key_info,
- uint key_length)
+ uint key_length, bool with_zerofill)
{
uint length;
KEY_PART_INFO *key_part;
@@ -129,6 +130,8 @@ void key_copy(uchar *to_key, uchar *from_record, KEY *key_info,
The -1 below is to subtract the null byte which is already handled
*/
length= min(key_length, (uint) key_part->store_length-1);
+ if (with_zerofill)
+ bzero((char*) to_key, length);
continue;
}
}
@@ -137,7 +140,9 @@ void key_copy(uchar *to_key, uchar *from_record, KEY *key_info,
{
key_length-= HA_KEY_BLOB_LENGTH;
length= min(key_length, key_part->length);
- key_part->field->get_key_image(to_key, length, Field::itRAW);
+ uint bytes= key_part->field->get_key_image(to_key, length, Field::itRAW);
+ if (with_zerofill && bytes < length)
+ bzero((char*) to_key + bytes, length - bytes);
to_key+= HA_KEY_BLOB_LENGTH;
}
else