Commit 6f56458a authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-25183 JSON_TABLE: CREATE VIEW involving NESTED PATH ends up with invalid frm.

Wrong comma was added after the single column.
parent 51ac57fb
...@@ -505,5 +505,16 @@ hex(a) b ...@@ -505,5 +505,16 @@ hex(a) b
626172 2 626172 2
SET @@character_set_connection= @old_character_set_connection; SET @@character_set_connection= @old_character_set_connection;
# #
# MDEV-25183 JSON_TABLE: CREATE VIEW involving NESTED PATH ends up with invalid frm
#
CREATE VIEW v AS SELECT * FROM JSON_TABLE('{}', '$' COLUMNS(NESTED PATH '$**.*' COLUMNS(a FOR ORDINALITY), b VARCHAR(8) PATH '$')) AS jt;
SHOW CREATE VIEW v;
View Create View character_set_client collation_connection
v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `jt`.`a` AS `a`,`jt`.`b` AS `b` from JSON_TABLE('{}', '$' COLUMNS (NESTED PATH '$**.*' COLUMNS (`a` FOR ORDINALITY), `b` varchar(8) PATH '$')) `jt` latin1 latin1_swedish_ci
SELECT * FROM v;
a b
NULL NULL
DROP VIEW v;
#
# End of 10.6 tests # End of 10.6 tests
# #
...@@ -387,6 +387,14 @@ SET @@character_set_connection= utf8; ...@@ -387,6 +387,14 @@ SET @@character_set_connection= utf8;
select hex(a), b from json_table('["foo","bar"]','$[*]' columns (a char(3) path '$', b for ordinality)) t; select hex(a), b from json_table('["foo","bar"]','$[*]' columns (a char(3) path '$', b for ordinality)) t;
SET @@character_set_connection= @old_character_set_connection; SET @@character_set_connection= @old_character_set_connection;
--echo #
--echo # MDEV-25183 JSON_TABLE: CREATE VIEW involving NESTED PATH ends up with invalid frm
--echo #
CREATE VIEW v AS SELECT * FROM JSON_TABLE('{}', '$' COLUMNS(NESTED PATH '$**.*' COLUMNS(a FOR ORDINALITY), b VARCHAR(8) PATH '$')) AS jt;
SHOW CREATE VIEW v;
SELECT * FROM v;
DROP VIEW v;
--echo # --echo #
--echo # End of 10.6 tests --echo # End of 10.6 tests
--echo # --echo #
...@@ -1220,7 +1220,8 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str, ...@@ -1220,7 +1220,8 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
if (str->append("COLUMNS (")) if (str->append("COLUMNS ("))
return 1; return 1;
do /* loop while jc belongs to the current or nested paths. */
while(jc && (jc->m_nest == c_path || jc->m_nest == c_nested))
{ {
if (first_column) if (first_column)
first_column= FALSE; first_column= FALSE;
...@@ -1231,23 +1232,21 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str, ...@@ -1231,23 +1232,21 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
{ {
if (jc->print(thd, *f, str)) if (jc->print(thd, *f, str))
return 1; return 1;
if (!(jc= it++)) if ((jc= it++))
goto exit_ok; ++(*f);
++(*f);
} }
else if (jc->m_nest == c_nested) else
{ {
DBUG_ASSERT(jc->m_nest == c_nested);
if (str->append("NESTED PATH ") || if (str->append("NESTED PATH ") ||
print_path(str, &jc->m_nest->m_path) || print_path(str, &jc->m_nest->m_path) ||
str->append(' ') ||
c_nested->print(thd, f, str, it, &jc)) c_nested->print(thd, f, str, it, &jc))
return 1; return 1;
c_nested= c_nested->m_next_nested; c_nested= c_nested->m_next_nested;
} }
else }
break;
} while(jc);
exit_ok:
if (str->append(")")) if (str->append(")"))
return 1; return 1;
......
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