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
b28626e8
Commit
b28626e8
authored
Dec 03, 2016
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11441 Server crashes in String::append /Item_func_json_extract::val_str.
Wrong 'value_lengh' taken
parent
1e2b46d5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
12 deletions
+9
-12
mysql-test/r/func_json.result
mysql-test/r/func_json.result
+5
-2
mysql-test/t/func_json.test
mysql-test/t/func_json.test
+1
-0
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+3
-10
No files found.
mysql-test/r/func_json.result
View file @
b28626e8
...
...
@@ -90,7 +90,7 @@ json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2")
1
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1");
json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1")
asd
"asd"
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY");
json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY")
NULL
...
...
@@ -102,7 +102,10 @@ json_extract('{"key1":5, "key2":[2,3]}', "$.key1", "$.key2")
[5, [2,3]]
select json_extract('{"key0":true, "key1":"qwe"}', "$.key1");
json_extract('{"key0":true, "key1":"qwe"}', "$.key1")
qwe
"qwe"
select json_extract(json_object('foo', 'foobar'),'$');
json_extract(json_object('foo', 'foobar'),'$')
{"foo": "foobar"}
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word')
{"a":1, "b":{"c":1, "k1":"word"}, "d":[1, 2]}
...
...
mysql-test/t/func_json.test
View file @
b28626e8
...
...
@@ -41,6 +41,7 @@ select json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY");
select
json_extract
(
'{"key1":"asd", "key2":[2,3]}'
,
"$.key1"
,
"$.key2"
);
select
json_extract
(
'{"key1":5, "key2":[2,3]}'
,
"$.key1"
,
"$.key2"
);
select
json_extract
(
'{"key0":true, "key1":"qwe"}'
,
"$.key1"
);
select
json_extract
(
json_object
(
'foo'
,
'foobar'
),
'$'
);
select
json_insert
(
'{"a":1, "b":{"c":1}, "d":[1, 2]}'
,
'$.b.k1'
,
'word'
);
select
json_insert
(
'{"a":1, "b":{"c":1}, "d":[1, 2]}'
,
'$.d[3]'
,
3
);
...
...
sql/item_jsonfunc.cc
View file @
b28626e8
...
...
@@ -427,8 +427,8 @@ String *Item_func_json_extract::val_str(String *str)
json_engine_t
je
;
bool
multiple_values_found
=
FALSE
;
const
uchar
*
value
;
const
char
*
first_value
=
NULL
,
*
first_p_value
;
uint
n_arg
,
v_len
,
first_len
,
first_p_len
;
const
char
*
first_value
=
NULL
;
uint
n_arg
,
v_len
,
first_len
;
uint
array_counters
[
JSON_DEPTH_LIMIT
];
if
((
null_value
=
args
[
0
]
->
null_value
))
...
...
@@ -487,13 +487,6 @@ String *Item_func_json_extract::val_str(String *str)
*/
first_value
=
(
const
char
*
)
value
;
first_len
=
v_len
;
/*
We need this as we have to preserve quotes around string
constants if we use the value to create an array. Otherwise
we get the value without the quotes.
*/
first_p_value
=
(
const
char
*
)
je
.
value
;
first_p_len
=
je
.
value_len
;
continue
;
}
else
...
...
@@ -519,7 +512,7 @@ String *Item_func_json_extract::val_str(String *str)
if
(
multiple_values_found
?
str
->
append
(
"]"
)
:
str
->
append
(
first_
p_value
,
first_p
_len
))
str
->
append
(
first_
value
,
first
_len
))
goto
error
;
/* Out of memory. */
return
str
;
...
...
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