diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result index 7a7f4c724ab..00f4ecf0c8d 100644 --- a/mysql-test/suite/json/r/json_table.result +++ b/mysql-test/suite/json/r/json_table.result @@ -559,5 +559,19 @@ DROP VIEW v; SELECT val, MATCH(val) AGAINST( 'MariaDB') FROM JSON_TABLE('{"db":"xx"}', '$' COLUMNS(val VARCHAR(32) PATH '$**.*')) AS jt; ERROR HY000: The storage engine JSON_TABLE function doesn't support FULLTEXT indexes # +# MDEV-25138 JSON_TABLE: A space between JSON_TABLE and opening bracket causes syntax error +# +select * from json_table ('{}', '$' COLUMNS(x FOR ORDINALITY)) a; +x +1 +create table json_table(id int); +insert into json_table values (1), (2), (3); +select * from json_table; +id +1 +2 +3 +drop table json_table; +# # End of 10.6 tests # diff --git a/mysql-test/suite/json/r/json_table_mysql.result b/mysql-test/suite/json/r/json_table_mysql.result index 9475ed930b2..b1db299c94e 100644 --- a/mysql-test/suite/json/r/json_table_mysql.result +++ b/mysql-test/suite/json/r/json_table_mysql.result @@ -846,11 +846,11 @@ SET jt1.a=1; ERROR HY000: The target table jt1 of the UPDATE is not updatable DELETE JSON_TABLE(t1.c1,'$[*]' COLUMNS (a INT PATH '$.a')) AS jt1 FROM t1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'JSON_TABLE(t1.c1,'$[*]' COLUMNS (a INT PATH '$.a')) AS jt1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(t1.c1,'$[*]' COLUMNS (a INT PATH '$.a')) AS jt1 FROM t1' at line 1 DELETE t1, JSON_TABLE(t1.c1,'$[*]' COLUMNS (a INT PATH '$.a')) AS jt1 USING t1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'JSON_TABLE(t1.c1,'$[*]' COLUMNS (a INT PATH '$.a')) AS jt1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(t1.c1,'$[*]' COLUMNS (a INT PATH '$.a')) AS jt1 USING t1' at line 1 DROP TABLE t1; # diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test index 3adb6385083..4b0293f6bea 100644 --- a/mysql-test/suite/json/t/json_table.test +++ b/mysql-test/suite/json/t/json_table.test @@ -437,6 +437,15 @@ DROP VIEW v; --error ER_TABLE_CANT_HANDLE_FT SELECT val, MATCH(val) AGAINST( 'MariaDB') FROM JSON_TABLE('{"db":"xx"}', '$' COLUMNS(val VARCHAR(32) PATH '$**.*')) AS jt; +--echo # +--echo # MDEV-25138 JSON_TABLE: A space between JSON_TABLE and opening bracket causes syntax error +--echo # +select * from json_table ('{}', '$' COLUMNS(x FOR ORDINALITY)) a; +create table json_table(id int); +insert into json_table values (1), (2), (3); +select * from json_table; +drop table json_table; + --echo # --echo # End of 10.6 tests --echo # diff --git a/sql/lex.h b/sql/lex.h index 440ac2de664..fb701f0afd4 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -329,6 +329,7 @@ static SYMBOL symbols[] = { { "INVOKER", SYM(INVOKER_SYM)}, { "JOIN", SYM(JOIN_SYM)}, { "JSON", SYM(JSON_SYM)}, + { "JSON_TABLE", SYM(JSON_TABLE_SYM)}, { "KEY", SYM(KEY_SYM)}, { "KEYS", SYM(KEYS)}, { "KEY_BLOCK_SIZE", SYM(KEY_BLOCK_SIZE)}, @@ -762,7 +763,6 @@ static SYMBOL sql_functions[] = { { "GROUP_CONCAT", SYM(GROUP_CONCAT_SYM)}, { "JSON_ARRAYAGG", SYM(JSON_ARRAYAGG_SYM)}, { "JSON_OBJECTAGG", SYM(JSON_OBJECTAGG_SYM)}, - { "JSON_TABLE", SYM(JSON_TABLE_SYM)}, { "LAG", SYM(LAG_SYM)}, { "LEAD", SYM(LEAD_SYM)}, { "MAX", SYM(MAX_SYM)}, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9c994b326df..01f9a8277ee 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -15914,6 +15914,7 @@ keyword_sp_var_and_label: | ISSUER_SYM | INSERT_METHOD | INVISIBLE_SYM + | JSON_TABLE_SYM | KEY_BLOCK_SIZE | LAST_VALUE | LAST_SYM