diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 02f044be479..1d636407ac0 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -2350,3 +2350,12 @@ JSON_OVERLAPS(@json1, @json2) # # End of 10.9 Test # +# +# MDEV-29381: JSON paths containing dashes are reported as syntax errors in procedures +# +SELECT JSON_EXTRACT('{ "my-key": 1 }', '$."my-key"'); +JSON_EXTRACT('{ "my-key": 1 }', '$."my-key"') +1 +SELECT JSON_EXTRACT('{ "my-key": 1 }', '$.my-key'); +JSON_EXTRACT('{ "my-key": 1 }', '$.my-key') +1 diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 8123ab4be8a..a1613d9ee4f 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1608,3 +1608,10 @@ SELECT JSON_OVERLAPS(@json1, @json2); --echo # --echo # End of 10.9 Test --echo # + +--echo # +--echo # MDEV-29381: JSON paths containing dashes are reported as syntax errors in procedures +--echo # + +SELECT JSON_EXTRACT('{ "my-key": 1 }', '$."my-key"'); +SELECT JSON_EXTRACT('{ "my-key": 1 }', '$.my-key'); diff --git a/strings/json_lib.c b/strings/json_lib.c index 380959cf204..4cb877baee1 100644 --- a/strings/json_lib.c +++ b/strings/json_lib.c @@ -1096,7 +1096,7 @@ static int json_path_transitions[N_PATH_STATES][N_PATH_CLASSES]= /* 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, JE_NOT_JSON_CHR, JE_BAD_CHR}, -/* KNM */ { PS_KOK, PS_KNM, PS_AST, PS_EAR, PS_KNM, PS_KNM, PS_EKY, JE_SYN, +/* KNM */ { PS_KOK, PS_KNM, PS_AST, PS_EAR, PS_KNM, PS_KNM, PS_EKY, PS_KNM, PS_KNM, PS_KNM, PS_KNM, PS_KNM, PS_KNM, PS_ESC, PS_KNM, PS_KNM, JE_NOT_JSON_CHR, JE_BAD_CHR}, /* KWD */ { PS_OK, JE_SYN, JE_SYN, PS_AR, JE_SYN, JE_SYN, PS_EKY, JE_SYN, @@ -1111,7 +1111,7 @@ static int json_path_transitions[N_PATH_STATES][N_PATH_CLASSES]= /* KEYX*/ { JE_EOS, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, JE_SYN, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_ESCX, PS_EKYX, PS_KNMX, JE_NOT_JSON_CHR, JE_BAD_CHR}, -/* KNMX */{ JE_EOS, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, JE_SYN, +/* KNMX */{ JE_EOS, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_KNMX, PS_ESCX, PS_EKYX, PS_KNMX, JE_NOT_JSON_CHR, JE_BAD_CHR}, /* LAST */{ JE_SYN, JE_SYN, JE_SYN, JE_SYN, JE_SYN, PS_PT, JE_SYN, PS_NEG,