summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2016-12-16 14:06:12 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2016-12-16 14:06:12 +0400
commitce55094f4fee3c0ff2c58ac4dd3ef2c16c5e20c3 (patch)
treecb620419c3911e9ca671e2ba24ba6b795cd454da
parent30c231b03a270d3056d2e0da6e263ac10091567b (diff)
downloadmariadb-git-ce55094f4fee3c0ff2c58ac4dd3ef2c16c5e20c3.tar.gz
MDEV-11572 JSON_DEPTH returns wrong results.
JSON depth calculation fixed.
-rw-r--r--mysql-test/r/func_json.result3
-rw-r--r--mysql-test/t/func_json.test1
-rw-r--r--sql/item_jsonfunc.cc1
3 files changed, 5 insertions, 0 deletions
diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result
index 8ce3ccb876f..a704274a112 100644
--- a/mysql-test/r/func_json.result
+++ b/mysql-test/r/func_json.result
@@ -405,6 +405,9 @@ json_depth('[[], {}]')
select json_depth('[[[1,2,3],"s"], {}, []]');
json_depth('[[[1,2,3],"s"], {}, []]')
4
+select json_depth('[10, {"a": 20}]');
+json_depth('[10, {"a": 20}]')
+3
select json_length('');
json_length('')
NULL
diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test
index b85b89c068d..a1d3d819adf 100644
--- a/mysql-test/t/func_json.test
+++ b/mysql-test/t/func_json.test
@@ -163,6 +163,7 @@ select cast(NULL AS JSON);
select json_depth(cast(NULL as JSON));
select json_depth('[[], {}]');
select json_depth('[[[1,2,3],"s"], {}, []]');
+select json_depth('[10, {"a": 20}]');
select json_length('');
select json_length('{}');
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 413b241f496..42570984e8d 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -1624,6 +1624,7 @@ longlong Item_func_json_depth::val_int()
switch (je.state)
{
case JST_VALUE:
+ case JST_KEY:
if (inc_depth)
{
c_depth++;