summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2010-11-11 16:41:52 -0800
committerIgor Babaev <igor@askmonty.org>2010-11-11 16:41:52 -0800
commitd9bbc64016d575cf8072a24da6edb2ebbf278d5b (patch)
tree140d4af3d8c16bfdb5cb9280577f4b4f6439b713 /sql/field_conv.cc
parent24f6a2ec4b7132123ec08b6f9b7291e3b1eb9b4a (diff)
downloadmariadb-git-d9bbc64016d575cf8072a24da6edb2ebbf278d5b.tar.gz
Fixed LP bug #672551.
Made sure that the function that copy a long varchar field from the record buffer into a key buffer does not copy bytes after the field value.
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 67ef4f95368..9fb3e131523 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -449,7 +449,8 @@ static void do_varstring1(Copy_field *copy)
if (length > copy->to_length- 1)
{
length=copy->to_length - 1;
- if (copy->from_field->table->in_use->count_cuted_fields)
+ if (copy->from_field->table->in_use->count_cuted_fields &&
+ copy->to_field)
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, 1);
}
@@ -485,7 +486,8 @@ static void do_varstring2(Copy_field *copy)
if (length > copy->to_length- HA_KEY_BLOB_LENGTH)
{
length=copy->to_length-HA_KEY_BLOB_LENGTH;
- if (copy->from_field->table->in_use->count_cuted_fields)
+ if (copy->from_field->table->in_use->count_cuted_fields &&
+ copy->to_field)
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, 1);
}
@@ -549,9 +551,16 @@ void Copy_field::set(uchar *to,Field *from)
do_copy= do_field_to_null_str;
}
else
- {
+ {
to_null_ptr= 0; // For easy debugging
- do_copy= do_field_eq;
+ /* Setup optimal copying for varchar */
+ if (from->real_type() == MYSQL_TYPE_VARCHAR)
+ {
+ do_copy= (((Field_varstring*) from)->length_bytes == 1 ?
+ do_varstring1 : do_varstring2);
+ }
+ else
+ do_copy= do_field_eq;
}
}
@@ -710,6 +719,10 @@ Copy_field::get_copy_func(Field *to,Field *from)
do_varstring1_mb) :
(from->charset()->mbmaxlen == 1 ? do_varstring2 :
do_varstring2_mb));
+ else
+ return (((Field_varstring*) from)->length_bytes == 1 ?
+ do_varstring1 : do_varstring2);
+
}
else if (to_length < from_length)
return (from->charset()->mbmaxlen == 1 ?