summaryrefslogtreecommitdiff
path: root/sql/key.cc
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2020-03-24 16:45:56 +1000
committerSergei Golubchik <serg@mariadb.org>2020-03-31 17:42:34 +0200
commitdb6f02bb988f5b3c57f3d9fb67a3d82f5a2b7592 (patch)
tree6ea372ea4678bd64085964d42280153bb217ead2 /sql/key.cc
parent7f9b3ea95138ea31faf54fa7d39885997b0f7ec9 (diff)
downloadmariadb-git-db6f02bb988f5b3c57f3d9fb67a3d82f5a2b7592.tar.gz
fix key_copy to use from_record argument data
key_copy is supposed to take field values from the from_record argument, but it was mostly ignoring it and instead relying on the caller to set field->ptr pointers accordingly. Inconsistently, it was checking the null bitmap in the from_record, not at the field->null_ptr. Now key_copy correctly takes all field values from the from_record.
Diffstat (limited to 'sql/key.cc')
-rw-r--r--sql/key.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/key.cc b/sql/key.cc
index 5ec76d37d5b..0f2af60f9e3 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -141,12 +141,13 @@ void key_copy(uchar *to_key, const uchar *from_record, const KEY *key_info,
continue;
}
}
+ auto *from_ptr= key_part->field->ptr_in_record(from_record);
if (key_part->key_part_flag & HA_BLOB_PART ||
key_part->key_part_flag & HA_VAR_LENGTH_PART)
{
key_length-= HA_KEY_BLOB_LENGTH;
length= MY_MIN(key_length, key_part->length);
- uint bytes= key_part->field->get_key_image(to_key, length,
+ uint bytes= key_part->field->get_key_image(to_key, length, from_ptr,
key_info->flags & HA_SPATIAL ? Field::itMBR : Field::itRAW);
if (with_zerofill && bytes < length)
bzero((char*) to_key + bytes, length - bytes);
@@ -157,7 +158,7 @@ void key_copy(uchar *to_key, const uchar *from_record, const KEY *key_info,
length= MY_MIN(key_length, key_part->length);
Field *field= key_part->field;
CHARSET_INFO *cs= field->charset();
- uint bytes= field->get_key_image(to_key, length, Field::itRAW);
+ uint bytes= field->get_key_image(to_key, length, from_ptr, Field::itRAW);
if (bytes < length)
cs->fill((char*) to_key + bytes, length - bytes, ' ');
}