- don't call JOIN::join_free(1) twice for every join in JOIN::cleanup().
The reason it happened was that both, JOIN::cleanup() and JOIN::join_free(), went over all nested joins and called cleanup/join_free for them. For that: - split recursive and non-recursive parts of JOIN::cleanup() and JOIN::join_free() - rename JOIN::cleanup to JOIN::destroy, as it actually destroys its argument - move the recursive part of JOIN::cleanup to st_select_lex::cleanup - move the non-recursive part of JOIN::join_free to the introduced method JOIN::cleanup(). sql/sql_lex.h: Add st_select_lex::cleanup, a counterpart of st_select_lex_unit::cleanup() sql/sql_select.cc: - remove two unused arguments from return_zero_rows - split JOIN::join_free and JOIN::cleanup to recursive and non-recursive parts. - note, the assert in JOIN::join_free _does_ fail in having.test. We have two options: a) propagate `full' flag to the nested joins. We did it before, and this patch didn't change it. If so, we can end up cleaning up an uncacheable JOIN (that is, the join that we might need again). b) evaluate own 'full' flag on every level. In this case, we might end up with tables freed in mysql_unlock_read_tables, but not cleaned up properly, and this may be even worse. The test suite passes with both approaches, but not with the assert. sql/sql_select.h: - declarations for JOIN::cleanup() and JOIN::join_free() sql/sql_union.cc: Add st_select_lex::cleanup, a counterpart of st_select_lex_unit::cleanup(): move the recursive part of JOIN::cleanup to it.
Showing
Please register or sign in to comment