Loading mysql-test/r/subselect.result +27 −0 Original line number Diff line number Diff line Loading @@ -2888,6 +2888,33 @@ select 1 from dual where 1 < any (select 2 from dual); select 1 from dual where 1 < all (select 2 from dual where 1!=1); 1 1 create table t1 (s1 char); insert into t1 values (1),(2); select * from t1 where (s1 < any (select s1 from t1)); s1 1 select * from t1 where not (s1 < any (select s1 from t1)); s1 2 select * from t1 where (s1 < ALL (select s1+1 from t1)); s1 1 select * from t1 where not(s1 < ALL (select s1+1 from t1)); s1 2 select * from t1 where (s1+1 = ANY (select s1 from t1)); s1 1 select * from t1 where NOT(s1+1 = ANY (select s1 from t1)); s1 2 select * from t1 where (s1 = ALL (select s1/s1 from t1)); s1 1 select * from t1 where NOT(s1 = ALL (select s1/s1 from t1)); s1 2 drop table t1; create table t1 (df decimal(5,1)); insert into t1 values(1.1); insert into t1 values(2.2); Loading mysql-test/t/subselect.test +18 −0 Original line number Diff line number Diff line Loading @@ -1851,6 +1851,24 @@ select 1 from dual where 2 > any (select 1); select 1 from dual where 2 > all (select 1); select 1 from dual where 1 < any (select 2 from dual); select 1 from dual where 1 < all (select 2 from dual where 1!=1); # BUG#20975 Wrong query results for subqueries within NOT create table t1 (s1 char); insert into t1 values (1),(2); select * from t1 where (s1 < any (select s1 from t1)); select * from t1 where not (s1 < any (select s1 from t1)); select * from t1 where (s1 < ALL (select s1+1 from t1)); select * from t1 where not(s1 < ALL (select s1+1 from t1)); select * from t1 where (s1+1 = ANY (select s1 from t1)); select * from t1 where NOT(s1+1 = ANY (select s1 from t1)); select * from t1 where (s1 = ALL (select s1/s1 from t1)); select * from t1 where NOT(s1 = ALL (select s1/s1 from t1)); drop table t1; # End of 4.1 tests # End of 4.1 tests # Loading sql/item_cmpfunc.cc +22 −0 Original line number Diff line number Diff line Loading @@ -3656,6 +3656,28 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */ } Item *Item_func_nop_all::neg_transformer(THD *thd) { /* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */ Item_func_not_all *new_item= new Item_func_not_all(args[0]); Item_allany_subselect *allany= (Item_allany_subselect*)args[0]; allany->func= allany->func_creator(FALSE); allany->all= !allany->all; allany->upper_item= new_item; return new_item; } Item *Item_func_not_all::neg_transformer(THD *thd) { /* "NOT (e $cmp$ ALL (SELECT ...)) -> e $rev_cmp$" ANY (SELECT ...) */ Item_func_nop_all *new_item= new Item_func_nop_all(args[0]); Item_allany_subselect *allany= (Item_allany_subselect*)args[0]; allany->all= !allany->all; allany->func= allany->func_creator(TRUE); allany->upper_item= new_item; return new_item; } Item *Item_func_eq::negated_item() /* a = b -> a != b */ { return new Item_func_ne(args[0], args[1]); Loading sql/item_cmpfunc.h +2 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,7 @@ class Item_func_not_all :public Item_func_not void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; }; void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; }; bool empty_underlying_subquery(); Item *neg_transformer(THD *thd); }; Loading @@ -321,6 +322,7 @@ class Item_func_nop_all :public Item_func_not_all Item_func_nop_all(Item *a) :Item_func_not_all(a) {} longlong val_int(); const char *func_name() const { return "<nop>"; } Item *neg_transformer(THD *thd); }; Loading sql/item_subselect.cc +3 −3 Original line number Diff line number Diff line Loading @@ -572,14 +572,14 @@ Item_in_subselect::Item_in_subselect(Item * left_exp, } Item_allany_subselect::Item_allany_subselect(Item * left_exp, Comp_creator *fn, chooser_compare_func_creator fc, st_select_lex *select_lex, bool all_arg) :Item_in_subselect(), all(all_arg) :Item_in_subselect(), all(all_arg), func_creator(fc) { DBUG_ENTER("Item_in_subselect::Item_in_subselect"); left_expr= left_exp; func= fn; func= func_creator(all_arg); init(select_lex, new select_exists_subselect(this)); max_columns= 1; abort_on_null= 0; Loading Loading
mysql-test/r/subselect.result +27 −0 Original line number Diff line number Diff line Loading @@ -2888,6 +2888,33 @@ select 1 from dual where 1 < any (select 2 from dual); select 1 from dual where 1 < all (select 2 from dual where 1!=1); 1 1 create table t1 (s1 char); insert into t1 values (1),(2); select * from t1 where (s1 < any (select s1 from t1)); s1 1 select * from t1 where not (s1 < any (select s1 from t1)); s1 2 select * from t1 where (s1 < ALL (select s1+1 from t1)); s1 1 select * from t1 where not(s1 < ALL (select s1+1 from t1)); s1 2 select * from t1 where (s1+1 = ANY (select s1 from t1)); s1 1 select * from t1 where NOT(s1+1 = ANY (select s1 from t1)); s1 2 select * from t1 where (s1 = ALL (select s1/s1 from t1)); s1 1 select * from t1 where NOT(s1 = ALL (select s1/s1 from t1)); s1 2 drop table t1; create table t1 (df decimal(5,1)); insert into t1 values(1.1); insert into t1 values(2.2); Loading
mysql-test/t/subselect.test +18 −0 Original line number Diff line number Diff line Loading @@ -1851,6 +1851,24 @@ select 1 from dual where 2 > any (select 1); select 1 from dual where 2 > all (select 1); select 1 from dual where 1 < any (select 2 from dual); select 1 from dual where 1 < all (select 2 from dual where 1!=1); # BUG#20975 Wrong query results for subqueries within NOT create table t1 (s1 char); insert into t1 values (1),(2); select * from t1 where (s1 < any (select s1 from t1)); select * from t1 where not (s1 < any (select s1 from t1)); select * from t1 where (s1 < ALL (select s1+1 from t1)); select * from t1 where not(s1 < ALL (select s1+1 from t1)); select * from t1 where (s1+1 = ANY (select s1 from t1)); select * from t1 where NOT(s1+1 = ANY (select s1 from t1)); select * from t1 where (s1 = ALL (select s1/s1 from t1)); select * from t1 where NOT(s1 = ALL (select s1/s1 from t1)); drop table t1; # End of 4.1 tests # End of 4.1 tests # Loading
sql/item_cmpfunc.cc +22 −0 Original line number Diff line number Diff line Loading @@ -3656,6 +3656,28 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */ } Item *Item_func_nop_all::neg_transformer(THD *thd) { /* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */ Item_func_not_all *new_item= new Item_func_not_all(args[0]); Item_allany_subselect *allany= (Item_allany_subselect*)args[0]; allany->func= allany->func_creator(FALSE); allany->all= !allany->all; allany->upper_item= new_item; return new_item; } Item *Item_func_not_all::neg_transformer(THD *thd) { /* "NOT (e $cmp$ ALL (SELECT ...)) -> e $rev_cmp$" ANY (SELECT ...) */ Item_func_nop_all *new_item= new Item_func_nop_all(args[0]); Item_allany_subselect *allany= (Item_allany_subselect*)args[0]; allany->all= !allany->all; allany->func= allany->func_creator(TRUE); allany->upper_item= new_item; return new_item; } Item *Item_func_eq::negated_item() /* a = b -> a != b */ { return new Item_func_ne(args[0], args[1]); Loading
sql/item_cmpfunc.h +2 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,7 @@ class Item_func_not_all :public Item_func_not void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; }; void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; }; bool empty_underlying_subquery(); Item *neg_transformer(THD *thd); }; Loading @@ -321,6 +322,7 @@ class Item_func_nop_all :public Item_func_not_all Item_func_nop_all(Item *a) :Item_func_not_all(a) {} longlong val_int(); const char *func_name() const { return "<nop>"; } Item *neg_transformer(THD *thd); }; Loading
sql/item_subselect.cc +3 −3 Original line number Diff line number Diff line Loading @@ -572,14 +572,14 @@ Item_in_subselect::Item_in_subselect(Item * left_exp, } Item_allany_subselect::Item_allany_subselect(Item * left_exp, Comp_creator *fn, chooser_compare_func_creator fc, st_select_lex *select_lex, bool all_arg) :Item_in_subselect(), all(all_arg) :Item_in_subselect(), all(all_arg), func_creator(fc) { DBUG_ENTER("Item_in_subselect::Item_in_subselect"); left_expr= left_exp; func= fn; func= func_creator(all_arg); init(select_lex, new select_exists_subselect(this)); max_columns= 1; abort_on_null= 0; Loading