diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result index 0c60c42ec77..5c3134b7ce9 100644 --- a/mysql-test/r/func_json.result +++ b/mysql-test/r/func_json.result @@ -699,3 +699,9 @@ select @str, @path, JSON_EXTRACT(@str, @path); select json_array(5,json_query('[1,2]','$')); json_array(5,json_query('[1,2]','$')) [5, [1,2]] +SELECT JSON_ARRAY('1. ě 2. š 3. č 4. ř 5. ž 6. ý 7. á 8. í 9. é 10. ů 11. ú') AS json_data; +json_data +["1. ě 2. š 3. č 4. ř 5. ž 6. ý 7. á 8. í 9. é 10. ů 11. ú"] +SELECT JSON_OBJECT("user","Jožko Mrkvičká") as json_data; +json_data +{"user": "Jožko Mrkvičká"} diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test index 39e31b8bb58..c660cb14856 100644 --- a/mysql-test/t/func_json.test +++ b/mysql-test/t/func_json.test @@ -354,3 +354,9 @@ select @str, @path, JSON_EXTRACT(@str, @path); # select json_array(5,json_query('[1,2]','$')); +# +# MDEV-13633 JSON_ARRAY() - bad output with some UTF8 characters. +# + +SELECT JSON_ARRAY('1. ě 2. š 3. č 4. ř 5. ž 6. ý 7. á 8. í 9. é 10. ů 11. ú') AS json_data; +SELECT JSON_OBJECT("user","Jožko Mrkvičká") as json_data; diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index a39b5f3f263..6398929defc 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -1473,6 +1473,7 @@ String *Item_func_json_array::val_str(String *str) uint n_arg; str->length(0); + str->set_charset(collation.collation); if (str->append("[", 1) || ((arg_count > 0) && append_json_value(str, args[0], &tmp_val))) @@ -1797,6 +1798,7 @@ String *Item_func_json_object::val_str(String *str) uint n_arg; str->length(0); + str->set_charset(collation.collation); if (str->append("{", 1) || (arg_count > 0 &&