diff options
author | unknown <sanja@askmonty.org> | 2011-09-05 09:29:49 +0300 |
---|---|---|
committer | unknown <sanja@askmonty.org> | 2011-09-05 09:29:49 +0300 |
commit | 8b062c1fefd14cfa22e625d098b92c8ac3c1b28f (patch) | |
tree | 006bf37105248a919358cfe57a4c5ed2979bae78 /sql/item_subselect.cc | |
parent | 4338091967df9fcb4a2576e2f21302a75d4feb36 (diff) | |
download | mariadb-git-8b062c1fefd14cfa22e625d098b92c8ac3c1b28f.tar.gz |
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.
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 415d81a5b58..6f0a38c1625 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1076,8 +1076,11 @@ Item_in_subselect::single_value_transformer(JOIN *join, if (upper_item) upper_item->set_sub_test(item); } - /* fix fields is already called for left expression */ - substitution= func->create(left_expr, subs); + /* + The swap is needed for expressions of type 'f1 < ALL ( SELECT ....)' + where we want to evaluate the sub query even if f1 would be null. + */ + substitution= func->create_swap(left_expr, subs); DBUG_RETURN(RES_OK); } |