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
78dc7c3a
Commit
78dc7c3a
authored
Dec 05, 2016
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-11461 JSON_TYPE does not recognize integer/double types.
Integer/Double recognition added.
parent
54545005
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
2 deletions
+33
-2
include/json_lib.h
include/json_lib.h
+11
-0
mysql-test/r/func_json.result
mysql-test/r/func_json.result
+4
-1
mysql-test/t/func_json.test
mysql-test/t/func_json.test
+1
-0
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+1
-1
strings/json_lib.c
strings/json_lib.c
+16
-0
No files found.
include/json_lib.h
View file @
78dc7c3a
...
...
@@ -172,6 +172,14 @@ enum json_value_types
};
enum
json_num_flags
{
JSON_NUM_NEG
=
1
,
/* Number is negative. */
JSON_NUM_FRAC_PART
=
2
,
/* The fractional part is not empty. */
JSON_NUM_EXP
=
4
,
/* The number has the 'e' part. */
};
typedef
struct
st_json_engine_t
{
json_string_t
s
;
/* String to parse. */
...
...
@@ -185,6 +193,9 @@ typedef struct st_json_engine_t
enum
json_value_types
value_type
;
/* type of the value.*/
const
uchar
*
value
;
/* Points to the value. */
const
uchar
*
value_begin
;
/* Points to where the value starts in the JSON. */
uint
num_flags
;
/* the details of the JSON_VALUE_NUMBER, is it negative,
or if it has the fractional part.
See the enum json_num_flags. */
/*
In most cases the 'value' and 'value_begin' are equal.
...
...
mysql-test/r/func_json.result
View file @
78dc7c3a
...
...
@@ -215,7 +215,10 @@ json_type("true")
BOOLEAN
select json_type('123');
json_type('123')
NUMBER
INTEGER
select json_type('123.12');
json_type('123.12')
DOUBLE
select json_keys('{"a":{"c":1, "d":2}, "b":2}');
json_keys('{"a":{"c":1, "d":2}, "b":2}')
["a", "b"]
...
...
mysql-test/t/func_json.test
View file @
78dc7c3a
...
...
@@ -93,6 +93,7 @@ select json_type('{"k1":123, "k2":345}');
select
json_type
(
'[123, "k2", 345]'
);
select
json_type
(
"true"
);
select
json_type
(
'123'
);
select
json_type
(
'123.12'
);
select
json_keys
(
'{"a":{"c":1, "d":2}, "b":2}'
);
select
json_keys
(
'{"a":{"c":1, "d":2}, "b":2}'
,
"$.a"
);
...
...
sql/item_jsonfunc.cc
View file @
78dc7c3a
...
...
@@ -1310,7 +1310,7 @@ String *Item_func_json_type::val_str(String *str)
type
=
"STRING"
;
break
;
case
JSON_VALUE_NUMBER
:
type
=
"NUMB
ER"
;
type
=
(
je
.
num_flags
&
JSON_NUM_FRAC_PART
)
?
"DOUBLE"
:
"INTEG
ER"
;
break
;
case
JSON_VALUE_TRUE
:
case
JSON_VALUE_FALSE
:
...
...
strings/json_lib.c
View file @
78dc7c3a
...
...
@@ -477,13 +477,29 @@ static int json_num_states[NS_NUM_STATES][N_NUM_CLASSES]=
};
static
uint
json_num_state_flags
[
NS_NUM_STATES
]
=
{
/*OK*/
0
,
/*GO*/
0
,
/*GO1*/
JSON_NUM_NEG
,
/*ZERO*/
0
,
/*ZE1*/
0
,
/*INT*/
0
,
/*FRAC*/
JSON_NUM_FRAC_PART
,
/*EX*/
JSON_NUM_EXP
,
/*EX1*/
0
,
};
static
int
skip_num_constant
(
json_engine_t
*
j
)
{
int
state
=
json_num_states
[
NS_GO
][
json_num_chr_map
[
j
->
s
.
c_next
]];
int
c_len
;
j
->
num_flags
=
0
;
for
(;;)
{
j
->
num_flags
|=
json_num_state_flags
[
state
];
if
((
c_len
=
json_next_char
(
&
j
->
s
))
>
0
)
{
if
((
state
=
json_num_states
[
state
][
json_num_chr_map
[
j
->
s
.
c_next
]])
>
0
)
...
...
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