diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index b88e5a66f96..cbcd3bfbe41 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -342,6 +342,10 @@ select some_id from t1 where some_id not in(-4,-1,3423534,2342342); some_id 1 2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 drop table t1; create table t1(f1 char(1)); insert into t1 values ('a'),('b'),('1'); diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 906747c2f78..9c924a930f3 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -231,6 +231,13 @@ insert into t1 values (1),(2); select some_id from t1 where some_id not in(2,-1); select some_id from t1 where some_id not in(-4,-1,-4); select some_id from t1 where some_id not in(-4,-1,3423534,2342342); + +# +# BUG#24261: crash when WHERE contains NOT IN ('') for unsigned column type +# + +select some_id from t1 where some_id not in('-1', '0'); + drop table t1; # diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 79b3e023a5f..001f1faf9b0 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -5012,7 +5012,8 @@ static SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Item_func *cond_func, for (uint idx= 0; idx < param->keys; idx++) { SEL_ARG *new_interval, *last_val; - if (((new_interval= tree2->keys[idx])) && + if (((new_interval= tree2->keys[idx])) && + (tree->keys[idx]) && ((last_val= tree->keys[idx]->last()))) { new_interval->min_value= last_val->max_value;