[MDEV-27559] convert_subq_to_jtbm() contains unreachable code since optimization_delayed is always TRUE Created: 2022-01-20  Updated: 2023-10-19

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
Fix Version/s: 10.4, 10.11

Type: Bug Priority: Minor
Reporter: Yury Chaikou Assignee: Sergei Petrunia
Resolution: Unresolved Votes: 0
Labels: None


 Description   

sql/opt_subselect.cc:2032
Local variable optimization_delayed is set to TRUE in the beginning of the function, and never changed. So the code inside "if (optimization_delayed)" always returns, and we never execute the rest of the function.

static bool convert_subq_to_jtbm(JOIN *parent_join, 
                                 Item_in_subselect *subq_pred, 
                                 bool *remove_item)
{
  SELECT_LEX *parent_lex= parent_join->select_lex;
  List<TABLE_LIST> *emb_join_list= &parent_lex->top_join_list;
  TABLE_LIST *emb_tbl_nest= NULL; // will change when we learn to handle outer joins
  TABLE_LIST *tl;
  bool *optimization_delayed= TRUE;*
...
  if (optimization_delayed)
  {
    DBUG_ASSERT(parent_join->table_count < MAX_TABLES);
 
    jtbm->jtbm_table_no= parent_join->table_count;
 
    create_subquery_temptable_name(&tbl_alias,
                                   subq_pred->unit->first_select()->select_number);
    jtbm->alias.str=    tbl_alias.str;
    jtbm->alias.length= tbl_alias.length;
    parent_join->table_count++;
    *DBUG_RETURN(thd->is_fatal_error);*    <== Always return here
  }
...
[code that is never executed]
}



 Comments   
Comment by Daniel Black [ 2023-10-19 ]

psergei, this was the case when you added the code all the way back in 8e25dcfcd7bc. Was something forgotten here or can this just be simplified?

Generated at Thu Feb 08 09:53:50 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.