summaryrefslogtreecommitdiff
path: root/sql/sql_update.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_update.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_update.cc')
-rw-r--r--sql/sql_update.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 84b22c56cf9..4a6249410a7 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -311,7 +311,7 @@ int mysql_update(THD *thd,
table->sort.io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
MYF(MY_FAE | MY_ZEROFILL));
- if (!(sortorder=make_unireg_sortorder(order, &length)) ||
+ if (!(sortorder=make_unireg_sortorder(order, &length, NULL)) ||
(table->sort.found_records = filesort(thd, table, sortorder, length,
select, limit,
&examined_rows))