Hi Sergey!

I've been investigating MDEV-7122. I'm still quite a ways to go before I can understand all the underlying bits of logic. I need a little help regarding a change that you've committed a while back.

Do you know (remember) why you've placed DBUG_ASSERT(0) in the commit:
a1b4eadf89a3940b80a6ed0eadd15ba456c2fa7a
BUG#868908: Crash in check_simple_equality() with semijoin + materialization + prepared statement
    - Part2: safety and code cleanup

To me, it feels like it's some leftover debugging code, but it would be good to get your input on this.

@@ -4182,6 +4183,8 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
   */
   if (tmp_table->s->keys == 0)
   {
+    //fprintf(stderr, "Q: %s\n", current_thd->query());
+    DBUG_ASSERT(0);

Obviously we should also get rid of the commented fprintf statement.

After trying to debug this by just looking at the adjacent function calls and logic, I've come to the conclusion that I need to actually understand the code methodically. This is what I am actually doing right now, starting from the parser, all the way to how this particular query is executed. Expect more questions from me on this topic.

Thanks,
Vicentiu