summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <bar@bar.myoffice.izhnet.ru>2007-05-31 12:10:37 +0500
committerunknown <bar@bar.myoffice.izhnet.ru>2007-05-31 12:10:37 +0500
commit7dacbd701d1cbddaea16cd31ed0b030561b8af15 (patch)
treef915de7bec4835640139570ecb836c1472597350 /sql/field.cc
parentfec3d7c6aea43070d85bae207f45da02c186db70 (diff)
parentc7dfc326d420409b794a81837ec1da5c13df24eb (diff)
downloadmariadb-git-7dacbd701d1cbddaea16cd31ed0b030561b8af15.tar.gz
Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.1-rpl
into mysql.com:/home/bar/mysql-5.1.b28600 sql/field.cc: Auto merged
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/sql/field.cc b/sql/field.cc
index fa25871fe61..0c647bd66f5 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5911,6 +5911,7 @@ void Field_datetime::sql_type(String &res) const
well_formed_error_pos - where not well formed data was first met
cannot_convert_error_pos - where a not-convertable character was first met
end - end of the string
+ cs - character set of the string
NOTES
As of version 5.0 both cases return the same error:
@@ -5930,7 +5931,8 @@ static bool
check_string_copy_error(Field_str *field,
const char *well_formed_error_pos,
const char *cannot_convert_error_pos,
- const char *end)
+ const char *end,
+ CHARSET_INFO *cs)
{
const char *pos, *end_orig;
char tmp[64], *t;
@@ -5944,8 +5946,18 @@ check_string_copy_error(Field_str *field,
for (t= tmp; pos < end; pos++)
{
+ /*
+ If the source string is ASCII compatible (mbminlen==1)
+ and the source character is in ASCII printable range (0x20..0x7F),
+ then display the character as is.
+
+ Otherwise, if the source string is not ASCII compatible (e.g. UCS2),
+ or the source character is not in the printable range,
+ then print the character using HEX notation.
+ */
if (((unsigned char) *pos) >= 0x20 &&
- ((unsigned char) *pos) <= 0x7F)
+ ((unsigned char) *pos) <= 0x7F &&
+ cs->mbminlen == 1)
{
*t++= *pos;
}
@@ -6027,7 +6039,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
field_charset->pad_char);
if (check_string_copy_error(this, well_formed_error_pos,
- cannot_convert_error_pos, from + length))
+ cannot_convert_error_pos, from + length, cs))
return 2;
/*
@@ -6479,7 +6491,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
int2store(ptr, copy_length);
if (check_string_copy_error(this, well_formed_error_pos,
- cannot_convert_error_pos, from + length))
+ cannot_convert_error_pos, from + length, cs))
return 2;
// Check if we lost something other than just trailing spaces
@@ -7160,7 +7172,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
bmove(ptr+packlength,(char*) &tmp,sizeof(char*));
if (check_string_copy_error(this, well_formed_error_pos,
- cannot_convert_error_pos, from + length))
+ cannot_convert_error_pos, from + length, cs))
return 2;
if (from_end_pos < from + length)