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
0cd73186
Commit
0cd73186
authored
Sep 12, 2017
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-13104 Json functions.
An extra ',' added to the JSON_MERGE result making it invalid.
parent
467acc21
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
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
+5
-0
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+14
-3
No files found.
mysql-test/r/func_json.result
View file @
0cd73186
...
@@ -683,3 +683,6 @@ JSON_OBJECT("foo", "bar`bar")
...
@@ -683,3 +683,6 @@ JSON_OBJECT("foo", "bar`bar")
SELECT JSON_SET('{}', '$.age', 87);
SELECT JSON_SET('{}', '$.age', 87);
JSON_SET('{}', '$.age', 87)
JSON_SET('{}', '$.age', 87)
{"age": 87}
{"age": 87}
SELECT JSON_MERGE('[]', '{"c":"d"}');
JSON_MERGE('[]', '{"c":"d"}')
[{"c": "d"}]
mysql-test/t/func_json.test
View file @
0cd73186
...
@@ -333,3 +333,8 @@ SELECT JSON_OBJECT("foo", "bar`bar");
...
@@ -333,3 +333,8 @@ SELECT JSON_OBJECT("foo", "bar`bar");
#
#
SELECT
JSON_SET
(
'{}'
,
'$.age'
,
87
);
SELECT
JSON_SET
(
'{}'
,
'$.age'
,
87
);
#
# MDEV-13104 Json functions.
#
SELECT
JSON_MERGE
(
'[]'
,
'{"c":"d"}'
);
sql/item_jsonfunc.cc
View file @
0cd73186
...
@@ -1971,14 +1971,25 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
...
@@ -1971,14 +1971,25 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
else
else
{
{
const
uchar
*
end1
,
*
beg1
,
*
end2
,
*
beg2
;
const
uchar
*
end1
,
*
beg1
,
*
end2
,
*
beg2
;
int
empty_array
=
0
;
beg1
=
je1
->
value_begin
;
beg1
=
je1
->
value_begin
;
/* Merge as a single array. */
/* Merge as a single array. */
if
(
je1
->
value_type
==
JSON_VALUE_ARRAY
)
if
(
je1
->
value_type
==
JSON_VALUE_ARRAY
)
{
{
if
(
json_skip_level
(
je1
))
int
cur_level
=
je1
->
stack_p
;
empty_array
=
1
;
while
(
json_scan_next
(
je1
)
==
0
)
{
if
(
je1
->
stack_p
<
cur_level
)
break
;
empty_array
=
0
;
}
if
(
je1
->
s
.
error
)
return
1
;
return
1
;
end1
=
je1
->
s
.
c_str
-
je1
->
sav_c_len
;
end1
=
je1
->
s
.
c_str
-
je1
->
sav_c_len
;
}
}
else
else
...
@@ -1995,8 +2006,8 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
...
@@ -1995,8 +2006,8 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
end1
=
je1
->
value_end
;
end1
=
je1
->
value_end
;
}
}
if
(
str
->
append
((
const
char
*
)
beg1
,
end1
-
beg1
)
,
if
(
str
->
append
((
const
char
*
)
beg1
,
end1
-
beg1
)
||
str
->
append
(
", "
,
2
))
(
!
empty_array
&&
str
->
append
(
", "
,
2
)
))
return
3
;
return
3
;
if
(
json_value_scalar
(
je2
))
if
(
json_value_scalar
(
je2
))
...
...
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