summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2006-10-17 16:20:26 +0300
committerunknown <gkodinov/kgeorge@macbook.gmz>2006-10-17 16:20:26 +0300
commit841ea461ce2b6782ce280806039c32e7a5b7dcdd (patch)
treee9d042b9e6f984142988ab80b1e498e226ff394a /sql/sql_delete.cc
parent21be389b46ae539a4a917539027636644d7f4dec (diff)
downloadmariadb-git-841ea461ce2b6782ce280806039c32e7a5b7dcdd.tar.gz
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 ().
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index e420022b8a1..33b46080696 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -167,7 +167,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
MYF(MY_FAE | MY_ZEROFILL));
if (!(sortorder= make_unireg_sortorder((ORDER*) order->first,
- &length)) ||
+ &length, NULL)) ||
(table->sort.found_records = filesort(thd, table, sortorder, length,
select, HA_POS_ERROR,
&examined_rows))