diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2021-05-21 17:46:48 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2021-05-21 17:46:48 +0300 |
commit | 2087d47aaeadc06dd007ce9bd28984ecc8e2101e (patch) | |
tree | a1396bf44f1883f3995b2b4db22d7b7493153302 /sql/item_subselect.cc | |
parent | 8c8a6ed3b8e2bf6d9c0c155ba9a987c0ff27ac6c (diff) | |
download | mariadb-git-2087d47aaeadc06dd007ce9bd28984ecc8e2101e.tar.gz |
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)
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index ed8e5e900a2..1e3c9a77a26 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -2249,7 +2249,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; @@ -2297,31 +2298,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; } } |