Skip to content

Commit

Permalink
MDEV-12312 JSON_CONTAINS_PATH does not detect invalid path and returns
Browse files Browse the repository at this point in the history
TRUE.

        Let's make empty brackets to be the syntax error in the JSON
        paths.
  • Loading branch information
Alexey Botchkov committed Oct 6, 2017
1 parent a3ba8c3 commit 3557de6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions mysql-test/r/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -720,3 +720,8 @@ json_data
SELECT JSON_OBJECT("user","Jožko Mrkvičká") as json_data;
json_data
{"user": "Jožko Mrkvičká"}
select json_contains_path('{"foo":"bar"}', 'one', '$[]');
json_contains_path('{"foo":"bar"}', 'one', '$[]')
NULL
Warnings:
Warning 4042 Syntax error in JSON path in argument 3 to function 'json_contains_path' at position 3
8 changes: 8 additions & 0 deletions mysql-test/t/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,11 @@ select json_array(5,json_query('[1,2]','$'));

SELECT JSON_ARRAY('1. ě 2. š 3. č 4. ř 5. ž 6. ý 7. á 8. í 9. é 10. ů 11. ú') AS json_data;
SELECT JSON_OBJECT("user","Jožko Mrkvičká") as json_data;


#
# MDEV-12312 JSON_CONTAINS_PATH does not detect invalid path and returns TRUE.
#

select json_contains_path('{"foo":"bar"}', 'one', '$[]');

2 changes: 1 addition & 1 deletion strings/json_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ static int json_path_transitions[N_PATH_STATES][N_PATH_CLASSES]=
/* PT */ { PS_OK, JE_SYN, PS_AST, PS_AR, JE_SYN, PS_KEY, JE_SYN, JE_SYN,
JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN,
JE_NOT_JSON_CHR, JE_BAD_CHR},
/* AR */ { JE_EOS, JE_SYN, PS_AWD, JE_SYN, PS_PT, JE_SYN, PS_Z,
/* AR */ { JE_EOS, JE_SYN, PS_AWD, JE_SYN, JE_SYN, JE_SYN, PS_Z,
PS_INT, JE_SYN, JE_SYN, PS_SAR, JE_SYN, JE_SYN, JE_SYN,
JE_NOT_JSON_CHR, JE_BAD_CHR},
/* SAR */ { JE_EOS, JE_SYN, PS_AWD, JE_SYN, PS_PT, JE_SYN, PS_Z,
Expand Down

0 comments on commit 3557de6

Please sign in to comment.