Commit a3ba8c36 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-13703 Illegal mix of collations for operation 'json_object' on

using JSON_UNQUOTE as an argument.

        The coercibility and repertoire should be set properly for the
        JSON_UNQUOTE.
parent 41e581b3
...@@ -405,6 +405,13 @@ abc ...@@ -405,6 +405,13 @@ abc
select json_unquote('abc'); select json_unquote('abc');
json_unquote('abc') json_unquote('abc')
abc abc
create table t1 (c VARCHAR(8)) DEFAULT CHARSET=latin1;
insert into t1 values ('abc'),('def');
select json_object('foo', json_unquote(json_object('bar', c)),'qux', c) as fld from t1;
fld
{"foo": "{\"bar\": \"abc\"}", "qux": "abc"}
{"foo": "{\"bar\": \"def\"}", "qux": "def"}
drop table t1;
select json_object("a", json_object("b", "abcd")); select json_object("a", json_object("b", "abcd"));
json_object("a", json_object("b", "abcd")) json_object("a", json_object("b", "abcd"))
{"a": {"b": "abcd"}} {"a": {"b": "abcd"}}
......
...@@ -164,6 +164,14 @@ drop table t1; ...@@ -164,6 +164,14 @@ drop table t1;
select json_unquote('"abc"'); select json_unquote('"abc"');
select json_unquote('abc'); select json_unquote('abc');
#
# MDEV-13703 Illegal mix of collations for operation 'json_object' on using JSON_UNQUOTE as an argument.
#
create table t1 (c VARCHAR(8)) DEFAULT CHARSET=latin1;
insert into t1 values ('abc'),('def');
select json_object('foo', json_unquote(json_object('bar', c)),'qux', c) as fld from t1;
drop table t1;
select json_object("a", json_object("b", "abcd")); select json_object("a", json_object("b", "abcd"));
select json_object("a", '{"b": "abcd"}'); select json_object("a", '{"b": "abcd"}');
......
...@@ -581,7 +581,8 @@ String *Item_func_json_quote::val_str(String *str) ...@@ -581,7 +581,8 @@ String *Item_func_json_quote::val_str(String *str)
void Item_func_json_unquote::fix_length_and_dec() void Item_func_json_unquote::fix_length_and_dec()
{ {
collation.set(&my_charset_utf8_general_ci); collation.set(&my_charset_utf8_general_ci,
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length= args[0]->max_length; max_length= args[0]->max_length;
maybe_null= 1; maybe_null= 1;
} }
...@@ -1458,7 +1459,8 @@ void Item_func_json_array::fix_length_and_dec() ...@@ -1458,7 +1459,8 @@ void Item_func_json_array::fix_length_and_dec()
if (arg_count == 0) if (arg_count == 0)
{ {
collation.set(&my_charset_utf8_general_ci); collation.set(&my_charset_utf8_general_ci,
DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
tmp_val.set_charset(&my_charset_utf8_general_ci); tmp_val.set_charset(&my_charset_utf8_general_ci);
max_length= 2; max_length= 2;
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment