diff options
author | Sergey Glukhov <sergey.glukhov@oracle.com> | 2012-08-09 15:34:52 +0400 |
---|---|---|
committer | Sergey Glukhov <sergey.glukhov@oracle.com> | 2012-08-09 15:34:52 +0400 |
commit | 2f30b34095e286877cda7156ae9622a4154147bd (patch) | |
tree | 45667344474d3cdd896bdb5596f052371ec18359 /sql/item.cc | |
parent | eede4140163d12b892ff140e6a4abc40df5ff87a (diff) | |
download | mariadb-git-2f30b34095e286877cda7156ae9622a4154147bd.tar.gz |
Bug #14409015 MEMORY LEAK WHEN REFERENCING OUTER FIELD IN HAVING
When resolving outer fields, Item_field::fix_outer_fields()
creates new Item_refs for each execution of a prepared statement, so
these must be allocated in the runtime memroot. The memroot switching
before resolving JOIN::having causes these to be allocated in the
statement root, leaking memory for each PS execution.
sql/item_subselect.cc:
addon, fix for 11829691, item could be created in
runtime memroot, so we need to use real_item instead.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc index 356fe4827c8..63215179ac6 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6010,7 +6010,12 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) if (from_field != not_found_field) { Item_field* fld; - if (!(fld= new Item_field(thd, last_checked_context, from_field))) + Query_arena backup, *arena; + arena= thd->activate_stmt_arena_if_needed(&backup); + fld= new Item_field(thd, last_checked_context, from_field); + if (arena) + thd->restore_active_arena(arena, &backup); + if (!fld) goto error; thd->change_item_tree(reference, fld); mark_as_dependent(thd, last_checked_context->select_lex, |