summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorunknown <petr@mysql.com>2005-08-25 16:06:49 +0400
committerunknown <petr@mysql.com>2005-08-25 16:06:49 +0400
commitda7a46ad9f14f04f6d845acb8c3359c96ee5e820 (patch)
treeff275f5c171aa788b3bd6c33a4b12fcb3ec951fe /sql/sp_head.cc
parent8ff1361d17195ac03beda833ee02cc64fd7989ec (diff)
parentd29df5645bf0cdac2ff08a7da305e62edcd79604 (diff)
downloadmariadb-git-da7a46ad9f14f04f6d845acb8c3359c96ee5e820.tar.gz
Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/cps/mysql/devel/mysql-5.0-sp11333 mysql-test/r/sp.result: Auto merged mysql-test/t/sp.test: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/sp_head.cc: manual merge
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index dfc91f5a3f4..e9de1f53bb5 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -245,10 +245,25 @@ sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type,
DBUG_PRINT("info",("STRING_RESULT: %*s",
s->length(), s->c_ptr_quick()));
CREATE_ON_CALLERS_ARENA(it= new(reuse, &rsize)
- Item_string(thd->strmake(s->ptr(),
- s->length()), s->length(),
- it->collation.collation),
+ Item_string(it->collation.collation),
use_callers_arena, &backup_current_arena);
+ /*
+ We have to use special constructor and allocate string
+ on system heap here. This is because usual Item_string
+ constructor would allocate memory in the callers arena.
+ This would lead to the memory leak in SP loops.
+ See Bug #11333 "Stored Procedure: Memory blow up on
+ repeated SELECT ... INTO query" for sample of such SP.
+ TODO: Usage of the system heap gives significant overhead,
+ however usual "reuse" mechanism does not work here, as
+ Item_string has no max size. That is, if we have a loop, which
+ has string variable with constantly increasing size, we would have
+ to allocate new pieces of memory again and again on each iteration.
+ In future we should probably reserve some area of memory for
+ not-very-large strings and reuse it. But for large strings
+ we would have to use system heap anyway.
+ */
+ ((Item_string*) it)->set_str_with_copy(s->ptr(), s->length());
break;
}
case ROW_RESULT: