diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index e631c7dbe5a06eabc1f7ccceddf169a54b579a2e..fc2df2b7fc271ca0bb6f2ffe1514cb08a25d4c53 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -570,27 +570,3 @@ ORDER BY t1.f1; f1 DROP TABLE t1,t2; End of 5.1 tests -# -# LP bug #791761: MAX over an empty join + HAVING -# -CREATE TABLE t1 (a int, b int , KEY (b)) ; -INSERT INTO t1 VALUES (3,1); -CREATE TABLE t2 (a int NOT NULL ) ; -INSERT INTO t2 VALUES (29); -SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a > 0 HAVING MAX(t1.b) <> 6; -MAX(t1.b) -1 -SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a > 0 HAVING MAX(t1.b) IS NULL; -MAX(t1.b) -EXPLAIN -SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a < 0 HAVING MAX(t1.b) <> 6; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a < 0 HAVING MAX(t1.b) <> 6; -MAX(t1.b) -CREATE TABLE t3 ( f3 int) ; -INSERT INTO t3 VALUES (NULL); -SELECT MAX(t1.b) AS f FROM t1 JOIN t2 ON t2.a != 0 -WHERE (SELECT f3 FROM t3) <> 0 HAVING f <> 6 ; -f -DROP TABLE t1,t2,t3; diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 01342fdf5fa888f56ca777f8df41cc7b40f02b8c..2ed8b40b8589bc05854aaec69b3397d59ccf9368 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -591,28 +591,3 @@ DROP TABLE t1,t2; --echo End of 5.1 tests - ---echo # ---echo # LP bug #791761: MAX over an empty join + HAVING ---echo # - -CREATE TABLE t1 (a int, b int , KEY (b)) ; -INSERT INTO t1 VALUES (3,1); - -CREATE TABLE t2 (a int NOT NULL ) ; -INSERT INTO t2 VALUES (29); - -SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a > 0 HAVING MAX(t1.b) <> 6; -SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a > 0 HAVING MAX(t1.b) IS NULL; - -EXPLAIN -SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a < 0 HAVING MAX(t1.b) <> 6; -SELECT MAX(t1.b) FROM t1,t2 WHERE t2.a < 0 HAVING MAX(t1.b) <> 6; - -CREATE TABLE t3 ( f3 int) ; -INSERT INTO t3 VALUES (NULL); - -SELECT MAX(t1.b) AS f FROM t1 JOIN t2 ON t2.a != 0 - WHERE (SELECT f3 FROM t3) <> 0 HAVING f <> 6 ; - -DROP TABLE t1,t2,t3; diff --git a/sql/item.h b/sql/item.h index 9891d690798f32bd7bc82dc8cd2fca808b663247..aeae1b1faf22ded81ee8a32863af9b108d83aa3f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1032,7 +1032,6 @@ class Item { virtual bool update_table_bitmaps_processor(uchar *arg) { return 0; } virtual bool view_used_tables_processor(uchar *arg) { return 0; } virtual bool eval_not_null_tables(uchar *opt_arg) { return 0; } - virtual bool clear_sum_processor(uchar *opt_arg) { return 0; } virtual bool is_subquery_processor (uchar *opt_arg) { return 0; } virtual bool limit_index_condition_pushdown_processor(uchar *opt_arg) { diff --git a/sql/item_sum.h b/sql/item_sum.h index 11caf37e6fe3b4cc2a39fca6eae89c8f954dc854..c970dec5082395049228bf3f86aefd6de1599d9c 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -390,7 +390,6 @@ class Item_sum :public Item_result_field { return trace_unsupported_by_check_vcol_func_processor(func_name()); } - bool clear_sum_processor(uchar *arg) { clear(); return 0; } }; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b66d235a2e9fad33df48a5ca87e490ce42f866b8..d5a2337445592ab7b2cd2cb428f9f02bfe23880f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -10470,9 +10470,7 @@ return_zero_rows(JOIN *join, select_result *result, List<TABLE_LIST> &tables, if (!table->is_jtbm()) mark_as_null_row(table->table); // All fields are NULL } - if (having && - !having->walk(&Item::clear_sum_processor, FALSE, NULL) && - having->val_int() == 0) + if (having && having->val_int() == 0) send_row=0; } if (!(result->send_fields(fields,