Commit 0cea1ea7 authored by Alexey Botchkov's avatar Alexey Botchkov

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

calling members of NULL object crashes on some platforms.
parent 22e0a317
...@@ -1208,10 +1208,9 @@ void Table_function_json_table::get_estimates(ha_rows *out_rows, ...@@ -1208,10 +1208,9 @@ void Table_function_json_table::get_estimates(ha_rows *out_rows,
don't have to loop through the m_next_nested. don't have to loop through the m_next_nested.
*/ */
bool Json_table_nested_path::column_in_this_or_nested( bool Json_table_nested_path::column_in_this_or_nested(
const Json_table_column *jc) const const Json_table_nested_path *p, const Json_table_column *jc)
{ {
const Json_table_nested_path *p; for (; p; p= p->m_nested)
for (p= this; p; p= p->m_nested)
{ {
if (jc->m_nest == p) if (jc->m_nest == p)
return TRUE; return TRUE;
...@@ -1247,8 +1246,8 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str, ...@@ -1247,8 +1246,8 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
return 1; return 1;
/* loop while jc belongs to the current or nested paths. */ /* loop while jc belongs to the current or nested paths. */
while(jc && (jc->m_nest == c_path || while(jc &&
c_nested->column_in_this_or_nested(jc))) (jc->m_nest == c_path || column_in_this_or_nested(c_nested, jc)))
{ {
if (first_column) if (first_column)
first_column= FALSE; first_column= FALSE;
...@@ -1264,7 +1263,7 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str, ...@@ -1264,7 +1263,7 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
} }
else else
{ {
DBUG_ASSERT(c_nested->column_in_this_or_nested(jc)); DBUG_ASSERT(column_in_this_or_nested(c_nested, jc));
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(' ') || str->append(' ') ||
......
...@@ -97,7 +97,8 @@ class Json_table_nested_path : public Sql_alloc ...@@ -97,7 +97,8 @@ class Json_table_nested_path : public Sql_alloc
/* The child NESTED PATH we're currently scanning */ /* The child NESTED PATH we're currently scanning */
Json_table_nested_path *m_cur_nested; Json_table_nested_path *m_cur_nested;
bool column_in_this_or_nested(const Json_table_column *jc) const; static bool column_in_this_or_nested(const Json_table_nested_path *p,
const Json_table_column *jc);
friend class Table_function_json_table; friend class Table_function_json_table;
}; };
......
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