Skip to content
Permalink
Browse files
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.
  • Loading branch information
Alexey Botchkov committed Jun 17, 2018
1 parent b8514c9 commit 352c7e0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
@@ -739,3 +739,6 @@ drop table t1;
select json_extract('{"test":8.437e-5}','$.test');
json_extract('{"test":8.437e-5}','$.test')
8.437e-5
select json_value('{"b":true}','$.b')=1;
json_value('{"b":true}','$.b')=1
1
@@ -398,3 +398,10 @@ drop table t1;

select json_extract('{"test":8.437e-5}','$.test');

#
# MDEV-15905 select json_value('{"b":true}','$.b')=1 --> false with
# "Truncated incorrect DOUBLE value: 'true'"
#
select json_value('{"b":true}','$.b')=1;


@@ -513,6 +513,10 @@ String *Item_func_json_value::val_str(String *str)
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);
}


0 comments on commit 352c7e0

Please sign in to comment.