diff options
author | Alexander Barkov <bar@mysql.com> | 2009-12-03 13:22:34 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mysql.com> | 2009-12-03 13:22:34 +0400 |
commit | 3707a74e6e97a86531d2284e8e3106b30c2297b2 (patch) | |
tree | 3152f716767e41822bbe0021a9a83e466894e33d /sql/item_timefunc.cc | |
parent | e4344ffa4199b0dcab72e3f93e9f572f2610fa74 (diff) | |
download | mariadb-git-3707a74e6e97a86531d2284e8e3106b30c2297b2.tar.gz |
Bug#44131 Binary-mode "order by" returns records in incorrect order for UTF-8 strings
Problem: Item_char_typecast reported wrong max_length when
casting to BINARY, which lead, in particular, in wrong
"ORDER BY BINARY(char_column)" results.
Fix: making Item_char_typecast report correct max_length.
@ mysql-test/r/ctype_utf16.result
Fixing old incorrect test result.
@ mysql-test/r/ctype_utf32.result
Fixing old incorrect test result.
@ mysql-test/r/ctype_utf8.result
Adding new test
@ mysql-test/t/ctype_utf8.test
Adding new test
@ sql/item_timefunc.cc
Making Item_char_typecast report correct max_length
when cast is done to BINARY.
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index b293145cc27..ded4d28ca29 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2554,9 +2554,9 @@ void Item_char_typecast::fix_length_and_dec() from_cs != &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; + char_length= (cast_length >= 0) ? cast_length : + args[0]->max_length / + (cast_cs == &my_charset_bin ? 1 : args[0]->collation.collation->mbmaxlen); max_length= char_length * cast_cs->mbmaxlen; } |