#At file:///home/alik/MySQL/bzr/00/bug60025/mysql-5.5-bug60025/ based on revid:alexander.nozdrin@stripped
3497 Alexander Nozdrin 2011-05-06
Patch for Bug#11848763 / 60025
(SUBSTRING inside a stored function works too slow).
The user-visible problem was that the server started to consume memory if a
stored-routine of some sort is executed subsequently. The memory was freed
only after the corresponding connection was closed.
Technically, the problem was that the memory needed for temporary string
conversions was allocated on the connection ("persistent") memory root,
instead of statement one.
The root cause of this problem was the incorrect patch for Bug 55744.
That patch wrongly fixed a crash in prepared-statement-mode introduced by
another patch. The patch for Bug 55744 used wrong condition to check if
prepared statement mode is active (or whether the connection-scoped or
statement-scoped memory root should be used). The thing is that for
prepared statements such conversions should be done in the connection
memory root, so that that the transformations of item-tree were correctly
remembered in the PREPARE-phase.
The fix is to use proper condition to detect prepared-statement-mode and
use proper memory root.
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2011-05-06 11:39:40 +0000
+++ b/sql/item.cc 2011-05-06 11:41:24 +0000
@@ -1781,14 +1781,17 @@ bool agg_item_set_converter(DTCollation
THD *thd= current_thd;
- Query_arena *arena, backup;
bool res= FALSE;
In case we're in statement prepare, create conversion item
in its memory: it will be reused on each execute.
- arena= thd->activate_stmt_arena_if_needed(&backup);
+ Query_arena backup;
+ Query_arena *arena= thd->stmt_arena->is_stmt_prepare() ?
+ thd->activate_stmt_arena_if_needed(&backup) :
for (i= 0, arg= args; i < nargs; i++, arg+= item_sep)
Attachment: [text/bzr-bundle] firstname.lastname@example.org
|• bzr commit into mysql-5.5 branch (alexander.nozdrin:3497) Bug#11848763||Alexander Nozdrin||6 May|