1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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.
This commit is contained in:
Alexey Botchkov
2018-06-17 17:15:21 +04:00
parent b8514c94f6
commit 352c7e0dfa
3 changed files with 30 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);
}