[Commits] c72457f8c31: MDEV-22462: Item_in_subselect::create_single_in_to_exists_cond(JOIN *, Item **, Item **): Assertion `false' failed.
revision-id: c72457f8c317b905763d56aa3528a506531662bb (mariadb-10.2.31-610-gc72457f8c31) parent(s): f99abb45c586e618fbbf573e1990209ab7f26968 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-12-22 17:58:23 +0300 message: MDEV-22462: Item_in_subselect::create_single_in_to_exists_cond(JOIN *, Item **, Item **): Assertion `false' failed. Item_in_subselect::create_single_in_to_exists_cond() should handle the case where the subquery is a table-less select but it is not a result of a UNION. (Table-less subqueries like "(SELECT 1)" are "substituted" with their select list, but table-less subqueries with WHERE or HAVING clause, like "(SELECT 1 WHERE ...)" are not substituted. They are handled with regular execution path) --- mysql-test/r/subselect4.result | 9 +++++++++ mysql-test/t/subselect4.test | 12 ++++++++++++ sql/item_subselect.cc | 44 ++++++++++++++++++++---------------------- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index c0df4f626b1..556fc2c5853 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -2686,4 +2686,13 @@ SELECT * FROM t2; f bar DROP TABLE t1, t2; +# +# MDEV-22462: Item_in_subselect::create_single_in_to_exists_cond(JOIN *, Item **, Item **): Assertion `false' failed. +# +select 1 from dual where 1 in (select 5 from dual where 1); +1 +create table t1 (a int); +insert into t1 values (1),(2),(3); +update t1 set a = 2 where a in (select a from dual where a = a); +drop table t1; # End of 10.2 tests diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index 6eada9b27d9..72184f8427d 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -2201,4 +2201,16 @@ SELECT * FROM t2; DROP TABLE t1, t2; +--echo # +--echo # MDEV-22462: Item_in_subselect::create_single_in_to_exists_cond(JOIN *, Item **, Item **): Assertion `false' failed. +--echo # + +select 1 from dual where 1 in (select 5 from dual where 1); + +create table t1 (a int); +insert into t1 values (1),(2),(3); + +update t1 set a = 2 where a in (select a from dual where a = a); +drop table t1; + --echo # End of 10.2 tests diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 802bfca64b7..92ef3b07884 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -2166,7 +2166,8 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join, */ Item *item= (Item*) select_lex->item_list.head(); - if (select_lex->table_list.elements) + if (select_lex->table_list.elements || + !(select_lex->master_unit()->is_union())) { Item *having= item; Item *orig_item= item; @@ -2214,31 +2215,28 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join, } else { - if (select_lex->master_unit()->is_union()) + DBUG_ASSERT(select_lex->master_unit()->is_union()); + + Item *new_having= + func->create(thd, expr, + new (thd->mem_root) Item_ref_null_helper(thd, + &select_lex->context, + this, + &select_lex->ref_pointer_array[0], + (char *)"<no matter>", + (char *)"<result>")); + if (!abort_on_null && left_expr->maybe_null) { - Item *new_having= - func->create(thd, expr, - new (thd->mem_root) Item_ref_null_helper(thd, - &select_lex->context, - this, - &select_lex->ref_pointer_array[0], - (char *)"<no matter>", - (char *)"<result>")); - if (!abort_on_null && left_expr->maybe_null) - { - disable_cond_guard_for_const_null_left_expr(0); - if (!(new_having= new (thd->mem_root) Item_func_trig_cond(thd, new_having, - get_cond_guard(0)))) - DBUG_RETURN(true); - } - - new_having->name= (char*) in_having_cond; - if (fix_having(new_having, select_lex)) + disable_cond_guard_for_const_null_left_expr(0); + if (!(new_having= new (thd->mem_root) Item_func_trig_cond(thd, new_having, + get_cond_guard(0)))) DBUG_RETURN(true); - *having_item= new_having; } - else - DBUG_ASSERT(false); + + new_having->name= (char*) in_having_cond; + if (fix_having(new_having, select_lex)) + DBUG_RETURN(true); + *having_item= new_having; } }
participants (1)
-
psergey