]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Added more tests of unique indices. (CVS 270)
authordrh <drh@noemail.net>
Thu, 27 Sep 2001 23:57:06 +0000 (23:57 +0000)
committerdrh <drh@noemail.net>
Thu, 27 Sep 2001 23:57:06 +0000 (23:57 +0000)
FossilOrigin-Name: 3ae952933997c6422ec53b26391ba362c6e5c44a

manifest
manifest.uuid
test/unique.test

index 4b7e05aca7b614a093f94b9ddde84921e08cb7a1..ddc34576b77085c5251561e1c9baf1fe48e911c3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Alpha-3\s(CVS\s269)
-D 2001-09-27T15:13:40
+C Added\smore\stests\sof\sunique\sindices.\s(CVS\s270)
+D 2001-09-27T23:57:06
 F Makefile.in fe9d96d6a7b04b3000a24692c2a3761840bbbf97
 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
 F VERSION 17fadc361fb942d644f92116388409c937c9fa79
@@ -74,7 +74,7 @@ F test/tableapi.test 162840153191a91a7dce6395f2334f9aef713b37
 F test/tclsqlite.test a57bb478d7e9f0b2c927f92e161f391e2896631a
 F test/tester.tcl c7ddeebc14cc841abb37134cd5d40c1e3ad367c1
 F test/trans.test 855337b8a178c73c433fcf8ee88e4b2f5efff0d9
-F test/unique.test 23056f0705755bc503ff543e79b79a5c91d35850
+F test/unique.test ef1f67607a7109e9c0842cd8557550fb121d7ec6
 F test/update.test b320ea22899e80b32b4d21c54591eb7a6ba4d6bd
 F test/vacuum.test 8acf8669f3b627e54149b25165b034aa06c2432e
 F test/where.test 43d5ac94da3f3722375307f948884dc79b326a91
@@ -100,7 +100,7 @@ F www/speed.tcl 91b53f9403a62bb322dc1f85a81531309bcfb41c
 F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
 F www/tclsqlite.tcl 13d50723f583888fc80ae1a38247c0ab415066fa
 F www/vdbe.tcl 0c8aaa529dd216ccbf7daaabd80985e413d5f9ad
-P 116fdad06868acf6aca9e75c2c3497c0511a42c3
-R bab102652f094d1047c0063db1742af9
+P a70d445070c905690dd8ec080981232594e1a969
+R 1b44db7fca8e394e88522eb424d8e81f
 U drh
-Z b41297f7bc20aa98a04e339482b2110b
+Z 52b2894364a881e04b3ad05afbb2e248
index 6d81284f19254190906133fa27727487589befca..91034072fcfe5ef58de696223437cbf3aa5bdc4c 100644 (file)
@@ -1 +1 @@
-a70d445070c905690dd8ec080981232594e1a969
\ No newline at end of file
+3ae952933997c6422ec53b26391ba362c6e5c44a
\ No newline at end of file
index e2eb6978924f9e6b5784069e765dae759fbc9bdb..c41203dfa53e27e51101533236117d59e1676e41 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing the CREATE UNIQUE INDEX statement,
 # and primary keys, and the UNIQUE constraint on table columns
 #
-# $Id: unique.test,v 1.1 2001/09/27 15:11:55 drh Exp $
+# $Id: unique.test,v 1.2 2001/09/27 23:57:06 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -29,5 +29,128 @@ do_test unique-1.1 {
     );
   }
 } {0 {}}
+do_test unique-1.2 {
+  catchsql {
+    INSERT INTO t1(a,b,c) VALUES(1,2,3)
+  }
+} {0 {}}
+do_test unique-1.3 {
+  catchsql {
+    INSERT INTO t1(a,b,c) VALUES(1,3,4)
+  }
+} {1 {constraint failed}}
+do_test unique-1.4 {
+  execsql {
+    SELECT * FROM t1 ORDER BY a;
+  }
+} {1 2 3}
+do_test unique-1.5 {
+  catchsql {
+    INSERT INTO t1(a,b,c) VALUES(3,2,4)
+  }
+} {1 {constraint failed}}
+do_test unique-1.6 {
+  execsql {
+    SELECT * FROM t1 ORDER BY a;
+  }
+} {1 2 3}
+do_test unique-1.7 {
+  catchsql {
+    INSERT INTO t1(a,b,c) VALUES(3,4,5)
+  }
+} {0 {}}
+do_test unique-1.8 {
+  execsql {
+    SELECT * FROM t1 ORDER BY a;
+  }
+} {1 2 3 3 4 5}
+
+do_test unique-2.0 {
+  execsql {
+    DROP TABLE t1;
+    CREATE TABLE t2(a int, b int);
+    INSERT INTO t2(a,b) VALUES(1,2);
+    INSERT INTO t2(a,b) VALUES(3,4);
+    SELECT * FROM t2 ORDER BY a;
+  }
+} {1 2 3 4}
+do_test unique-2.1 {
+  catchsql {
+    CREATE UNIQUE INDEX i2 ON t2(a)
+  }
+} {0 {}}
+do_test unique-2.2 {
+  catchsql {
+    SELECT * FROM t2 ORDER BY a
+  }
+} {0 {1 2 3 4}}
+do_test unique-2.3 {
+  catchsql {
+    INSERT INTO t2 VALUES(1,5);
+  }
+} {1 {constraint failed}}
+do_test unique-2.4 {
+  catchsql {
+    SELECT * FROM t2 ORDER BY a
+  }
+} {0 {1 2 3 4}}
+do_test unique-2.5 {
+  catchsql {
+    DROP INDEX i2;
+    SELECT * FROM t2 ORDER BY a;
+  }
+} {0 {1 2 3 4}}
+do_test unique-2.6 {
+  catchsql {
+    INSERT INTO t2 VALUES(1,5)
+  }
+} {0 {}}
+do_test unique-2.7 {
+  catchsql {
+    SELECT * FROM t2 ORDER BY a, b;
+  }
+} {0 {1 2 1 5 3 4}}
+do_test unique-2.8 {
+  catchsql {
+    CREATE UNIQUE INDEX i2 ON t2(a);
+  }
+} {1 {constraint failed}}
+do_test unique-2.9 {
+  catchsql {
+    CREATE INDEX i2 ON t2(a);
+  }
+} {0 {}}
+
+# Test the UNIQUE keyword as used on two or more fields.
+#
+do_test unique-3.1 {
+  catchsql {
+    CREATE TABLE t3(
+       a int,
+       b int,
+       c int,
+       d int,
+       unique(a,c,d)
+     );
+  }
+} {0 {}}
+do_test unique-3.2 {
+  catchsql {
+    INSERT INTO t3(a,b,c,d) VALUES(1,2,3,4);
+    SELECT * FROM t3 ORDER BY a,b,c,d;
+  }
+} {0 {1 2 3 4}}
+do_test unique-3.3 {
+  catchsql {
+    INSERT INTO t3(a,b,c,d) VALUES(1,2,3,5);
+    SELECT * FROM t3 ORDER BY a,b,c,d;
+  }
+} {0 {1 2 3 4 1 2 3 5}}
+do_test unique-3.4 {
+  catchsql {
+    INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5);
+    SELECT * FROM t3 ORDER BY a,b,c,d;
+  }
+} {1 {constraint failed}}
 
 finish_test