summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-06-18 02:31:11 +0300
committerunknown <monty@mysql.com>2004-06-18 02:31:11 +0300
commit209cfe77583cf6f9b4d89e36dbe3defe9447503d (patch)
treed8058bbd66a30927ba6d0de27a446358abf68a3f /sql/opt_range.cc
parenteefb240b6da0db2023ad3c86f5be8ed338911a04 (diff)
downloadmariadb-git-209cfe77583cf6f9b4d89e36dbe3defe9447503d.tar.gz
Fixed unlikely bug in the range optimzer when using many IN() queries on different key parts. (Bug #4157)
mysql-test/r/range.result: Test of range optimizer bug mysql-test/t/range.test: Test of range optimizer bug sql/opt_range.cc: Fixed unlikely bug in the range optimzer when using many IN() queries on different key parts. (Bug #4157)
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc30
1 files changed, 21 insertions, 9 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index dfed08479f9..1bbf967b2bc 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1539,7 +1539,7 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
{
swap(SEL_ARG *,key1,key2);
}
- else if (!(key1=key1->clone_tree()))
+ if (key1->use_count > 0 || !(key1=key1->clone_tree()))
return 0; // OOM
}
@@ -1608,10 +1608,10 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
SEL_ARG *next=key2->next; // Keys are not overlapping
if (key2_shared)
{
- SEL_ARG *tmp= new SEL_ARG(*key2); // Must make copy
- if (!tmp)
+ SEL_ARG *cpy= new SEL_ARG(*key2); // Must make copy
+ if (!cpy)
return 0; // OOM
- key1=key1->insert(tmp);
+ key1=key1->insert(cpy);
key2->increment_use_count(key1->use_count+1);
}
else
@@ -1847,8 +1847,17 @@ SEL_ARG::find_range(SEL_ARG *key)
/*
-** Remove a element from the tree
-** This also frees all sub trees that is used by the element
+ Remove a element from the tree
+
+ SYNOPSIS
+ tree_delete()
+ key Key that is to be deleted from tree (this)
+
+ NOTE
+ This also frees all sub trees that is used by the element
+
+ RETURN
+ root of new tree (with key deleted)
*/
SEL_ARG *
@@ -1856,7 +1865,10 @@ SEL_ARG::tree_delete(SEL_ARG *key)
{
enum leaf_color remove_color;
SEL_ARG *root,*nod,**par,*fix_par;
- root=this; this->parent= 0;
+ DBUG_ENTER("tree_delete");
+
+ root=this;
+ this->parent= 0;
/* Unlink from list */
if (key->prev)
@@ -1903,7 +1915,7 @@ SEL_ARG::tree_delete(SEL_ARG *key)
}
if (root == &null_element)
- return 0; // Maybe root later
+ DBUG_RETURN(0); // Maybe root later
if (remove_color == BLACK)
root=rb_delete_fixup(root,nod,fix_par);
test_rb_tree(root,root->parent);
@@ -1911,7 +1923,7 @@ SEL_ARG::tree_delete(SEL_ARG *key)
root->use_count=this->use_count; // Fix root counters
root->elements=this->elements-1;
root->maybe_flag=this->maybe_flag;
- return root;
+ DBUG_RETURN(root);
}