summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorunknown <bar@bar.myoffice.izhnet.ru>2007-04-13 10:08:52 +0500
committerunknown <bar@bar.myoffice.izhnet.ru>2007-04-13 10:08:52 +0500
commitd8cb1181b5dd6091e8b361c0af85292d75473991 (patch)
tree665d6a06c6f5685da6fc6c06d1f334e44f3ce006 /sql/field_conv.cc
parent83f394c773d31fb24ac3bdd425b17bd3f72681fe (diff)
parent40dc6be6233a006ccd00ae3210dcf049398dbcf5 (diff)
downloadmariadb-git-d8cb1181b5dd6091e8b361c0af85292d75473991.tar.gz
Merge mysql.com:/home/bar/mysql-5.0.b20095
into mysql.com:/home/bar/mysql-5.1-new-rpl mysql-test/r/ctype_utf8.result: Auto merged mysql-test/t/ctype_utf8.test: Auto merged sql/field_conv.cc: Auto merged
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index a718a402897..9771cbc12b1 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -433,6 +433,26 @@ static void do_varstring1(Copy_field *copy)
}
+static void do_varstring1_mb(Copy_field *copy)
+{
+ int well_formed_error;
+ CHARSET_INFO *cs= copy->from_field->charset();
+ uint from_length= (uint) *(uchar*) copy->from_ptr;
+ const char *from_ptr= copy->from_ptr + 1;
+ uint to_char_length= (copy->to_length - 1) / cs->mbmaxlen;
+ uint length= cs->cset->well_formed_len(cs, from_ptr, from_ptr + from_length,
+ to_char_length, &well_formed_error);
+ if (length < from_length)
+ {
+ if (current_thd->count_cuted_fields)
+ copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
+ WARN_DATA_TRUNCATED, 1);
+ }
+ *(uchar*) copy->to_ptr= (uchar) length;
+ memcpy(copy->to_ptr + 1, from_ptr, length);
+}
+
+
static void do_varstring2(Copy_field *copy)
{
uint length=uint2korr(copy->from_ptr);
@@ -458,6 +478,12 @@ static void do_varstring2_mb(Copy_field *copy)
const char *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH;
uint length= cs->cset->well_formed_len(cs, from_beg, from_beg + from_length,
char_length, &well_formed_error);
+ if (length < from_length)
+ {
+ if (current_thd->count_cuted_fields)
+ copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
+ WARN_DATA_TRUNCATED, 1);
+ }
int2store(copy->to_ptr, length);
memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, length);
}
@@ -633,8 +659,10 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
return do_field_string;
if (to_length != from_length)
return (((Field_varstring*) to)->length_bytes == 1 ?
- do_varstring1 : (from->charset()->mbmaxlen == 1 ?
- do_varstring2 : do_varstring2_mb));
+ (from->charset()->mbmaxlen == 1 ? do_varstring1 :
+ do_varstring1_mb) :
+ (from->charset()->mbmaxlen == 1 ? do_varstring2 :
+ do_varstring2_mb));
}
else if (to_length < from_length)
return (from->charset()->mbmaxlen == 1 ?