Commit abe97121 authored by Rucha Deodhar's avatar Rucha Deodhar

MDEV-27972: Unexpected behavior with negative zero (-0) in

JSON Path

Analysis: When we have '-' followed by 0, then the state is
changed to JE_SYN, meaning syntax error.
Fix: Change the state to PS_INT instead, because we are
reading '0' next (integer) and it is not a syntax error.
parent dfcbb30a
......@@ -2013,5 +2013,21 @@ SELECT JSON_VALUE(@json, '$.A[last-1][last-1].key1');
JSON_VALUE(@json, '$.A[last-1][last-1].key1')
123
#
# MDEV-27972: Unexpected behavior with negative zero (-0) in JSON Path
#
SET @json='{ "x": [0,1]}';
SELECT JSON_VALUE(@json,'$.x[last]');
JSON_VALUE(@json,'$.x[last]')
1
SELECT JSON_VALUE(@json,'$.x[last-0]');
JSON_VALUE(@json,'$.x[last-0]')
1
SELECT JSON_VALUE(@json,'$.x[-0]');
JSON_VALUE(@json,'$.x[-0]')
0
SELECT JSON_VALUE(@json,'$.x[0]');
JSON_VALUE(@json,'$.x[0]')
0
#
# End of 10.9 Test
#
......@@ -1306,6 +1306,16 @@ SET @json='{
SELECT JSON_VALUE(@json, '$.A[-2][-2].key1');
SELECT JSON_VALUE(@json, '$.A[last-1][last-1].key1');
--echo #
--echo # MDEV-27972: Unexpected behavior with negative zero (-0) in JSON Path
--echo #
SET @json='{ "x": [0,1]}';
SELECT JSON_VALUE(@json,'$.x[last]');
SELECT JSON_VALUE(@json,'$.x[last-0]');
SELECT JSON_VALUE(@json,'$.x[-0]');
SELECT JSON_VALUE(@json,'$.x[0]');
--echo #
--echo # End of 10.9 Test
--echo #
......@@ -1079,7 +1079,7 @@ static int json_path_transitions[N_PATH_STATES][N_PATH_CLASSES]=
/* AWD */ { JE_EOS, JE_SYN, JE_SYN, JE_SYN, PS_PT, JE_SYN,JE_SYN, JE_SYN,
JE_SYN, JE_SYN, JE_SYN, PS_AS, JE_SYN, JE_SYN, JE_SYN,
JE_NOT_JSON_CHR, JE_BAD_CHR},
/* NEG */ { JE_EOS, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN,JE_SYN,
/* NEG */ { JE_EOS, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, PS_INT,
PS_INT, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN,
JE_NOT_JSON_CHR, JE_BAD_CHR},
/* Z */ { JE_EOS, JE_SYN, JE_SYN, JE_SYN, PS_PT, JE_SYN,JE_SYN, JE_SYN,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment