summaryrefslogtreecommitdiff
path: root/sql/sp_rcontext.cc
diff options
context:
space:
mode:
authorunknown <pem@mysql.comhem.se>2005-05-18 11:07:57 +0200
committerunknown <pem@mysql.comhem.se>2005-05-18 11:07:57 +0200
commit90a2edd78407b5b3a748345307f0db54309804b8 (patch)
tree67a170c90033b6c1830ba103207e9ee41cec47e8 /sql/sp_rcontext.cc
parentb9a4e7d88eabba5b7463da899d1a72a264a84093 (diff)
downloadmariadb-git-90a2edd78407b5b3a748345307f0db54309804b8.tar.gz
Fixed BUG#6048: Stored procedure causes operating system reboot.
Memory leak in locally evalutated expressions during SP execution fixed by reusing allocated item slots when possible. Note: No test case added, since the test is a stress test that tries to make the machine to run out of memory. sql/item.cc: Make it possible to reuse allocated item slots (for use in SP execution). sql/item.h: Make it possible to reuse allocated item slots (for use in SP execution). sql/sp_head.cc: Reuse allocated item slots for expression evalutation during SP execution. sql/sp_rcontext.cc: Updated sp_eval_func_item() call, and prevent item reuse in reused frames (for handlers).
Diffstat (limited to 'sql/sp_rcontext.cc')
-rw-r--r--sql/sp_rcontext.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 672491a97f2..fdffa7fb88d 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -43,8 +43,11 @@ sp_rcontext::sp_rcontext(uint fsize, uint hmax, uint cmax)
int
sp_rcontext::set_item_eval(uint idx, Item **item_addr, enum_field_types type)
{
- extern Item *sp_eval_func_item(THD *thd, Item **it, enum_field_types type);
- Item *it= sp_eval_func_item(current_thd, item_addr, type);
+ extern Item *sp_eval_func_item(THD *thd, Item **it, enum_field_types type,
+ MEM_ROOT *mem_root,
+ Item *reuse);
+ THD *thd= current_thd;
+ Item *it= sp_eval_func_item(thd, item_addr, type, thd->mem_root, NULL);
if (! it)
return -1;
@@ -111,7 +114,12 @@ void
sp_rcontext::save_variables(uint fp)
{
while (fp < m_count)
- m_saved.push_front(m_frame[fp++]);
+ {
+ Item *it= m_frame[fp];
+
+ m_frame[fp++]= NULL; // Prevent reuse
+ m_saved.push_front(it);
+ }
}
void