Comment 2 for bug 1007622

Revision history for this message
Timour Katchaounov (timour) wrote :

The actual cause of the crash is that when handler::increment_statistics() is called from write_record() -> handler::ha_write_row(), the state of the ha_heap object is such that ha_heap::table == NULL.

When comparing the execution of MariaDB 5.3/5.5 (where the crash is observed) with MariaDB 5.2 or mysql-trunk (no crash), the main difference is as follows.

MariaDB 5.3/5.5 creates two temporary tables, named 'v1', and 'v2', one per each view. The call two write_record() gets as its table argument the object of the temporary table named 'v1'. Apparently the handler for this table and possibly the table object itself is not initialized properly.

MariaDB 5.2 and mysql-trunk do not create temporary tables at all.

The question is what is wrong - is MariaDB 5.3/5.5 supposed to create and use temporary tables at all or not? The function that decides on temp table creation is mysql_derived_prepare(). In MariaDB 5.2 there are two clear branches where one deals with temp tables, and the other with merged views. However the logic of mysql_derived_prepare() has changed in MariaDB 5.3/5.5, and at least to me it appears that a temp table is created always.

I will ask Igor for help on the above question since he modified heavily this code. Depending on the intended behavior, I will analyze the bug further.