Commit 0225159a authored by Alexander Freiherr von Buddenbrock's avatar Alexander Freiherr von Buddenbrock Committed by Rucha Deodhar

MDEV-29381: SON paths containing dashes are reported as syntax errors in

procedures

MDEV-22224 caused the parsing of keys with hyphens to break by setting
the state transitions for parsing keys to JE_SYN (syntax error) when
they encounter a hyphen. However json key names may contain hyphens and
still be considered valid json.

This patch changes the state transition table so that key names with
hyphens remain valid. Note that unquoted key names in paths like
$.key-name are also valid again. This restores the previous behaviour
when hyphens were considered part of the P_ETC character class.
parent 5bb2cc8d
......@@ -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
......@@ -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');
......@@ -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,
......
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