From: Tor Didriksen Date: February 2 2011 9:22am Subject: bzr push into mysql-trunk branch (tor.didriksen:3588 to 3589) Bug#52123 List-Archive: http://lists.mysql.com/commits/130190 X-Bug: 52123 Message-Id: <20110202092217.2E4333768@atum07.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3589 Tor Didriksen 2011-02-02 [merge] Empty merge of Backport of fix for Bug#52123 3588 Ole John Aske 2011-02-02 Fix for bug#56690 'Wrong results with subquery with GROUP BY inside < ANY clause' A subquery of the form : 1) SELECT ... WHERE < ANY(select ...) Is transformed into the form by the optimizer: 2) SELECT ... WHERE < (select MAX()...) The Min/Max aggregation of subquery columns is implemented in 'class select_max_min_finder_subselect'. The handling of NULL values in this implementation was incorrect as they was interpreted as a NULL-value being '>' than any other value being compared. This is incorrect wrt. SQL semantics which specifies that NULL values are 'undefined' and should be removed as soon as a non-NULL value is encountered. This fix changes implementation of all select_max_min_finder_subselect::cmp_() methods to follow the correct SQL semantics as described above. (Which also simplifies the logic IMHO) It also changes the methods to be 'private' within class select_max_min_finder_subselect. modified: mysql-test/include/subquery.inc mysql-test/r/subquery_nomat_nosj.result mysql-test/r/subquery_none.result sql/sql_class.cc sql/sql_class.h No bundle (reason: useless for push emails).