Commit 9c7bd4f2 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2

Note they key_or() may call tree_delete(), which will cause the weight
asserts to be checked. In order to avoid them from firing, update key1
tree's weight after we've changed key1->some_local_child->next_key_part.

Having done that, do we still need this at the function end:

  /* Re-compute the result tree's weight. */
  key1->update_weight_locally();
?
parent 7e3806ce
......@@ -239,3 +239,12 @@ insert into t1 values (1,1,1,1), (2,2,2,2), (3,3,3,3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 2 NULL 3 Using where
drop table t1;
#
# MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2
#
SELECT *
FROM mysql.help_relation
WHERE
(help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND
help_keyword_id = help_topic_id;
help_topic_id help_keyword_id
......@@ -140,3 +140,13 @@ WHERE
--enable_query_log
drop table t1;
--echo #
--echo # MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2
--echo #
SELECT *
FROM mysql.help_relation
WHERE
(help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND
help_keyword_id = help_topic_id;
......@@ -10642,9 +10642,15 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
*/
tmp->maybe_flag|= key2_cpy.maybe_flag;
key2_cpy.increment_use_count(key1->use_count+1);
uint old_weight= tmp->next_key_part? tmp->next_key_part->weight: 0;
tmp->next_key_part= key_or(param, tmp->next_key_part,
key2_cpy.next_key_part);
uint new_weight= tmp->next_key_part? tmp->next_key_part->weight: 0;
key1->weight += (new_weight - old_weight);
if (!cmp)
break; // case b: done with this key2 range
......
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