diff options
author | Alexander Barkov <bar@mariadb.org> | 2016-10-10 14:36:09 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2016-10-10 14:36:09 +0400 |
commit | 5058ced5df7a4ee3ff011577829fb2e4a6f47843 (patch) | |
tree | 8f90cd07e71cef5dc09adfd825712f812f978f57 /sql/field_conv.cc | |
parent | a6f032af5778018051d41fc8ba7e9c983b4b7fbf (diff) | |
download | mariadb-git-5058ced5df7a4ee3ff011577829fb2e4a6f47843.tar.gz |
MDEV-7769 MY_CHARSET_INFO refactoring# On branch 10.2
Part 3 (final): removing MY_CHARSET_HANDLER::well_formed_len().
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r-- | sql/field_conv.cc | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 263c5bb5017..85101fd5f0a 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -467,20 +467,19 @@ static void do_cut_string(Copy_field *copy) static void do_cut_string_complex(Copy_field *copy) { // Shorter string field - int well_formed_error; CHARSET_INFO *cs= copy->from_field->charset(); const uchar *from_end= copy->from_ptr + copy->from_length; - uint copy_length= cs->cset->well_formed_len(cs, - (char*) copy->from_ptr, - (char*) from_end, - copy->to_length / cs->mbmaxlen, - &well_formed_error); + Well_formed_prefix prefix(cs, + (char*) copy->from_ptr, + (char*) from_end, + copy->to_length / cs->mbmaxlen); + uint copy_length= prefix.length(); if (copy->to_length < copy_length) copy_length= copy->to_length; memcpy(copy->to_ptr, copy->from_ptr, copy_length); /* Check if we lost any important characters */ - if (well_formed_error || + if (prefix.well_formed_error_pos() || cs->cset->scan(cs, (char*) copy->from_ptr + copy_length, (char*) from_end, MY_SEQ_SPACES) < (copy->from_length - copy_length)) @@ -534,22 +533,19 @@ 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 uchar *from_ptr= copy->from_ptr + 1; uint to_char_length= (copy->to_length - 1) / cs->mbmaxlen; - uint length= cs->cset->well_formed_len(cs, (char*) from_ptr, - (char*) from_ptr + from_length, - to_char_length, &well_formed_error); - if (length < from_length) + Well_formed_prefix prefix(cs, (char*) from_ptr, from_length, to_char_length); + if (prefix.length() < from_length) { if (current_thd->count_cuted_fields) copy->to_field->set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } - *copy->to_ptr= (uchar) length; - memcpy(copy->to_ptr + 1, from_ptr, length); + *copy->to_ptr= (uchar) prefix.length(); + memcpy(copy->to_ptr + 1, from_ptr, prefix.length()); } @@ -572,22 +568,19 @@ static void do_varstring2(Copy_field *copy) static void do_varstring2_mb(Copy_field *copy) { - int well_formed_error; CHARSET_INFO *cs= copy->from_field->charset(); uint char_length= (copy->to_length - HA_KEY_BLOB_LENGTH) / cs->mbmaxlen; uint from_length= uint2korr(copy->from_ptr); const uchar *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH; - uint length= cs->cset->well_formed_len(cs, (char*) from_beg, - (char*) from_beg + from_length, - char_length, &well_formed_error); - if (length < from_length) + Well_formed_prefix prefix(cs, (char*) from_beg, from_length, char_length); + if (prefix.length() < from_length) { if (current_thd->count_cuted_fields) copy->to_field->set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } - int2store(copy->to_ptr, length); - memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, length); + int2store(copy->to_ptr, prefix.length()); + memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, prefix.length()); } |