]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Additional test cases for the coalesce() and ifnull() functions.
authordrh <drh@noemail.net>
Wed, 11 Nov 2009 01:14:17 +0000 (01:14 +0000)
committerdrh <drh@noemail.net>
Wed, 11 Nov 2009 01:14:17 +0000 (01:14 +0000)
FossilOrigin-Name: d0591258b62df4fa610b7ac2a2af0344cf82f231

manifest
manifest.uuid
test/coalesce.test [new file with mode: 0644]

index e21055da579441a4265fa9466c70e2300e0cb635..366fb8b9fd288ca846c1f5d2aca8baa17cec2e0b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-C Generate\sVDBE\scode\sfor\sthe\sbuilt-in\sCOALESCE()\sand\sIFNULL()\sfunctions.\s\sThis\nallows\sunused\sarguments\sto\snever\sbe\sevaluated,\swhich\sis\sa\sperformance\swin\swhen\nthe\sunused\sargument\sis\sa\ssubquery.
-D 2009-11-11T00:24:32
+C Additional\stest\scases\sfor\sthe\scoalesce()\sand\sifnull()\sfunctions.
+D 2009-11-11T01:14:18
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 53f3dfa49f28ab5b80cb083fb7c9051e596bcfa1
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -276,6 +276,7 @@ F test/capi3c.test d9d293ce8fd4dc2944ce2dae5718fc7a6184a567
 F test/capi3d.test 57d83b690d7364bde02cddbf8339a4b50d80ce23
 F test/cast.test 166951664a0b0a2e0f8fb5997a152490c6363932
 F test/check.test b897cd3cc839b34b31cdd073e9882ccd03da977b
+F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91
 F test/collate1.test e3eaa48c21e150814be1a7b852d2a8af24458d04
 F test/collate2.test 04cebe4a033be319d6ddbb3bbc69464e01700b49
 F test/collate3.test d28d2cfab2c3a3d4628ae4b2b7afc9965daa3b4c
@@ -769,14 +770,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 0c8db5d88ee41dab58d6464283b51f82f7457838
-R 77b5dc144a79987f5b38b3638c59cf4e
+P 30055b257c3c65f8123cad5ac6c62c4c6ca2c900
+R f47af5b75e0e8e616f1fd8b931ddb5b3
 U drh
-Z 3ce600a45d7855e5b1ce1fd4101b7aec
+Z 3b5efed677f45a2948478d37ad1216cc
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
-iD8DBQFK+gRDoxKgR168RlERAgIHAJ0c3Kp4EnYcJoKIuhzMw7RRNw4w4wCcDLfM
-lEOWeC7zbgysoema8RzHOEA=
-=mkIE
+iD8DBQFK+g/toxKgR168RlERAjaZAJ4lZcZqcztQ7x0Q3/6iUvbKhaxjwwCfasc4
+Gd5rMrr89fVbrffFtkNRS+A=
+=P4HI
 -----END PGP SIGNATURE-----
index 7a2f9deebcab1c2e4c9c4ecde8a2c6bcb67b821d..61664a8804458e8df1fa052e23e4a791e2558d5b 100644 (file)
@@ -1 +1 @@
-30055b257c3c65f8123cad5ac6c62c4c6ca2c900
\ No newline at end of file
+d0591258b62df4fa610b7ac2a2af0344cf82f231
\ No newline at end of file
diff --git a/test/coalesce.test b/test/coalesce.test
new file mode 100644 (file)
index 0000000..af4ea8d
--- /dev/null
@@ -0,0 +1,84 @@
+# 2009 November 10
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# Additional test cases for the COALESCE() and IFNULL() functions.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+
+do_test coalesce-1.0 {
+  db eval {
+    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);
+    INSERT INTO t1 VALUES(1, null, null, null);
+    INSERT INTO t1 VALUES(2, 2, 99, 99);
+    INSERT INTO t1 VALUES(3, null, 3, 99);
+    INSERT INTO t1 VALUES(4, null, null, 4);
+    INSERT INTO t1 VALUES(5, null, null, null);
+    INSERT INTO t1 VALUES(6, 22, 99, 99);
+    INSERT INTO t1 VALUES(7, null, 33, 99);
+    INSERT INTO t1 VALUES(8, null, null, 44);
+
+    SELECT coalesce(b,c,d) FROM t1 ORDER BY a;
+  }
+} {{} 2 3 4 {} 22 33 44}
+do_test coalesce-1.1 {
+  db eval {
+    SELECT coalesce(d+c+b,d+c,d) FROM t1 ORDER BY a;
+  }
+} {{} 200 102 4 {} 220 132 44}
+do_test coalesce-1.2 {
+  db eval {
+    SELECT ifnull(d+c+b,ifnull(d+c,d)) FROM t1 ORDER BY a;
+  }
+} {{} 200 102 4 {} 220 132 44}
+do_test coalesce-1.3 {
+  db eval {
+    SELECT ifnull(ifnull(d+c+b,d+c),d) FROM t1 ORDER BY a;
+  }
+} {{} 200 102 4 {} 220 132 44}
+do_test coalesce-1.4 {
+  db eval {
+    SELECT ifnull(ifnull(b,c),d) FROM t1 ORDER BY a;
+  }
+} {{} 2 3 4 {} 22 33 44}
+do_test coalesce-1.5 {
+  db eval {
+    SELECT ifnull(b,ifnull(c,d)) FROM t1 ORDER BY a;
+  }
+} {{} 2 3 4 {} 22 33 44}
+do_test coalesce-1.6 {
+  db eval {
+    SELECT coalesce(b,NOT b,-b,abs(b),lower(b),length(b),min(b,5),b*123,c)
+      FROM t1 ORDER BY a;
+  }
+} {{} 2 3 {} {} 22 33 {}}
+do_test coalesce-1.7 {
+  db eval {
+    SELECT ifnull(nullif(a,4),99)
+      FROM t1 ORDER BY a;
+  }
+} {1 2 3 99 5 6 7 8}
+do_test coalesce-1.8 {
+  db eval {
+pragma vdbe_listing=on;
+    SELECT coalesce(
+      CASE WHEN b=2 THEN 123 END,
+      CASE WHEN b=3 THEN 234 END,
+      CASE WHEN c=3 THEN 345 WHEN c=33 THEN 456 END,
+      d
+    )
+    FROM t1 ORDER BY a;
+  }
+} {{} 123 345 4 {} 99 456 44}
+
+
+finish_test