mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-11489 Assertion `0' failed in json_find_path.
When the json was just a scalar value, json_extract tried to parse after the value ended.
This commit is contained in:
@@ -138,6 +138,9 @@ json_extract('[10, 20, [30, 40]]', '$[2][*]')
|
|||||||
select json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]');
|
select json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]');
|
||||||
json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]')
|
json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]')
|
||||||
[{"a":3}, 30, 40]
|
[{"a":3}, 30, 40]
|
||||||
|
select json_extract('1', '$');
|
||||||
|
json_extract('1', '$')
|
||||||
|
1
|
||||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
|
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
|
||||||
json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word')
|
json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word')
|
||||||
{"a":1, "b":{"c":1, "k1":"word"}, "d":[1, 2]}
|
{"a":1, "b":{"c":1, "k1":"word"}, "d":[1, 2]}
|
||||||
|
@@ -54,6 +54,7 @@ select json_extract('{"key0":true, "key1":"qwe"}', "$.key1");
|
|||||||
select json_extract(json_object('foo', 'foobar'),'$');
|
select json_extract(json_object('foo', 'foobar'),'$');
|
||||||
select json_extract('[10, 20, [30, 40]]', '$[2][*]');
|
select json_extract('[10, 20, [30, 40]]', '$[2][*]');
|
||||||
select json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]');
|
select json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]');
|
||||||
|
select json_extract('1', '$');
|
||||||
|
|
||||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
|
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
|
||||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3);
|
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3);
|
||||||
|
@@ -476,9 +476,6 @@ String *Item_func_json_extract::val_str(String *str)
|
|||||||
v_len= je.s.c_str - value;
|
v_len= je.s.c_str - value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json_scan_next(&je) && je.s.error)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (!multiple_values_found)
|
if (!multiple_values_found)
|
||||||
{
|
{
|
||||||
if (first_value == NULL)
|
if (first_value == NULL)
|
||||||
@@ -489,7 +486,6 @@ String *Item_func_json_extract::val_str(String *str)
|
|||||||
*/
|
*/
|
||||||
first_value= (const char *) value;
|
first_value= (const char *) value;
|
||||||
first_len= v_len;
|
first_len= v_len;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -500,15 +496,20 @@ String *Item_func_json_extract::val_str(String *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (str->append(", ", 2) ||
|
if (multiple_values_found &&
|
||||||
str->append((const char *) value, v_len))
|
(str->append(", ", 2) ||
|
||||||
|
str->append((const char *) value, v_len)))
|
||||||
goto error; /* Out of memory. */
|
goto error; /* Out of memory. */
|
||||||
}
|
|
||||||
|
|
||||||
if (je.s.error)
|
if (json_scan_next(&je))
|
||||||
goto error;
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (je.s.error)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (first_value == NULL)
|
if (first_value == NULL)
|
||||||
{
|
{
|
||||||
/* Nothing was found. */
|
/* Nothing was found. */
|
||||||
|
Reference in New Issue
Block a user