diff options
author | Igor Babaev <igor@askmonty.org> | 2017-11-05 11:59:19 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2017-11-05 11:59:19 -0800 |
commit | 2ba1616e5d0f7008d5f6bf2c6cbc439935f6138b (patch) | |
tree | f4d85187a8330b24869985b2c399c21f0a96a4ea /sql/sql_tvc.cc | |
parent | d957a6c1f68316cd837c606f1d4917e6ec3c9c52 (diff) | |
download | mariadb-git-2ba1616e5d0f7008d5f6bf2c6cbc439935f6138b.tar.gz |
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.
Diffstat (limited to 'sql/sql_tvc.cc')
-rw-r--r-- | sql/sql_tvc.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index 19ec6c6c46a..8c8e132746e 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -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); } + |