mirror of
https://github.com/MariaDB/server.git
synced 2026-04-28 03:05:33 +02:00
Fixed mdev-14281 Wrong result from query with NOT IN predicate in WHERE
Conversion of NOT IN predicates into NOT IN subqueries did not work correctly: the predicates actually were converted into IN subqueries. As a result if the conversion was applied for the query with a NOT IN predicate the query could return a wrong result set.
This commit is contained in:
parent
d957a6c1f6
commit
2ba1616e5d
4 changed files with 106 additions and 6 deletions
|
|
@ -728,20 +728,25 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd,
|
|||
/* Create IN subquery predicate */
|
||||
sq_select->parsing_place= parent_select->parsing_place;
|
||||
Item_in_subselect *in_subs;
|
||||
Item *sq;
|
||||
if (!(in_subs=
|
||||
new (thd->mem_root) Item_in_subselect(thd, args[0], sq_select)))
|
||||
goto err;
|
||||
in_subs->emb_on_expr_nest= emb_on_expr_nest;
|
||||
|
||||
sq= in_subs;
|
||||
if (negated)
|
||||
sq= negate_expression(thd, in_subs);
|
||||
else
|
||||
in_subs->emb_on_expr_nest= emb_on_expr_nest;
|
||||
|
||||
if (arena)
|
||||
thd->restore_active_arena(arena, &backup);
|
||||
thd->lex->current_select= parent_select;
|
||||
|
||||
if (in_subs->fix_fields(thd, (Item **)&in_subs))
|
||||
if (sq->fix_fields(thd, (Item **)&sq))
|
||||
goto err;
|
||||
|
||||
parent_select->curr_tvc_name++;
|
||||
return in_subs;
|
||||
return sq;
|
||||
|
||||
err:
|
||||
if (arena)
|
||||
|
|
@ -847,3 +852,4 @@ bool JOIN::transform_in_predicates_into_in_subq(THD *thd)
|
|||
thd->lex->current_select= save_current_select;
|
||||
DBUG_RETURN(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue