summaryrefslogtreecommitdiff
path: root/sql/item_jsonfunc.cc
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2017-10-05 23:23:39 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2017-10-05 23:23:39 +0400
commit1f6ada8da8dbbe8c2d9e50ed0d4bd54c6f81653b (patch)
tree5af3e7fa186188e61da3648fc71cd6c6073a4475 /sql/item_jsonfunc.cc
parent08c493c62afae0e81f9da6bb9b86efe99a9a763d (diff)
downloadmariadb-git-1f6ada8da8dbbe8c2d9e50ed0d4bd54c6f81653b.tar.gz
MDEV-13306 JSON_CONTAINS returns wrong value.
The 'value' state should be saved to be compared against the next array item.
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r--sql/item_jsonfunc.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 77363f80919..d0cde98de3d 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -1011,6 +1011,8 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
case JSON_VALUE_ARRAY:
if (value->value_type != JSON_VALUE_ARRAY)
{
+ loc_js= *value;
+ set_js= FALSE;
while (json_scan_next(js) == 0 && js->state != JST_ARRAY_END)
{
int c_level, v_scalar;
@@ -1021,6 +1023,11 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
if (!(v_scalar= json_value_scalar(js)))
c_level= json_get_level(js);
+ if (set_js)
+ *value= loc_js;
+ else
+ set_js= TRUE;
+
if (check_contains(js, value))
{
if (json_skip_level(js))