diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2021-03-25 11:18:28 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2021-04-21 10:21:44 +0400 |
commit | 0cea1ea7d345566d1ed53c83f550d220484bafc4 (patch) | |
tree | ccf1da7eb54e37aa6e537e6d9241b649420d0beb | |
parent | 22e0a317be63d98df6850c0a15e20c6a3d682b60 (diff) | |
download | mariadb-git-0cea1ea7d345566d1ed53c83f550d220484bafc4.tar.gz |
MDEV-25183 JSON_TABLE: CREATE VIEW involving NESTED PATH ends up with invalid frm.
calling members of NULL object crashes on some platforms.
-rw-r--r-- | sql/json_table.cc | 11 | ||||
-rw-r--r-- | sql/json_table.h | 3 |
2 files changed, 7 insertions, 7 deletions
diff --git a/sql/json_table.cc b/sql/json_table.cc index 8b424d6e485..27a6a130a54 100644 --- a/sql/json_table.cc +++ b/sql/json_table.cc @@ -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. */ 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= this; p; p= p->m_nested) + for (; p; p= p->m_nested) { if (jc->m_nest == p) return TRUE; @@ -1247,8 +1246,8 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str, return 1; /* loop while jc belongs to the current or nested paths. */ - while(jc && (jc->m_nest == c_path || - c_nested->column_in_this_or_nested(jc))) + while(jc && + (jc->m_nest == c_path || column_in_this_or_nested(c_nested, jc))) { if (first_column) first_column= FALSE; @@ -1264,7 +1263,7 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str, } 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 ") || print_path(str, &jc->m_nest->m_path) || str->append(' ') || diff --git a/sql/json_table.h b/sql/json_table.h index 4b375ea7867..e4816e72287 100644 --- a/sql/json_table.h +++ b/sql/json_table.h @@ -97,7 +97,8 @@ private: /* The child NESTED PATH we're currently scanning */ 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; }; |