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
842dce37
Commit
842dce37
authored
Nov 16, 2017
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-14402 JSON_VALUE doesn't escape quote.
Result unescaping added.
parent
0c4d11e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-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
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+6
-4
No files found.
mysql-test/r/func_json.result
View file @
842dce37
...
...
@@ -28,6 +28,9 @@ NULL
select json_value('{"key1": [1,2,3], "key1":123}', '$.key1');
json_value('{"key1": [1,2,3], "key1":123}', '$.key1')
123
select JSON_VALUE('{ "x": [0,1], "y": "[0,1]", "z": "Mon\\\"t\\\"y" }','$.z');
JSON_VALUE('{ "x": [0,1], "y": "[0,1]", "z": "Mon\\\"t\\\"y" }','$.z')
Mon"t"y
select json_query('{"key1":{"a":1, "b":[1,2]}}', '$.key2');
json_query('{"key1":{"a":1, "b":[1,2]}}', '$.key2')
NULL
...
...
mysql-test/t/func_json.test
View file @
842dce37
...
...
@@ -9,6 +9,7 @@ select json_value('{"key1":123}', '$.key2');
select
json_value
(
'{"key1":123}'
,
'$.key1'
);
select
json_value
(
'{"key1":[1,2,3]}'
,
'$.key1'
);
select
json_value
(
'{"key1": [1,2,3], "key1":123}'
,
'$.key1'
);
select
JSON_VALUE
(
'{ "x": [0,1], "y": "[0,1]", "z": "Mon\\\"t\\\"y" }'
,
'$.z'
);
select
json_query
(
'{"key1":{"a":1, "b":[1,2]}}'
,
'$.key2'
);
select
json_query
(
'{"key1":{"a":1, "b":[1,2]}}'
,
'$.key1'
);
...
...
sql/item_jsonfunc.cc
View file @
842dce37
...
...
@@ -69,6 +69,7 @@ static inline bool append_simple(String *s, const uchar *a, size_t a_len)
/*
Appends JSON string to the String object taking charsets in
consideration.
*/
static
int
st_append_json
(
String
*
s
,
CHARSET_INFO
*
json_cs
,
const
uchar
*
js
,
uint
js_len
)
{
...
...
@@ -82,9 +83,8 @@ static int st_append_json(String *s,
return
0
;
}
return
js
_len;
return
str
_len
;
}
*/
/*
...
...
@@ -475,6 +475,9 @@ String *Item_func_json_value::val_str(String *str)
json_scan_start
(
&
je
,
js
->
charset
(),(
const
uchar
*
)
js
->
ptr
(),
(
const
uchar
*
)
js
->
ptr
()
+
js
->
length
());
str
->
length
(
0
);
str
->
set_charset
(
&
my_charset_utf8mb4_bin
);
path
.
cur_step
=
path
.
p
.
steps
;
continue_search:
if
(
json_find_path
(
&
je
,
&
path
.
p
,
&
path
.
cur_step
,
array_counters
))
...
...
@@ -515,8 +518,7 @@ bool Item_func_json_value::check_and_get_value(json_engine_t *je, String *res,
return
true
;
}
res
->
set
((
const
char
*
)
je
->
value
,
je
->
value_len
,
je
->
s
.
cs
);
return
false
;
return
st_append_json
(
res
,
je
->
s
.
cs
,
je
->
value
,
je
->
value_len
);
}
...
...
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