Skip to content

Commit 9c7bd4f

Browse files
committed
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(); ?
1 parent 7e3806c commit 9c7bd4f

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

mysql-test/main/range_notembedded.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,12 @@ insert into t1 values (1,1,1,1), (2,2,2,2), (3,3,3,3);
239239
id select_type table type possible_keys key key_len ref rows Extra
240240
1 SIMPLE t1 range PRIMARY PRIMARY 2 NULL 3 Using where
241241
drop table t1;
242+
#
243+
# MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2
244+
#
245+
SELECT *
246+
FROM mysql.help_relation
247+
WHERE
248+
(help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND
249+
help_keyword_id = help_topic_id;
250+
help_topic_id help_keyword_id

mysql-test/main/range_notembedded.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,13 @@ WHERE
140140
--enable_query_log
141141

142142
drop table t1;
143+
144+
--echo #
145+
--echo # MDEV-25069: Assertion `root->weight >= ...' failed in SEL_ARG::tree_delete #2
146+
--echo #
147+
148+
SELECT *
149+
FROM mysql.help_relation
150+
WHERE
151+
(help_topic_id < '2' OR help_topic_id != 8 OR help_topic_id < 1) AND
152+
help_keyword_id = help_topic_id;

sql/opt_range.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10642,9 +10642,15 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
1064210642
*/
1064310643
tmp->maybe_flag|= key2_cpy.maybe_flag;
1064410644
key2_cpy.increment_use_count(key1->use_count+1);
10645+
10646+
uint old_weight= tmp->next_key_part? tmp->next_key_part->weight: 0;
10647+
1064510648
tmp->next_key_part= key_or(param, tmp->next_key_part,
1064610649
key2_cpy.next_key_part);
1064710650

10651+
uint new_weight= tmp->next_key_part? tmp->next_key_part->weight: 0;
10652+
key1->weight += (new_weight - old_weight);
10653+
1064810654
if (!cmp)
1064910655
break; // case b: done with this key2 range
1065010656

0 commit comments

Comments
 (0)