From 14a80f092914c966e552128f1f5ae744dad86220 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 3 Feb 2025 14:58:58 +0200 Subject: [PATCH] MDEV-35318 Assertion `tl->jtbm_subselect' failed... - PART 2 After the fix in the previous commit, we should never end up in a situation where select_lex->first_cond_optimization=false (i.e, "it's done") but select_lex->leaf_tables_saved==false ("not done"). So, in setup_tables(), revert the the condition added in the fix for MDEV-25008. Add an assert instead. --- sql/sql_base.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4e9261a453b..6165575b300 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8241,7 +8241,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context, 0); SELECT_LEX *select_lex= select_insert ? thd->lex->first_select_lex() : thd->lex->current_select; - if (select_lex->first_cond_optimization || !select_lex->leaf_tables_saved) + if (select_lex->first_cond_optimization) { leaves.empty(); if (select_lex->prep_leaf_list_state != SELECT_LEX::SAVED) @@ -8305,6 +8305,7 @@ bool setup_tables(THD *thd, Name_resolution_context *context, } else { + DBUG_ASSERT(select_lex->leaf_tables_saved); List_iterator_fast ti(select_lex->leaf_tables_exec); select_lex->leaf_tables.empty(); while ((table_list= ti++))