Commit c69d72c2 authored by Rucha Deodhar's avatar Rucha Deodhar

MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in json

path (when range is used)

Analysis: When 0 comes after space, then the json path parser changes the
state to JE_SYN instead of PS_Z (meaning parse zero). Hence the warning.
Fix: Make the state PS_Z instead of JE_SYN.
parent 95a9078e
......@@ -1751,6 +1751,53 @@ JSON_OVERLAPS('true','tr')
Warnings:
Warning 4037 Unexpected end of JSON text in argument 2 to function 'json_overlaps'
#
<<<<<<< HEAD
||||||| parent of 970dba92c3d... MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in json
<<<<<<< HEAD
<<<<<<< HEAD
||||||| constructed merge base
# End of 10.9 test
#
#
||||||| constructed merge base
# End of 10.9 test
#
#
=======
>>>>>>> MDEV-22224: Support JSON Path negative index
# Beginning of 10.9 Test
#
=======
# Beginning of 10.9 Test
#
>>>>>>> MDEV-28071: JSON_EXISTS returns always 1 if it is used range notation for
=======
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
||||||| constructed merge base
# End of 10.9 test
#
#
||||||| constructed merge base
# End of 10.9 test
#
#
=======
>>>>>>> MDEV-22224: Support JSON Path negative index
||||||| constructed merge base
=======
# End of 10.9 test
#
#
>>>>>>> MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in json
# Beginning of 10.9 Test
#
=======
# Beginning of 10.9 Test
#
>>>>>>> MDEV-28071: JSON_EXISTS returns always 1 if it is used range notation for
>>>>>>> 970dba92c3d... MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in json
# MDEV-22224: Support JSON Path negative index
#
SET @json='{
......@@ -2024,6 +2071,7 @@ SELECT JSON_VALUE(@json,'$.x[0]');
JSON_VALUE(@json,'$.x[0]')
0
#
<<<<<<< HEAD
# MDEV-27911: Implement range notation for json path
#
SET @json= '[
......@@ -3014,7 +3062,21 @@ SELECT JSON_VALUE(@json, '$.A[last-1][last-1].key1');
JSON_VALUE(@json, '$.A[last-1][last-1].key1')
123
#
<<<<<<< HEAD
# MDEV-28075: JSON_VALUE returns first value from array not from range
||||||| parent of 970dba92c3d... MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in json
# MDEV-22224: Support JSON Path negative index
#
# MDEV-27911: Implement range notation for json path
=======
# MDEV-22224: Support JSON Path negative index
#
# Beginning of 10.9 Test
#
# MDEV-22224: Support JSON Path negative index
#
# MDEV-27911: Implement range notation for json path
>>>>>>> 970dba92c3d... MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in json
#
SET @json1= '[
[{"key1": "value1"}, {"key2": "value2"}],
......@@ -3038,9 +3100,32 @@ SELECT JSON_VALUE(@json, '$[2 to 3][0]');
JSON_VALUE(@json, '$[2 to 3][0]')
7
#
<<<<<<< HEAD
# Beginning of 10.9 Test
#
# MDEV-22224: Support JSON Path negative index
||||||| parent of 970dba92c3d... MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in json
# MDEV-27911: Implement range notation for json path
=======
# MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in
# json path (when range is used)
#
SET @json= '[ 11, 22 , 33]';
SELECT JSON_EXTRACT(@json, '$[0 to 0]');
JSON_EXTRACT(@json, '$[0 to 0]')
[11]
SELECT JSON_EXTRACT(@json, '$[0 to -0]');
JSON_EXTRACT(@json, '$[0 to -0]')
[11]
SELECT JSON_EXTRACT(@json, '$[-0 to 0]');
JSON_EXTRACT(@json, '$[-0 to 0]')
[11]
SELECT JSON_EXTRACT(@json, '$[-0 to -0]');
JSON_EXTRACT(@json, '$[-0 to -0]')
[11]
#
# MDEV-22224: Support JSON Path negative index
>>>>>>> 970dba92c3d... MDEV-28072: JSON_EXTRACT has inconsistent behavior with '0' value in json
#
SET @json='{
"A": [0,
......@@ -3298,4 +3383,4 @@ JSON_VALUE(@json, '$.A[last-1][last-1].key1')
123
#
# End of 10.9 Test
#
\ No newline at end of file
#
This diff is collapsed.
......@@ -1091,7 +1091,7 @@ static int json_path_transitions[N_PATH_STATES][N_PATH_CLASSES]=
PS_INT, PS_INT, JE_SYN, JE_SYN, PS_AS, JE_SYN, JE_SYN, JE_SYN,
JE_NOT_JSON_CHR, JE_BAD_CHR},
/* AS */ { JE_EOS, JE_SYN, JE_SYN, JE_SYN, PS_T, PS_PT, JE_SYN, PS_NEG,
JE_SYN, PS_INT, PS_LAST, PS_AS, JE_SYN, JE_SYN, JE_SYN,
PS_Z, PS_INT, PS_LAST, PS_AS, JE_SYN, JE_SYN, JE_SYN,
JE_NOT_JSON_CHR, JE_BAD_CHR},
/* KEY */ { JE_EOS, PS_KNM, PS_KWD, JE_SYN, PS_KNM, PS_KNM, JE_SYN, JE_SYN,
PS_KNM, PS_KNM, PS_KNM, PS_KNM, PS_KNM, JE_SYN, PS_KEYX, PS_KNM,
......
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