@@ -135,18 +135,16 @@ static
135
135
table_map get_disallowed_table_deps (JOIN *join, table_map table_func_bit)
136
136
{
137
137
table_map disallowed_tables= 0 ;
138
- if (get_disallowed_table_deps_for_list (table_func_bit, join->join_list ,
139
- &disallowed_tables))
140
- return disallowed_tables;
141
- else
138
+ if (!get_disallowed_table_deps_for_list (table_func_bit, join->join_list ,
139
+ &disallowed_tables))
142
140
{
141
+ // We haven't found the table with table_func_bit in all tables?
143
142
DBUG_ASSERT (0 );
144
- return disallowed_tables;
145
143
}
144
+ return disallowed_tables;
146
145
}
147
146
148
147
149
-
150
148
/*
151
149
A table that produces output rows for JSON_TABLE().
152
150
*/
@@ -1229,10 +1227,10 @@ void Table_function_json_table::end_nested_path()
1229
1227
1230
1228
bool push_table_function_arg_context (LEX *lex, MEM_ROOT *alloc)
1231
1229
{
1232
- // Walk the context stack until we find a context that is select-level
1233
- // context .
1230
+ // Walk the context stack until we find a context that is used for resolving
1231
+ // the SELECT's WHERE clause .
1234
1232
List_iterator<Name_resolution_context> it (lex->context_stack );
1235
- Name_resolution_context *ctx= NULL ;
1233
+ Name_resolution_context *ctx;
1236
1234
while ((ctx= it++))
1237
1235
{
1238
1236
if (ctx->select_lex && ctx == &ctx->select_lex ->context )
@@ -1242,6 +1240,10 @@ bool push_table_function_arg_context(LEX *lex, MEM_ROOT *alloc)
1242
1240
1243
1241
// Then, create a copy of it and return it.
1244
1242
Name_resolution_context *new_ctx= new (alloc) Name_resolution_context;
1243
+
1244
+ // Note: not all fields of *ctx are initialized yet at this point.
1245
+ // We will get all of the fields filled in Table_function_json_table::setup
1246
+ // (search for the "Prepare the name resolution context" comment).
1245
1247
*new_ctx= *ctx;
1246
1248
return lex->push_context (new_ctx);
1247
1249
}
@@ -1274,8 +1276,8 @@ int Table_function_json_table::setup(THD *thd, TABLE_LIST *sql_table,
1274
1276
save_is_item_list_lookup= thd->lex ->current_select ->is_item_list_lookup ;
1275
1277
thd->lex ->current_select ->is_item_list_lookup = 0 ;
1276
1278
1277
- // Prepare the name resolution context. First, copy the context that
1278
- // is using for name resolution of the WHERE clause
1279
+ // Prepare the name resolution context. First, copy the context that is
1280
+ // used for name resolution of the WHERE clause
1279
1281
*m_context= thd->lex ->current_select ->context ;
1280
1282
1281
1283
// Then, restrict it to only allow to refer to tables that come before the
0 commit comments