diff options
author | ingo@mysql.com <> | 2005-01-27 12:18:02 +0100 |
---|---|---|
committer | ingo@mysql.com <> | 2005-01-27 12:18:02 +0100 |
commit | 48488e483a082c6ff320bf9c2766c2aa2c64c4b4 (patch) | |
tree | 444de60ab20a2de41ab01f6f904a717941f2f3ce /sql/item_timefunc.cc | |
parent | 160541b5d431ff9e2f5f02d0791723c0a0f78223 (diff) | |
parent | 42531336f0b3e79c9b58c41cf46831f30977e359 (diff) | |
download | mariadb-git-48488e483a082c6ff320bf9c2766c2aa2c64c4b4.tar.gz |
Merge mysql.com:/home/mydev/mysql-4.1-4100
into mysql.com:/home/mydev/mysql-5.0-5000
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 32813454fef..5a069aee554 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2134,7 +2134,6 @@ String *Item_char_typecast::val_str(String *str) String *res; uint32 length; -#if 0 if (!charset_conversion) { if (!(res= args[0]->val_str(str))) @@ -2144,7 +2143,6 @@ String *Item_char_typecast::val_str(String *str) } } else -#endif { // Convert character set if differ uint dummy_errors; @@ -2182,9 +2180,18 @@ String *Item_char_typecast::val_str(String *str) void Item_char_typecast::fix_length_and_dec() { uint32 char_length; - charset_conversion= !my_charset_same(args[0]->collation.collation, cast_cs) && - args[0]->collation.collation != &my_charset_bin && - cast_cs != &my_charset_bin; + /* + We always force character set conversion if cast_cs + is a multi-byte character set. It garantees that the + result of CAST is a well-formed string. + For single-byte character sets we allow just to copy + from the argument. A single-byte character sets string + is always well-formed. + */ + charset_conversion= (cast_cs->mbmaxlen > 1) || + !my_charset_same(args[0]->collation.collation, cast_cs) && + args[0]->collation.collation != &my_charset_bin && + cast_cs != &my_charset_bin; collation.set(cast_cs, DERIVATION_IMPLICIT); char_length= (cast_length >= 0) ? cast_length : args[0]->max_length/args[0]->collation.collation->mbmaxlen; |