diff options
author | bell@sanja.is.com.ua <> | 2004-11-18 18:10:07 +0200 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2004-11-18 18:10:07 +0200 |
commit | f5e253dc2f94029cf2904702c197aa01537ddab4 (patch) | |
tree | d831cff077b97eced161a50c24d8964c0a08a416 /sql/item_cmpfunc.cc | |
parent | 078597564d699289ba76ab211f5c5c685705efa1 (diff) | |
download | mariadb-git-f5e253dc2f94029cf2904702c197aa01537ddab4.tar.gz |
reporting empty result added in case of max/min optimisation of ALL/ANY/SOME subqueries
fixed null processing in NOT operation used in ALL subquery (Bug #6247)
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index c36f2d191c7..d3c9cfc2c58 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -106,7 +106,7 @@ longlong Item_func_not::val_int() DBUG_ASSERT(fixed == 1); double value=args[0]->val(); null_value=args[0]->null_value; - return !null_value && value == 0 ? 1 : 0; + return ((!null_value && value == 0) ? 1 : 0); } /* @@ -117,13 +117,23 @@ longlong Item_func_not_all::val_int() { DBUG_ASSERT(fixed == 1); double value= args[0]->val(); - if (abort_on_null) - { - null_value= 0; - return (args[0]->null_value || value == 0) ? 1 : 0; - } + + /* + return TRUE if there was records in underlaying select in max/min + optimisation + */ + if (empty_underlying_subquery()) + return 1; + null_value= args[0]->null_value; - return (!null_value && value == 0) ? 1 : 0; + return ((!null_value && value == 0) ? 1 : 0); +} + + +bool Item_func_not_all::empty_underlying_subquery() +{ + return ((test_sum_item && !test_sum_item->any_value()) || + (test_sub_item && !test_sub_item->any_value())); } void Item_func_not_all::print(String *str) @@ -134,6 +144,28 @@ void Item_func_not_all::print(String *str) args[0]->print(str); } + +/* + special NOP for ALL subquery +*/ + +longlong Item_func_nop_all::val_int() +{ + DBUG_ASSERT(fixed == 1); + double value= args[0]->val(); + + /* + return TRUE if there was records in underlaying select in max/min + optimisation + */ + if (empty_underlying_subquery()) + return 1; + + null_value= args[0]->null_value; + return (null_value || value == 0) ? 0 : 1; +} + + /* Convert a constant expression or string to an integer. This is done when comparing DATE's of different formats and |