aboutsummaryrefslogtreecommitdiff
path: root/test/minmax.test
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2004-06-24 00:20:04 +0000
committerdanielk1977 <danielk1977@noemail.net>2004-06-24 00:20:04 +0000
commit3aeab9e438b2252d7ebd8a20b69be47ebd6aee4b (patch)
treec77e71217c5049577bfbf72c4908bfca59ce7e10 /test/minmax.test
parent1ba1b5511ce578095e1153f36ba820cd170866ef (diff)
downloadsqlite-3aeab9e438b2252d7ebd8a20b69be47ebd6aee4b.tar.gz
sqlite-3aeab9e438b2252d7ebd8a20b69be47ebd6aee4b.zip
Apply (1679) to version 3. Ticket #777. (CVS 1680)
FossilOrigin-Name: 0a26b9158095f0995fce2f0ccdfb383ab26c76a5
Diffstat (limited to 'test/minmax.test')
-rw-r--r--test/minmax.test34
1 files changed, 32 insertions, 2 deletions
diff --git a/test/minmax.test b/test/minmax.test
index 5517ad99e..3a32f76c7 100644
--- a/test/minmax.test
+++ b/test/minmax.test
@@ -13,7 +13,7 @@
# aggregate min() and max() functions and which are handled as
# as a special case.
#
-# $Id: minmax.test,v 1.9 2004/03/13 14:00:37 drh Exp $
+# $Id: minmax.test,v 1.10 2004/06/24 00:20:05 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -127,7 +127,7 @@ do_test minmax-4.1 {
SELECT coalesce(min(x+0),-1), coalesce(max(x+0),-1) FROM
(SELECT * FROM t1 UNION SELECT NULL as 'x', NULL as 'y')
}
-} {1 20}
+} {-1 20}
do_test minmax-4.2 {
execsql {
SELECT y, sum(x) FROM
@@ -276,4 +276,34 @@ do_test minmax-9.2 {
}
} {{}}
+# If there is a NULL in an aggregate max(), ignore it. If a NULL
+# occurs in an aggregate min(), then the result will be NULL because
+# NULL compares less than all other values.
+#
+do_test minmax-10.1 {
+ execsql {
+ CREATE TABLE t6(x);
+ INSERT INTO t6 VALUES(1);
+ INSERT INTO t6 VALUES(2);
+ INSERT INTO t6 VALUES(NULL);
+ SELECT coalesce(min(x),-1) FROM t6;
+ }
+} {-1}
+do_test minmax-10.2 {
+ execsql {
+ SELECT max(x) FROM t6;
+ }
+} {2}
+do_test minmax-10.3 {
+ execsql {
+ CREATE INDEX i6 ON t6(x);
+ SELECT coalesce(min(x),-1) FROM t6;
+ }
+} {-1}
+do_test minmax-10.4 {
+ execsql {
+ SELECT max(x) FROM t6;
+ }
+} {2}
+
finish_test