From bc09362eb312eff5eb2203963d75f368fea3f4ad Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 11 Oct 2021 09:27:38 +0200 Subject: [PATCH] MDEV-26796 Natural sort does not work for utf32/utf16/ucs2 Fixed typo, added test. --- mysql-test/main/natural_sort_key.result | 3 +++ mysql-test/main/natural_sort_key.test | 2 ++ sql/item_strfunc.cc | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/natural_sort_key.result b/mysql-test/main/natural_sort_key.result index 10adc7acef3..46151dc8446 100644 --- a/mysql-test/main/natural_sort_key.result +++ b/mysql-test/main/natural_sort_key.result @@ -203,3 +203,6 @@ NULL NULL a2 a02 a11 a111 drop table t; +select natural_sort_key(_utf16 0x0031),natural_sort_key(_ucs2 0x0031), natural_sort_key(_utf32 0x00000031); +natural_sort_key(_utf16 0x0031) natural_sort_key(_ucs2 0x0031) natural_sort_key(_utf32 0x00000031) +01 01 01 diff --git a/mysql-test/main/natural_sort_key.test b/mysql-test/main/natural_sort_key.test index 4f4e2b0e05e..fbd4e6e0172 100644 --- a/mysql-test/main/natural_sort_key.test +++ b/mysql-test/main/natural_sort_key.test @@ -93,3 +93,5 @@ select * from t order by b; select a, b from t order by b; drop table t; +# MDEV-26796 Natural sort does not work for utf32/utf16/ucs2 +select natural_sort_key(_utf16 0x0031),natural_sort_key(_ucs2 0x0031), natural_sort_key(_utf32 0x00000031); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f43115fef54..a13728295b8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -5657,7 +5657,7 @@ String *Item_func_natural_sort_key::val_str(String *out) */ if (cs->mbminlen != 1) { - if (!tmp.copy(in, &my_charset_utf8mb4_bin, &errs)) + if (tmp.copy(in, &my_charset_utf8mb4_bin, &errs)) goto error_exit; in= &tmp; }