summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/func_json.result3
-rw-r--r--mysql-test/t/func_json.test6
-rw-r--r--strings/json_lib.c1
3 files changed, 10 insertions, 0 deletions
diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result
index cc682a0756d..a0a81914e98 100644
--- a/mysql-test/r/func_json.result
+++ b/mysql-test/r/func_json.result
@@ -633,3 +633,6 @@ SET @str = 'bar', @path = '$';
SELECT JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path);
JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path)
"$.foo"
+SELECT JSON_VALUE('[{"foo": 1},"bar"]', '$[*][0]');
+JSON_VALUE('[{"foo": 1},"bar"]', '$[*][0]')
+bar
diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test
index 7ff5f3f13d9..ce13456bf25 100644
--- a/mysql-test/t/func_json.test
+++ b/mysql-test/t/func_json.test
@@ -281,3 +281,9 @@ drop table t1;
SET @str = 'bar', @path = '$';
SELECT JSON_SEARCH('{"foo":"bar"}', 'all' , @str, '%', @path);
+#
+# MDEV-12351 Assertion `cur_step->type & JSON_PATH_KEY' failed in json_find_path.
+#
+
+SELECT JSON_VALUE('[{"foo": 1},"bar"]', '$[*][0]');
+
diff --git a/strings/json_lib.c b/strings/json_lib.c
index 5eda81d96c5..0e2a17b0ae0 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -1248,6 +1248,7 @@ static int handle_match(json_engine_t *je, json_path_t *p,
if (++next_step > p->last_step)
{
je->s.c_str= je->value_begin;
+ je->stack_p--;
return 1;
}
} while (next_step->type == JSON_PATH_ARRAY && next_step->n_item == 0);