summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-08-23 12:46:25 +0300
committerMichael Widenius <monty@askmonty.org>2010-08-23 12:46:25 +0300
commitb6fe4713fe14c059c4bceca60ed1863a90b7e512 (patch)
treedde4fe858e152b2b411a5b8c1d750629cf228a35 /sql/item_sum.h
parent096666fcbbf0329676cfd1d8623c1503613f1570 (diff)
downloadmariadb-git-b6fe4713fe14c059c4bceca60ed1863a90b7e512.tar.gz
Fix for LP#612894 Some aggregate functions (such as MIN MAX) work incorrectly in subqueries after getting NULL value
mysql-test/r/group_by.result: Added test that showed problems that no_rows_in_results() didn't work for expressions mysql-test/r/subselect4.result: Test case for LP#612894 mysql-test/t/group_by.test: Added test that showed problems that no_rows_in_results() didn't work for expressions mysql-test/t/subselect4.test: Test case for LP#612894 sql/item.h: Added restore_to_before_no_rows_in_result() Added function processor for no_rows_in_results() and restore_to_before_no_rows_in_results() to ensure it works with functions Fix that above functions are handled by Item_ref() sql/item_func.h: Ensure that no_rows_in_results() and restore_to_before_no_rows_in_result() are called for all function arguments sql/item_sum.cc: Added restore_to_before_no_rows_in_result() to restore settings after Item_sum_hybrid::no_rows_in_result() was called. This is needed to handle the case where we have made 'make_const()' on the item in opt_sum(), but the item will be reused again in a sub query. Ignore multiple calls to no_rows_in_result() as Item_ref is calling it twice. sql/item_sum.h: Added restore_to_before_no_rows_in_result(); sql/sql_select.cc: Added reset of no_rows_in_result() for JOIN::reinit() sql/sql_select.h: Added marker if no_rows_in_result() is called.
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index b82f2d961f1..ac6a56400a4 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -496,7 +496,7 @@ public:
enum Sumfunctype sum_func () const { return SUM_DISTINCT_FUNC; }
void reset_field() {} // not used
void update_field() {} // not used
- virtual void no_rows_in_result() {}
+ void no_rows_in_result() {}
void fix_length_and_dec();
enum Item_result result_type () const { return val.traits->type(); }
virtual void calculate_val_and_count();
@@ -845,6 +845,7 @@ protected:
enum_field_types hybrid_field_type;
int cmp_sign;
bool was_values; // Set if we have found at least one row (for max/min only)
+ bool was_null_value;
public:
Item_sum_hybrid(Item *item_par,int sign)
@@ -876,6 +877,7 @@ protected:
void cleanup();
bool any_value() { return was_values; }
void no_rows_in_result();
+ void restore_to_before_no_rows_in_result();
Field *create_tmp_field(bool group, TABLE *table,
uint convert_blob_length);
};