this case uses Semi Join Materializaion and the subquery is added to the table list of select #1.
The total number of tables for select #1 is 1(one_k)+ 5(inner_tables) + 1(SJM_TABLE). But for the top level we are only considered about 2 and should only have two JOIN_TAB structures.
In the function JOIN::get_best_combination
we allocate space for JOIN_TAB array like
In the debugger
(gdb) p top_join_tab_count
$8 = 6
So in this issue we would like to correct the value of top_join_tab_count, to only consider the tables that would be present at the top level. In this case
the value of top_join_tab_count should be 2.