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
4d10273b
Commit
4d10273b
authored
Dec 24, 2016
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11571 JSON_EXTRACT returns wrong results.
Array counter didn't increment after an item was found.
parent
bbb3fb31
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
mysql-test/r/func_json.result
mysql-test/r/func_json.result
+3
-0
mysql-test/t/func_json.test
mysql-test/t/func_json.test
+1
-0
strings/json_lib.c
strings/json_lib.c
+1
-4
No files found.
mysql-test/r/func_json.result
View file @
4d10273b
...
@@ -209,6 +209,9 @@ json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]')
...
@@ -209,6 +209,9 @@ json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]')
select json_extract('1', '$');
select json_extract('1', '$');
json_extract('1', '$')
json_extract('1', '$')
1
1
select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]');
json_extract('[10, 20, [30, 40], 1, 10]', '$[1]')
20
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]}', '$.b.k1', 'word');
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]}
{"a":1, "b":{"c":1, "k1":"word"}, "d":[1, 2]}
...
...
mysql-test/t/func_json.test
View file @
4d10273b
...
@@ -77,6 +77,7 @@ select json_extract(json_object('foo', 'foobar'),'$');
...
@@ -77,6 +77,7 @@ select json_extract(json_object('foo', 'foobar'),'$');
select
json_extract
(
'[10, 20, [30, 40]]'
,
'$[2][*]'
);
select
json_extract
(
'[10, 20, [30, 40]]'
,
'$[2][*]'
);
select
json_extract
(
'[10, 20, [{"a":3}, 30, 40]]'
,
'$[2][*]'
);
select
json_extract
(
'[10, 20, [{"a":3}, 30, 40]]'
,
'$[2][*]'
);
select
json_extract
(
'1'
,
'$'
);
select
json_extract
(
'1'
,
'$'
);
select
json_extract
(
'[10, 20, [30, 40], 1, 10]'
,
'$[1]'
);
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]}'
,
'$.b.k1'
,
'word'
);
select
json_insert
(
'{"a":1, "b":{"c":1}, "d":[1, 2]}'
,
'$.d[3]'
,
3
);
select
json_insert
(
'{"a":1, "b":{"c":1}, "d":[1, 2]}'
,
'$.d[3]'
,
3
);
...
...
strings/json_lib.c
View file @
4d10273b
...
@@ -1270,7 +1270,7 @@ int json_find_path(json_engine_t *je,
...
@@ -1270,7 +1270,7 @@ int json_find_path(json_engine_t *je,
case
JST_VALUE
:
case
JST_VALUE
:
DBUG_ASSERT
(
cur_step
->
type
&
JSON_PATH_ARRAY
);
DBUG_ASSERT
(
cur_step
->
type
&
JSON_PATH_ARRAY
);
if
(
cur_step
->
type
&
JSON_PATH_WILD
||
if
(
cur_step
->
type
&
JSON_PATH_WILD
||
cur_step
->
n_item
==
array_counters
[
cur_step
-
p
->
steps
])
cur_step
->
n_item
==
array_counters
[
cur_step
-
p
->
steps
]
++
)
{
{
/* Array item matches. */
/* Array item matches. */
if
(
cur_step
==
p
->
last_step
||
if
(
cur_step
==
p
->
last_step
||
...
@@ -1278,10 +1278,7 @@ int json_find_path(json_engine_t *je,
...
@@ -1278,10 +1278,7 @@ int json_find_path(json_engine_t *je,
goto
exit
;
goto
exit
;
}
}
else
else
{
json_skip_array_item
(
je
);
json_skip_array_item
(
je
);
array_counters
[
cur_step
-
p
->
steps
]
++
;
}
break
;
break
;
case
JST_OBJ_END
:
case
JST_OBJ_END
:
case
JST_ARRAY_END
:
case
JST_ARRAY_END
:
...
...
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