diff options
author | unknown <jimw@mysql.com> | 2005-12-06 14:16:34 -0800 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-12-06 14:16:34 -0800 |
commit | bf802ab7684019e14a0009169010a9542fced065 (patch) | |
tree | 86ef9f34ecc2f91912ab3c3501327e29d7d81573 /sql/field.cc | |
parent | 3d1e9eae43a2cd353278b18da37c0ab28d88357d (diff) | |
parent | c3ecc18f0ce54ec7bf94d25d41ac2d1b99e164dc (diff) | |
download | mariadb-git-bf802ab7684019e14a0009169010a9542fced065.tar.gz |
Merge mysql.com:/home/jimw/my/mysql-5.0-14299
into mysql.com:/home/jimw/my/mysql-5.0-clean
sql/field.cc:
Auto merged
mysql-test/r/type_binary.result:
Resolve conflicts
mysql-test/t/type_binary.test:
Resolve conflicts
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/sql/field.cc b/sql/field.cc index 6de2a731030..3903d8323ad 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5855,44 +5855,52 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) char buff[STRING_BUFFER_USUAL_SIZE]; String tmpstr(buff,sizeof(buff), &my_charset_bin); uint copy_length; - + /* See the comment for Field_long::store(long long) */ DBUG_ASSERT(table->in_use == current_thd); - + /* Convert character set if necessary */ if (String::needs_conversion(length, cs, field_charset, ¬_used)) - { + { uint conv_errors; tmpstr.copy(from, length, cs, field_charset, &conv_errors); from= tmpstr.ptr(); - length= tmpstr.length(); + length= tmpstr.length(); if (conv_errors) error= 2; } - /* - Make sure we don't break a multibyte sequence - as well as don't copy a malformed data. - */ + /* Make sure we don't break a multibyte sequence or copy malformed data. */ copy_length= field_charset->cset->well_formed_len(field_charset, from,from+length, field_length/ field_charset->mbmaxlen, &well_formed_error); memcpy(ptr,from,copy_length); - if (copy_length < field_length) // Append spaces if shorter + + /* Append spaces if the string was shorter than the field. */ + if (copy_length < field_length) field_charset->cset->fill(field_charset,ptr+copy_length, - field_length-copy_length, + field_length-copy_length, field_charset->pad_char); - + + /* + Check if we lost any important data (anything in a binary string, + or any non-space in others). + */ if ((copy_length < length) && table->in_use->count_cuted_fields) - { // Check if we loosed some info - const char *end=from+length; - from+= copy_length; - from+= field_charset->cset->scan(field_charset, from, end, - MY_SEQ_SPACES); - if (from != end) + { + if (binary()) error= 2; + else + { + const char *end=from+length; + from+= copy_length; + from+= field_charset->cset->scan(field_charset, from, end, + MY_SEQ_SPACES); + if (from != end) + error= 2; + } } if (error) { @@ -6271,12 +6279,15 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) if ((copy_length < length) && table->in_use->count_cuted_fields && !error_code) { - const char *end= from + length; - from+= copy_length; - from+= field_charset->cset->scan(field_charset, from, end, MY_SEQ_SPACES); - /* If we lost only spaces then produce a NOTE, not a WARNING */ - if (from == end) - level= MYSQL_ERROR::WARN_LEVEL_NOTE; + if (!binary()) + { + const char *end= from + length; + from+= copy_length; + from+= field_charset->cset->scan(field_charset, from, end, MY_SEQ_SPACES); + /* If we lost only spaces then produce a NOTE, not a WARNING */ + if (from == end) + level= MYSQL_ERROR::WARN_LEVEL_NOTE; + } error_code= WARN_DATA_TRUNCATED; } if (error_code) |