From 6cfc5e0eb2a0931903ecffb6d438f5dc6ea011f0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 2 Mar 2002 09:51:24 +0200 Subject: Fix sorting of NULL values (Should always be first) Fix problem with HAVING and MAX() IS NOT NULL Docs/manual.texi: Changelog & NULL usage with ORDER BY client/mysqldump.c: Cleanup disable keys mysql-test/r/distinct.result: Fix results after ORDER BY with NULL fix mysql-test/r/group_by.result: Fix results after ORDER BY with NULL fix mysql-test/r/having.result: Testcase for bug with HAVING mysql-test/t/distinct.test: Test for DISTINCT + ORDER BY DESC bug mysql-test/t/having.test: Test of HAVING and MAX IS NOT NULL sql/filesort.cc: Fix sorting of NULL values (Should always be first) sql/item.h: Fix problem with HAVING and MAX() IS NOT NULL sql/item_sum.h: Fix problem with HAVING and MAX() IS NOT NULL sql/opt_range.cc: Fix problem with HAVING and MAX() IS NOT NULL sql/opt_range.h: Fix sorting of NULL values sql/sql_select.cc: Fix sorting of ORDER BY ... DESC on NULL values. --- mysql-test/t/having.test | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mysql-test/t/having.test') diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index fff5415976c..8dd7606d82b 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -48,3 +48,15 @@ GROUP BY e.id HAVING chr_strand= -1 and end >= 0 AND start <= 999660; drop table t1,t2; + +# +# Test problem with having and MAX() IS NOT NULL +# + +CREATE TABLE t1 (Fld1 int(11) default NULL,Fld2 int(11) default NULL); +INSERT INTO t1 VALUES (1,10),(1,20),(2,NULL),(2,NULL),(3,50); +select Fld1, max(Fld2) as q from t1 group by Fld1 having q is not null; +select Fld1, max(Fld2) from t1 group by Fld1 having max(Fld2) is not null; +select Fld1, max(Fld2) from t1 group by Fld1 having avg(Fld2) is not null; +select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null; +drop table t1; -- cgit v1.2.1