summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorcmiller@zippy.(none) <>2006-03-02 19:59:49 -0500
committercmiller@zippy.(none) <>2006-03-02 19:59:49 -0500
commit5147bb8e9bbcdf42148ca76b67cf1d9240c8440b (patch)
tree93057b81d12a646375f9b7997adb21f55fbe55e1 /sql/field_conv.cc
parent1bacdef0a7ee1d20f268935f32dfdd7e458aa54d (diff)
downloadmariadb-git-5147bb8e9bbcdf42148ca76b67cf1d9240c8440b.tar.gz
Expanding a binary field should result in 0x00-filled positions, not 0x20
(ASCII space). For Bug#16857.
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index bbe2dbe5e9f..895f022624c 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -379,6 +379,16 @@ static void do_cut_string_complex(Copy_field *copy)
+static void do_expand_binary(Copy_field *copy)
+{
+ CHARSET_INFO *cs= copy->from_field->charset();
+ memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
+ cs->cset->fill(cs, copy->to_ptr+copy->from_length,
+ copy->to_length-copy->from_length, '\0');
+}
+
+
+
static void do_expand_string(Copy_field *copy)
{
CHARSET_INFO *cs= copy->from_field->charset();
@@ -583,7 +593,13 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
return (from->charset()->mbmaxlen == 1 ?
do_cut_string : do_cut_string_complex);
else if (to_length > from_length)
- return do_expand_string;
+ {
+ if ((to->flags & BINARY_FLAG) != 0)
+ return do_expand_binary;
+ else
+ return do_expand_string;
+ }
+
}
else if (to->real_type() != from->real_type() ||
to_length != from_length ||