summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-07-20 21:55:55 -0700
committerIgor Babaev <igor@askmonty.org>2011-07-20 21:55:55 -0700
commit2e8542f4620fd64e65eb6e41122bbe166c242a01 (patch)
tree1b19d7e54e2415fd9aba043b07c1b5d698d6bc3c /sql/sql_select.cc
parent6dc1cdc2057121d8a10782fc5261e4ea9650a7ab (diff)
downloadmariadb-git-2e8542f4620fd64e65eb6e41122bbe166c242a01.tar.gz
Fixed LP bug #791761.
An aggregating query over an empty set of a join of two tables with a rejecting HAVING clause erroneously could return a row. It could happen in the cases when the optimizer made a conclusion that the aggregating set was empty. Wrong results were produced because the server missed initial setting for aggregation functions in the mentioned cases.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c4f03cf2c4f..eacebcb498a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -10146,7 +10146,9 @@ return_zero_rows(JOIN *join, select_result *result, List<TABLE_LIST> &tables,
TABLE_LIST *table;
while ((table= ti++))
mark_as_null_row(table->table); // All fields are NULL
- if (having && having->val_int() == 0)
+ if (having &&
+ !having->walk(&Item::clear_sum_processor, FALSE, NULL) &&
+ having->val_int() == 0)
send_row=0;
}
if (!(result->send_fields(fields,