- When JOIN::cleanup(full==TRUE) is called, the select can be in two states:
= Right after the create_sort_index() call, when join->join_tab[0] is used to
read data produced by filesort().
= After create_sort_index(), and after JOIN::reinit() calls, when
join->join_tab[0] has been reset to read the original data.
- We didn't handle the second case correctly, which resulted in an attempt to free
the same SQL_SELECT two times. The fix is to make sure we don't double-free.
- Correct the way SHOW EXPLAIN code calculates 'need_order' parameter
for JOIN::print_explain().
The calculation is still an approximation (see MDEV entry for details) (even EXPLAIN itself
is wrong in certain cases), but now it's a better approximation than before.
- Fix the year in Monty Program Ab copyrights in the new files.
- Fix permissions handling so that SHOW EXPLAIN's handling is the
same as SHOW PROCESSLIST's.
- Make SHOW EXPLAIN code take into account that st_select_lex object without joins can be
a full-featured SELECTs which were already executed and cleaned up.
- The problem was that create_ref_for_key() would act differently, depending on
whether we're running EXPLAIN or the actual query.
- As the first step, fixed the EXPLAIN printout not to depend on actions in create_ref_for_key().
- Don't try to produce plans after JOIN::cleanup() has been called, because:
= JOIN::cleanup leaves data structures in partially-cleaned state
= Walking them is hazardous (see this bug), and has funny effects
(See previous commits, "Using join cache" may or may not be shown)
= Changing data structures to be persisted may cause unwanted side effects
- The consequence is that SHOW EXPLAIN will show "Query plan already deleted" when e.g.
reading data after filesort.
- It turns out, there is a case where the join is degenerate, but
join->table_count!= && join->tables_list!=NULL. Need to also check
if join->zero_result_cause!=NULL, too.
- There is a slight problem: The code sets
zero_result_cause= "no matching row in const table"
when NOT running EXPLAIN. The result is that SHOW EXPLAIN will show this line while
regular EXPLAIN will not.
Make SHOW EXPLAIN work for queries that do "Using temporary" and/or "Using filesort"
- Patch#1: Don't lose "Using temporary/filesort" in the SHOW EXPLAIN output.
- Implement new approach to testing (the DBUG_EXECUTE_IF variant)
- add an 'evalp' mysqltest command that is like 'eval' except that
it prints the original query.
- Fix select_describe() not to change join_tab[i]->type
- More tests
- Fix st_select_lex::set_explain_type() to allow producing exactly the
same EXPLAINs as it did before. SHOW EXPLAIN output may produce
select_type=SIMPLE instead or select_type=PRIMARY or vice versa (which
is ok because values of select_type weren't self-consistent in this
regard to begin with)