Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
7e03c67a
Commit
7e03c67a
authored
Dec 05, 2016
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11474 JSON_DEPTH returns incorrect results.
Item_func_json_depth::val_int fixed.
parent
78dc7c3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
mysql-test/r/func_json.result
mysql-test/r/func_json.result
+6
-0
mysql-test/t/func_json.test
mysql-test/t/func_json.test
+2
-0
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+10
-2
No files found.
mysql-test/r/func_json.result
View file @
7e03c67a
...
...
@@ -277,3 +277,9 @@ NULL
select json_depth(cast(NULL as JSON));
json_depth(cast(NULL as JSON))
NULL
select json_depth('[[], {}]');
json_depth('[[], {}]')
2
select json_depth('[[[1,2,3],"s"], {}, []]');
json_depth('[[[1,2,3],"s"], {}, []]')
4
mysql-test/t/func_json.test
View file @
7e03c67a
...
...
@@ -123,4 +123,6 @@ select json_object("a", cast('{"b": "abcd"}' as json));
select
cast
(
NULL
AS
JSON
);
select
json_depth
(
cast
(
NULL
as
JSON
));
select
json_depth
(
'[[], {}]'
);
select
json_depth
(
'[[[1,2,3],"s"], {}, []]'
);
sql/item_jsonfunc.cc
View file @
7e03c67a
...
...
@@ -1235,7 +1235,7 @@ longlong Item_func_json_depth::val_int()
{
String
*
js
=
args
[
0
]
->
val_str
(
&
tmp_js
);
json_engine_t
je
;
uint
depth
=
0
;
uint
depth
=
0
,
c_depth
=
0
;
bool
inc_depth
=
TRUE
;
if
((
null_value
=
args
[
0
]
->
null_value
))
...
...
@@ -1252,14 +1252,22 @@ longlong Item_func_json_depth::val_int()
case
JST_VALUE
:
if
(
inc_depth
)
{
depth
++
;
c_
depth
++
;
inc_depth
=
FALSE
;
if
(
c_depth
>
depth
)
depth
=
c_depth
;
}
break
;
case
JST_OBJ_START
:
case
JST_ARRAY_START
:
inc_depth
=
TRUE
;
break
;
case
JST_OBJ_END
:
case
JST_ARRAY_END
:
if
(
!
inc_depth
)
c_depth
--
;
inc_depth
=
FALSE
;
break
;
default:
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment