Bug#21798: memory leak during query execution with subquery in column
list using a function When executing dependent subqueries they are re-inited and re-exec() for each row of the outer context. The cause for the bug is that during subquery reinitialization/re-execution, the optimizer reallocates JOIN::join_tab, JOIN::table in make_simple_join() and the local variable in 'sortorder' in create_sort_index(), which is allocated by make_unireg_sortorder(). Care must be taken not to allocate anything into the thread's memory pool while re-initializing query plan structures between subquery re-executions. All such items mush be cached and reused because the thread's memory pool is freed at the end of the whole query. Note that they must be cached and reused even for queries that are not otherwise cacheable because otherwise it will grow the thread's memory pool every time a cacheable query is re-executed. We provide additional members to the JOIN structure to store references to the items that need to be cached. mysql-test/r/subselect.result: Bug#21798: memory leak during query execution with subquery in column list using a function - test case mysql-test/t/subselect.test: Bug#21798: memory leak during query execution with subquery in column list using a function - test case sql/mysql_priv.h: Bug#21798: memory leak during query execution with subquery in column list using a function - cache the entities allocated in the threads memory pool by JOIN::exec (). sql/sql_delete.cc: Bug#21798: memory leak during query execution with subquery in column list using a function - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's memory pool by JOIN::exec (). sql/sql_select.cc: Bug#21798: memory leak during query execution with subquery in column list using a function - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's memory pool by JOIN::exec (). sql/sql_select.h: Bug#21798: memory leak during query execution with subquery in column list using a function - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's memory pool by JOIN::exec (). sql/sql_table.cc: Bug#21798: memory leak during query execution with subquery in column list using a function - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's memory pool by JOIN::exec (). sql/sql_update.cc: Bug#21798: memory leak during query execution with subquery in column list using a function - cache the SORT_ORDER, TABLE * and JOIN_TAB allocated in the thread's memory pool by JOIN::exec ().
Showing
Please register or sign in to comment