diff options
author | svoj@april.(none) <> | 2006-04-19 15:13:50 +0500 |
---|---|---|
committer | svoj@april.(none) <> | 2006-04-19 15:13:50 +0500 |
commit | 06ce215f103cf83aee63a9e24340e15ee8ca1ee8 (patch) | |
tree | 5bb95b29ccad280aca995617952fa4dd8c747dc3 /mysys/tree.c | |
parent | da6210ee61ed204d1b327081d5258f13eec5072d (diff) | |
download | mariadb-git-06ce215f103cf83aee63a9e24340e15ee8ca1ee8.tar.gz |
BUG#18160 - Memory-/HEAP Table endless growing indexes
Updating data in HEAP table with BTREE index results in wrong index_length
counter value, which keeps growing after each update.
When inserting new record into tree counter is incremented by:
sizeof(TREE_ELEMENT) + key_size + tree->size_of_element
But when deleting element from tree it doesn't decrement counter by key_size:
sizeof(TREE_ELEMENT) + tree->size_of_element
This fix makes accurate allocated memory counter for tree. That is
decrease counter by key_size when deleting tree element.
Diffstat (limited to 'mysys/tree.c')
-rw-r--r-- | mysys/tree.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/mysys/tree.c b/mysys/tree.c index 1780913961e..0c9c04919b0 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -271,7 +271,7 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size, return element; } -int tree_delete(TREE *tree, void *key, void *custom_arg) +int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg) { int cmp,remove_colour; TREE_ELEMENT *element,***parent, ***org_parent, *nod; @@ -326,8 +326,7 @@ int tree_delete(TREE *tree, void *key, void *custom_arg) rb_delete_fixup(tree,parent); if (tree->free) (*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg); - /* This doesn't include key_size, but better than nothing */ - tree->allocated-= sizeof(TREE_ELEMENT)+tree->size_of_element; + tree->allocated-= sizeof(TREE_ELEMENT) + tree->size_of_element + key_size; my_free((gptr) element,MYF(0)); tree->elements_in_tree--; return 0; |