Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2110 06/03/29 11:36:19 pem@stripped +2 -0
Fixed BUG#17260: Triggers: crash while updating million-row table
We must set a mem_root/arena for the function each time the trigger is
fired, and free it afterwards, otherwise the allocated memory accumulates
in the calling statement's mem_root.
To test this, we must attempt to make the machine run out of memory (with
a trigger on a miljon row table for instance) which is not practical to
have in the test suite, so a test case is not included in the patch.
(Also fixed minor memory hogging in st_lex:st_lex()).
sql/sql_trigger.cc
1.48 06/03/29 11:36:15 pem@stripped +14 -0
Set a temporary arena and mem_root for the function call in a trigger,
and free it after each call; otherwise memory accumulates in the calling
statement's mem_root.
sql/sql_lex.cc
1.181 06/03/29 11:36:15 pem@stripped +1 -1
Fixed memory hogging in st_lex::st_lex(): Allocate a smaller hash table than the
default.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: pem
# Host: pem.mysql.com
# Root: /extern/mysql/5.0/bug18300/mysql-5.0
--- 1.180/sql/sql_lex.cc 2006-03-10 01:44:01 +01:00
+++ 1.181/sql/sql_lex.cc 2006-03-29 11:36:15 +02:00
@@ -1628,7 +1628,7 @@
st_lex::st_lex()
:result(0), sql_command(SQLCOM_END), query_tables_own_last(0)
{
- hash_init(&sroutines, system_charset_info, 0, 0, 0, sp_sroutine_key, 0, 0);
+ hash_init(&sroutines, system_charset_info, 16, 0, 0, sp_sroutine_key, 0, 0);
sroutines_list.empty();
sroutines_list_own_last= sroutines_list.next;
sroutines_list_own_elements= 0;
--- 1.47/sql/sql_trigger.cc 2006-03-10 01:44:01 +01:00
+++ 1.48/sql/sql_trigger.cc 2006-03-29 11:36:15 +02:00
@@ -1454,6 +1454,10 @@
{
bool err_status= FALSE;
sp_head *sp_trigger= bodies[event][time_type];
+ /* Memory root/arena for the function call. */
+ MEM_ROOT execute_mem_root;
+ Query_arena execute_arena(&execute_mem_root, Query_arena::INITIALIZED_FOR_SP),
+ backup_arena;
if (sp_trigger)
{
@@ -1498,7 +1502,17 @@
#endif // NO_EMBEDDED_ACCESS_CHECKS
thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER);
+
+ /* Set execute arena for the function call. */
+ init_alloc_root(&execute_mem_root, MEM_ROOT_BLOCK_SIZE, 0);
+ thd->set_n_backup_active_arena(&execute_arena, &backup_arena);
+
err_status= sp_trigger->execute_function(thd, 0, 0, 0);
+
+ /* Free the memory used by the function. */
+ free_root(&execute_mem_root, MYF(0));
+ thd->restore_active_arena(&execute_arena, &backup_arena);
+
thd->restore_sub_statement_state(&statement_state);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
| Thread |
|---|
| • bk commit into 5.0 tree (pem:1.2110) BUG#17260 | pem | 29 Mar |