Skip to content

Commit

Permalink
MDEV-11465 JSON_LENGTH returns incorrect length.
Browse files Browse the repository at this point in the history
        Item_func_json_length::val_int fixed.
  • Loading branch information
Alexey Botchkov committed Dec 5, 2016
1 parent 75a5181 commit 2b01461
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions mysql-test/r/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,12 @@ json_depth('[[], {}]')
select json_depth('[[[1,2,3],"s"], {}, []]');
json_depth('[[[1,2,3],"s"], {}, []]')
4
select json_length('');
json_length('')
NULL
select json_length('{}');
json_length('{}')
0
select json_length('[1, 2, {"a": 3}]');
json_length('[1, 2, {"a": 3}]')
3
3 changes: 3 additions & 0 deletions mysql-test/t/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,6 @@ select json_depth(cast(NULL as JSON));
select json_depth('[[], {}]');
select json_depth('[[[1,2,3],"s"], {}, []]');

select json_length('');
select json_length('{}');
select json_length('[1, 2, {"a": 3}]');
3 changes: 1 addition & 2 deletions sql/item_jsonfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1271,8 +1271,7 @@ longlong Item_func_json_length::val_int()
return 0;
}

return length;

return length - 1;
}


Expand Down

0 comments on commit 2b01461

Please sign in to comment.