diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2018-06-17 17:15:21 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2018-06-17 17:15:21 +0400 |
commit | 352c7e0dfaa0f121c5b35e1d9fafb9ec8897e768 (patch) | |
tree | ef8bd11207fabc7c6e02fea9e0974c8b18a54d7a /sql/item_jsonfunc.cc | |
parent | b8514c94f61f37757a24df1c6b9a7dd530b3de12 (diff) | |
download | mariadb-git-352c7e0dfaa0f121c5b35e1d9fafb9ec8897e768.tar.gz |
MDEV-15905 select json_value('{"b":true}','$.b')=1 --> false with
"Truncated incorrect DOUBLE value: 'true'".
JSON_VALUE_TRUE and JSON_VALUE_FALSE should be handled specifically
in Item_json_value.
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r-- | sql/item_jsonfunc.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 72aeac5b930..c8cda66580c 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -513,6 +513,10 @@ err_return: bool Item_func_json_value::check_and_get_value(json_engine_t *je, String *res, int *error) { + CHARSET_INFO *json_cs; + const uchar *js; + uint js_len; + if (!json_value_scalar(je)) { /* We only look for scalar values! */ @@ -521,7 +525,22 @@ bool Item_func_json_value::check_and_get_value(json_engine_t *je, String *res, return true; } - return st_append_json(res, je->s.cs, je->value, je->value_len); + if (je->value_type == JSON_VALUE_TRUE || + je->value_type == JSON_VALUE_FALSE) + { + json_cs= &my_charset_utf8mb4_bin; + js= (const uchar *) ((je->value_type == JSON_VALUE_TRUE) ? "1" : "0"); + js_len= 1; + } + else + { + json_cs= je->s.cs; + js= je->value; + js_len= je->value_len; + } + + + return st_append_json(res, json_cs, js, js_len); } |