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
abb80d25
Commit
abb80d25
authored
Dec 05, 2016
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11472 JSON_ARRAY_INSERT returns incorrect results.
Item_func_json_array_insert::val_str fixed.
parent
df87dce0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
13 deletions
+17
-13
mysql-test/r/func_json.result
mysql-test/r/func_json.result
+11
-8
mysql-test/t/func_json.test
mysql-test/t/func_json.test
+5
-4
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+1
-1
No files found.
mysql-test/r/func_json.result
View file @
abb80d25
...
@@ -55,18 +55,21 @@ json_array_append('["a", "b"]', '$', FALSE)
...
@@ -55,18 +55,21 @@ json_array_append('["a", "b"]', '$', FALSE)
select json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2);
select json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2);
json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2)
json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2)
{"k1":1, "k2":["a", "b", 2]}
{"k1":1, "k2":["a", "b", 2]}
SELECT JSON_ARRAY_INSERT
('["a", {"b": [1, 2]}, [3, 4]]', '$[1]', 'x');
select json_array_insert
('["a", {"b": [1, 2]}, [3, 4]]', '$[1]', 'x');
JSON_ARRAY_INSERT
('["a", {"b": [1, 2]}, [3, 4]]', '$[1]', 'x')
json_array_insert
('["a", {"b": [1, 2]}, [3, 4]]', '$[1]', 'x')
["a", "x", {"b": [1, 2]}, [3, 4]]
["a", "x", {"b": [1, 2]}, [3, 4]]
SELECT JSON_ARRAY_INSERT
('["a", {"b": [1, 2]}, [3, 4]]', '$[2]', 'x');
select json_array_insert
('["a", {"b": [1, 2]}, [3, 4]]', '$[2]', 'x');
JSON_ARRAY_INSERT
('["a", {"b": [1, 2]}, [3, 4]]', '$[2]', 'x')
json_array_insert
('["a", {"b": [1, 2]}, [3, 4]]', '$[2]', 'x')
["a", {"b": [1, 2]}, "x", [3, 4]]
["a", {"b": [1, 2]}, "x", [3, 4]]
SELECT JSON_ARRAY_INSERT
('["a", {"b": [1, 2]}, [3, 4]]', '$[3]', 'x');
select json_array_insert
('["a", {"b": [1, 2]}, [3, 4]]', '$[3]', 'x');
JSON_ARRAY_INSERT
('["a", {"b": [1, 2]}, [3, 4]]', '$[3]', 'x')
json_array_insert
('["a", {"b": [1, 2]}, [3, 4]]', '$[3]', 'x')
["a", {"b": [1, 2]}, [3, 4], "x"]
["a", {"b": [1, 2]}, [3, 4], "x"]
SELECT JSON_ARRAY_INSERT
('["a", {"b": [1, 2]}, [3, 4]]', '$[4]', 'x');
select json_array_insert
('["a", {"b": [1, 2]}, [3, 4]]', '$[4]', 'x');
JSON_ARRAY_INSERT
('["a", {"b": [1, 2]}, [3, 4]]', '$[4]', 'x')
json_array_insert
('["a", {"b": [1, 2]}, [3, 4]]', '$[4]', 'x')
["a", {"b": [1, 2]}, [3, 4], "x"]
["a", {"b": [1, 2]}, [3, 4], "x"]
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[1].b[0]', 'x');
json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[1].b[0]', 'x')
["a", {"b": [ "x",1, 2]}, [3, 4]]
select json_contains('{"k1":123, "k2":345}', '123', '$.k1');
select json_contains('{"k1":123, "k2":345}', '123', '$.k1');
json_contains('{"k1":123, "k2":345}', '123', '$.k1')
json_contains('{"k1":123, "k2":345}', '123', '$.k1')
1
1
...
...
mysql-test/t/func_json.test
View file @
abb80d25
...
@@ -22,10 +22,11 @@ select json_array(1, "text", false, null);
...
@@ -22,10 +22,11 @@ select json_array(1, "text", false, null);
select
json_array_append
(
'["a", "b"]'
,
'$'
,
FALSE
);
select
json_array_append
(
'["a", "b"]'
,
'$'
,
FALSE
);
select
json_array_append
(
'{"k1":1, "k2":["a", "b"]}'
,
'$.k2'
,
2
);
select
json_array_append
(
'{"k1":1, "k2":["a", "b"]}'
,
'$.k2'
,
2
);
SELECT
JSON_ARRAY_INSERT
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[1]'
,
'x'
);
select
json_array_insert
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[1]'
,
'x'
);
SELECT
JSON_ARRAY_INSERT
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[2]'
,
'x'
);
select
json_array_insert
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[2]'
,
'x'
);
SELECT
JSON_ARRAY_INSERT
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[3]'
,
'x'
);
select
json_array_insert
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[3]'
,
'x'
);
SELECT
JSON_ARRAY_INSERT
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[4]'
,
'x'
);
select
json_array_insert
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[4]'
,
'x'
);
select
json_array_insert
(
'["a", {"b": [1, 2]}, [3, 4]]'
,
'$[1].b[0]'
,
'x'
);
select
json_contains
(
'{"k1":123, "k2":345}'
,
'123'
,
'$.k1'
);
select
json_contains
(
'{"k1":123, "k2":345}'
,
'123'
,
'$.k1'
);
select
json_contains
(
'"you"'
,
'"you"'
);
select
json_contains
(
'"you"'
,
'"you"'
);
...
...
sql/item_jsonfunc.cc
View file @
abb80d25
...
@@ -1051,7 +1051,7 @@ String *Item_func_json_array_insert::val_str(String *str)
...
@@ -1051,7 +1051,7 @@ String *Item_func_json_array_insert::val_str(String *str)
if
(
s_p
&&
if
(
s_p
&&
(
json_path_setup
(
&
c_path
->
p
,
s_p
->
charset
(),(
const
uchar
*
)
s_p
->
ptr
(),
(
json_path_setup
(
&
c_path
->
p
,
s_p
->
charset
(),(
const
uchar
*
)
s_p
->
ptr
(),
(
const
uchar
*
)
s_p
->
ptr
()
+
s_p
->
length
())
||
(
const
uchar
*
)
s_p
->
ptr
()
+
s_p
->
length
())
||
c_path
->
p
.
last_step
-
1
>
c_path
->
p
.
steps
||
c_path
->
p
.
last_step
-
1
<
c_path
->
p
.
steps
||
c_path
->
p
.
last_step
->
type
!=
JSON_PATH_ARRAY
))
c_path
->
p
.
last_step
->
type
!=
JSON_PATH_ARRAY
))
goto
error
;
goto
error
;
c_path
->
parsed
=
c_path
->
constant
;
c_path
->
parsed
=
c_path
->
constant
;
...
...
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