Skip to content

Commit 0cea1ea

Browse files
author
Alexey Botchkov
committed
MDEV-25183 JSON_TABLE: CREATE VIEW involving NESTED PATH ends up with invalid frm.
calling members of NULL object crashes on some platforms.
1 parent 22e0a31 commit 0cea1ea

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sql/json_table.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,10 +1208,9 @@ void Table_function_json_table::get_estimates(ha_rows *out_rows,
12081208
don't have to loop through the m_next_nested.
12091209
*/
12101210
bool Json_table_nested_path::column_in_this_or_nested(
1211-
const Json_table_column *jc) const
1211+
const Json_table_nested_path *p, const Json_table_column *jc)
12121212
{
1213-
const Json_table_nested_path *p;
1214-
for (p= this; p; p= p->m_nested)
1213+
for (; p; p= p->m_nested)
12151214
{
12161215
if (jc->m_nest == p)
12171216
return TRUE;
@@ -1247,8 +1246,8 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
12471246
return 1;
12481247

12491248
/* loop while jc belongs to the current or nested paths. */
1250-
while(jc && (jc->m_nest == c_path ||
1251-
c_nested->column_in_this_or_nested(jc)))
1249+
while(jc &&
1250+
(jc->m_nest == c_path || column_in_this_or_nested(c_nested, jc)))
12521251
{
12531252
if (first_column)
12541253
first_column= FALSE;
@@ -1264,7 +1263,7 @@ int Json_table_nested_path::print(THD *thd, Field ***f, String *str,
12641263
}
12651264
else
12661265
{
1267-
DBUG_ASSERT(c_nested->column_in_this_or_nested(jc));
1266+
DBUG_ASSERT(column_in_this_or_nested(c_nested, jc));
12681267
if (str->append("NESTED PATH ") ||
12691268
print_path(str, &jc->m_nest->m_path) ||
12701269
str->append(' ') ||

sql/json_table.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class Json_table_nested_path : public Sql_alloc
9797
/* The child NESTED PATH we're currently scanning */
9898
Json_table_nested_path *m_cur_nested;
9999

100-
bool column_in_this_or_nested(const Json_table_column *jc) const;
100+
static bool column_in_this_or_nested(const Json_table_nested_path *p,
101+
const Json_table_column *jc);
101102
friend class Table_function_json_table;
102103
};
103104

0 commit comments

Comments
 (0)