summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2010-07-09 14:39:47 +0400
committerSergey Glukhov <Sergey.Glukhov@sun.com>2010-07-09 14:39:47 +0400
commit013136364c95b7bcc5a987dd301b042f31dab1f9 (patch)
tree2856c3cdebae0d619e3583ec3b8e82991deed42d /sql/sql_select.cc
parent625ae7185abcfc7042be225d4f8ef77806fc0803 (diff)
downloadmariadb-git-013136364c95b7bcc5a987dd301b042f31dab1f9.tar.gz
Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set
The problem there is that HAVING condition evaluates const parts of condition despite the condition has references on aggregate functions. Table t1 became const tables after make_join_statistics and table1.pk = 1, HAVING is transformed into MAX(1) < 7 and taken away from HAVING. The fix is to skip evaluation of HAVING conts parts if HAVING condition has references on aggregate functions. mysql-test/r/having.result: test case mysql-test/t/having.test: test case sql/sql_select.cc: skip evaluation of HAVING conts parts if HAVING condition has references on aggregate functions.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index b20726fc151..fe391b50bb9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1132,7 +1132,7 @@ JOIN::optimize()
elements may be lost during further having
condition transformation in JOIN::exec.
*/
- if (having && const_table_map)
+ if (having && const_table_map && !having->with_sum_func)
{
having->update_used_tables();
having= remove_eq_conds(thd, having, &having_value);