Commit 2de3480e authored by Igor Babaev's avatar Igor Babaev

Fixed LP bug #928352.

This bug led to wrong values of the use_count fields in some SEL_ARG
trees that triggered complains on the server side when executing the
test case for LP bug 800184 if a debug build of the server was used.
  
This was the result of the incomplete fix for bug 800184.
To complete it the following corrections had to be made:
- the copy constructor for SEL_TREE must call the new function incr_refs_all()
  instead of the function incr_refs(), because references to next key parts
  from any SEL_ARG tree belonging to the list of the first key part has to be
  adjusted.
- the method and_sel_tree of the class SEL_IMERGE must use the copy constructor
  of the SEL_TREE class to make a copy of its second argument before it ANDs it
  with any SEL_TREE tree from the processed SEL_IMERGE object.  
   

parent 1f42e742
...@@ -552,6 +552,14 @@ class SEL_ARG :public Sql_alloc ...@@ -552,6 +552,14 @@ class SEL_ARG :public Sql_alloc
increment_use_count(1); increment_use_count(1);
use_count++; use_count++;
} }
void incr_refs_all()
{
for (SEL_ARG *pos=first(); pos ; pos=pos->next)
{
pos->increment_use_count(1);
}
use_count++;
}
void free_tree() void free_tree()
{ {
for (SEL_ARG *pos=first(); pos ; pos=pos->next) for (SEL_ARG *pos=first(); pos ; pos=pos->next)
...@@ -1090,9 +1098,11 @@ int SEL_IMERGE::and_sel_tree(RANGE_OPT_PARAM *param, SEL_TREE *tree, ...@@ -1090,9 +1098,11 @@ int SEL_IMERGE::and_sel_tree(RANGE_OPT_PARAM *param, SEL_TREE *tree,
for (SEL_TREE** or_tree= trees; or_tree != trees_next; or_tree++) for (SEL_TREE** or_tree= trees; or_tree != trees_next; or_tree++)
{ {
SEL_TREE *res_or_tree= 0; SEL_TREE *res_or_tree= 0;
if (!(res_or_tree= new SEL_TREE())) SEL_TREE *and_tree= 0;
if (!(res_or_tree= new SEL_TREE()) ||
!(and_tree= new SEL_TREE(tree, TRUE, param)))
return (-1); return (-1);
if (!and_range_trees(param, *or_tree, tree, res_or_tree)) if (!and_range_trees(param, *or_tree, and_tree, res_or_tree))
{ {
if (new_imerge->or_sel_tree(param, res_or_tree)) if (new_imerge->or_sel_tree(param, res_or_tree))
return (-1); return (-1);
...@@ -1305,7 +1315,7 @@ SEL_TREE::SEL_TREE(SEL_TREE *arg, bool without_merges, ...@@ -1305,7 +1315,7 @@ SEL_TREE::SEL_TREE(SEL_TREE *arg, bool without_merges,
for (uint idx= 0; idx < param->keys; idx++) for (uint idx= 0; idx < param->keys; idx++)
{ {
if ((keys[idx]= arg->keys[idx])) if ((keys[idx]= arg->keys[idx]))
keys[idx]->incr_refs(); keys[idx]->incr_refs_all();
} }
if (without_merges) if (without_merges)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment