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
0e6968c2
Commit
0e6968c2
authored
Feb 09, 2017
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11857 json_search() shows "Out of memory" with empty key.
We should be ready for an empty key.
parent
66c6188a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
mysql-test/t/func_json.test
mysql-test/t/func_json.test
+5
-0
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+8
-4
strings/json_lib.c
strings/json_lib.c
+3
-1
No files found.
mysql-test/t/func_json.test
View file @
0e6968c2
...
...
@@ -220,3 +220,8 @@ SELECT json_replace('1', '$[0][0]', 100);
SELECT
json_replace
(
'[]'
,
'$[0][0]'
,
100
);
SELECT
json_set
(
'[]'
,
'$[0][0]'
,
100
);
SELECT
json_set
(
'[]'
,
'$[0][0][0]'
,
100
);
#
# MDEV-11857 json_search() shows "Out of memory" with empty key.
#
SELECT
JSON_search
(
'{"": "a"}'
,
"one"
,
'a'
);
sql/item_jsonfunc.cc
View file @
0e6968c2
...
...
@@ -147,8 +147,10 @@ static int json_nice(json_engine_t *je, String *nice_js,
const
uchar
*
key_start
=
je
->
s
.
c_str
;
const
uchar
*
key_end
;
while
(
json_read_keyname_chr
(
je
)
==
0
)
do
{
key_end
=
je
->
s
.
c_str
;
}
while
(
json_read_keyname_chr
(
je
)
==
0
);
if
(
je
->
s
.
error
)
goto
error
;
...
...
@@ -892,8 +894,10 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
DBUG_ASSERT
(
value
->
state
==
JST_KEY
);
k_start
=
value
->
s
.
c_str
;
while
(
json_read_keyname_chr
(
value
)
==
0
)
do
{
k_end
=
value
->
s
.
c_str
;
}
while
(
json_read_keyname_chr
(
value
)
==
0
);
if
(
value
->
s
.
error
||
json_read_value
(
value
))
return
FALSE
;
...
...
@@ -2527,10 +2531,10 @@ String *Item_func_json_keys::val_str(String *str)
{
case
JST_KEY
:
key_start
=
je
.
s
.
c_str
;
while
(
json_read_keyname_chr
(
&
je
)
==
0
)
do
{
key_end
=
je
.
s
.
c_str
;
}
}
while
(
json_read_keyname_chr
(
&
je
)
==
0
);
if
(
je
.
s
.
error
||
(
n_keys
>
0
&&
str
->
append
(
", "
,
2
))
||
str
->
append
(
"
\"
"
,
1
)
||
...
...
strings/json_lib.c
View file @
0e6968c2
...
...
@@ -1701,8 +1701,10 @@ int json_get_path_next(json_engine_t *je, json_path_t *p)
{
case
JST_KEY
:
p
->
last_step
->
key
=
je
->
s
.
c_str
;
while
(
json_read_keyname_chr
(
je
)
==
0
)
do
{
p
->
last_step
->
key_end
=
je
->
s
.
c_str
;
}
while
(
json_read_keyname_chr
(
je
)
==
0
);
if
(
je
->
s
.
error
)
return
1
;
/* Now we have je.state == JST_VALUE, so let's handle it. */
...
...
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