Fix of LP BUG#780386.

ALL subquery should return TRUE if subquery rowa set is empty independently
of left part.  The problem was that Item_func_(eq,ne,gt,ge,lt,le) do not
call execution of second argument if first is NULL no in this case subquery
will not be executed and when Item_func_not_all calls any_value() of the
subquery or aggregation function which report that there was rows. So for
NULL < ALL (SELECT...) result was FALSE instead of TRUE.

Fix is just swapping of arguments of Item_func_(eq,ne,gt,ge,lt,le) (with
changing the operation if it is needed) so that result will be the same
(for examole a < b is equal to b > a). This fix exploit the fact that
first argument will be executed in any case.

mysql-test/r/subselect.result:
  The test suite added.
mysql-test/r/subselect_no_mat.result:
  The test suite added.
mysql-test/r/subselect_no_opts.result:
  The test suite added.
mysql-test/r/subselect_no_semijoin.result:
  The test suite added.
mysql-test/r/subselect_scache.result:
  The test suite added.
mysql-test/t/subselect.test:
  The test suite added.
sql/item_cmpfunc.cc:
  Swap arguments creation methods added.
sql/item_cmpfunc.h:
  Swap arguments creation methods added.
sql/item_subselect.cc:
  Swap arguments of the comparison.
This commit is contained in:
unknown 2011-07-20 21:48:41 +03:00
commit 2b6a23447b
9 changed files with 214 additions and 62 deletions

View file

@ -266,36 +266,61 @@ Item_bool_func2* Eq_creator::create(Item *a, Item *b) const
return new Item_func_eq(a, b);
}
Item_bool_func2* Eq_creator::create_swap(Item *a, Item *b) const
{
return new Item_func_eq(b, a);
}
Item_bool_func2* Ne_creator::create(Item *a, Item *b) const
{
return new Item_func_ne(a, b);
}
Item_bool_func2* Ne_creator::create_swap(Item *a, Item *b) const
{
return new Item_func_ne(b, a);
}
Item_bool_func2* Gt_creator::create(Item *a, Item *b) const
{
return new Item_func_gt(a, b);
}
Item_bool_func2* Gt_creator::create_swap(Item *a, Item *b) const
{
return new Item_func_lt(b, a);
}
Item_bool_func2* Lt_creator::create(Item *a, Item *b) const
{
return new Item_func_lt(a, b);
}
Item_bool_func2* Lt_creator::create_swap(Item *a, Item *b) const
{
return new Item_func_gt(b, a);
}
Item_bool_func2* Ge_creator::create(Item *a, Item *b) const
{
return new Item_func_ge(a, b);
}
Item_bool_func2* Ge_creator::create_swap(Item *a, Item *b) const
{
return new Item_func_le(b, a);
}
Item_bool_func2* Le_creator::create(Item *a, Item *b) const
{
return new Item_func_le(a, b);
}
Item_bool_func2* Le_creator::create_swap(Item *a, Item *b) const
{
return new Item_func_ge(b, a);
}
/*
Test functions
Most of these returns 0LL if false and 1LL if true and