]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Test a couple of the examples in foreignkeys.html.
authordan <dan@noemail.net>
Thu, 8 Oct 2009 19:02:50 +0000 (19:02 +0000)
committerdan <dan@noemail.net>
Thu, 8 Oct 2009 19:02:50 +0000 (19:02 +0000)
FossilOrigin-Name: a2fb7902c01f8b095b25d338fc2f23cb26c941d9

manifest
manifest.uuid
test/e_fkey.test

index 73c15fadc4513080d33e9506c84eed83245bb9e7..31fbfd69e6b08e4e90f65008cb060b1062d77d6a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\stest\scases\sto\stest\sfile\s"e_fkey.test".
-D 2009-10-08T17:42:29
+C Test\sa\scouple\sof\sthe\sexamples\sin\sforeignkeys.html.
+D 2009-10-08T19:02:51
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 4ca3f1dd6efa2075bcb27f4dc43eef749877740d
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -319,7 +319,7 @@ F test/descidx2.test 1310ed1326cdfed4ea2c55169631579f082d174f
 F test/descidx3.test 3394ad4d089335cac743c36a14129d6d931c316f
 F test/diskfull.test 0cede7ef9d8f415d9d3944005c76be7589bb5ebb
 F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376
-F test/e_fkey.test 87a5d48261adbd7500dee176b62cffdef3410ac0
+F test/e_fkey.test 9ad5b376c95dfa60281b5931e6a99d446387446c
 F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
 F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398
 F test/enc3.test 5c550d59ff31dccdba5d1a02ae11c7047d77c041
@@ -756,7 +756,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 273ccbf18af5191807678a0a0c09cda82408b29c
-R 762331726a5577e23ac7c6aad53d3fa9
+P 23e0f61a4f24315bf31f632f43b60ec232f348fb
+R bf6536ce577073a4ab6551eb95f10373
 U dan
-Z 4c265bdcf3668f8a9c927f36e1a29a4b
+Z baa870c437a97e37a52b46ca7fd8e861
index 21a5d06bab337880681b1c5458e32f3120bc954a..77e45fb82af7a37dafc72df14ef367716d08679c 100644 (file)
@@ -1 +1 @@
-23e0f61a4f24315bf31f632f43b60ec232f348fb
\ No newline at end of file
+a2fb7902c01f8b095b25d338fc2f23cb26c941d9
\ No newline at end of file
index 21ca85b49ab3dd84321753fc52edd9c86135e14e..cfa5fd4dce856daf53ec8ce4abf649ebb0d13314 100644 (file)
@@ -19,6 +19,110 @@ ifcapable {!foreignkey} { finish_test ; return }
 
 execsql "PRAGMA foreign_keys = ON"
 
+#-------------------------------------------------------------------------
+# /* EV: R-51437-39891 */
+#
+# Test an example from the "ON DELETE and ON UPDATE Actions" section 
+# of foreignkeys.html.
+#
+drop_all_tables
+do_test e_fkey-13.1 {
+  execsql {
+    CREATE TABLE parent(x PRIMARY KEY);
+    CREATE TABLE child(y REFERENCES parent ON UPDATE SET NULL);
+    INSERT INTO parent VALUES('key');
+    INSERT INTO child VALUES('key');
+  }
+} {}
+do_test e_fkey-13.2 {
+  execsql {
+    UPDATE parent SET x = 'key';
+    SELECT IFNULL(y, 'null') FROM child;
+  }
+} {key}
+do_test e_fkey-13.3 {
+  execsql {
+    UPDATE parent SET x = 'key2';
+    SELECT IFNULL(y, 'null') FROM child;
+  }
+} {null}
+
+#-------------------------------------------------------------------------
+# /* EV: R-07065-59588 */
+#
+# Test an example from the "ON DELETE and ON UPDATE Actions" section 
+# of foreignkeys.html.
+#
+drop_all_tables
+do_test e_fkey-14.1 {
+  execsql {
+    CREATE TABLE artist(
+      artistid    INTEGER PRIMARY KEY, 
+      artistname  TEXT
+    );
+    CREATE TABLE track(
+      trackid     INTEGER,
+      trackname   TEXT, 
+      trackartist INTEGER DEFAULT 0 REFERENCES artist(artistid) ON DELETE SET DEFAULT
+    );
+    INSERT INTO artist VALUES(3, 'Sammy Davis Jr.');
+    INSERT INTO track VALUES(14, 'Mr. Bojangles', 3);
+  }
+} {}
+do_test e_fkey-14.2 {
+  catchsql { DELETE FROM artist WHERE artistname = 'Sammy Davis Jr.' }
+} {1 {foreign key constraint failed}}
+do_test e_fkey-14.3 {
+  execsql {
+    INSERT INTO artist VALUES(0, 'Unknown Artist');
+    DELETE FROM artist WHERE artistname = 'Sammy Davis Jr.';
+  }
+} {}
+do_test e_fkey-14.4 {
+  execsql { SELECT * FROM artist }
+} {0 {Unknown Artist}}
+do_test e_fkey-14.5 {
+  execsql { SELECT * FROM track }
+} {14 {Mr. Bojangles} 0}
+
+#-------------------------------------------------------------------------
+# /* EV: R-25213-27898 */
+#
+# Test an example from the "ON DELETE and ON UPDATE Actions" section 
+# of foreignkeys.html.
+#
+drop_all_tables
+do_test e_fkey-15.1 {
+  execsql {
+    CREATE TABLE artist(
+      artistid    INTEGER PRIMARY KEY, 
+      artistname  TEXT
+    );
+    CREATE TABLE track(
+      trackid     INTEGER,
+      trackname   TEXT, 
+      trackartist INTEGER REFERENCES artist(artistid) ON UPDATE CASCADE
+    );
+
+    INSERT INTO artist VALUES(1, 'Dean Martin');
+    INSERT INTO artist VALUES(2, 'Frank Sinatra');
+    INSERT INTO track VALUES(11, 'That''s Amore', 1);
+    INSERT INTO track VALUES(12, 'Christmas Blues', 1);
+    INSERT INTO track VALUES(13, 'My Way', 2);
+  }
+} {}
+do_test e_fkey-15.2 {
+  execsql {
+    UPDATE artist SET artistid = 100 WHERE artistname = 'Dean Martin';
+  }
+} {}
+do_test e_fkey-15.3 {
+  execsql { SELECT * FROM artist }
+} {2 {Frank Sinatra} 100 {Dean Martin}}
+do_test e_fkey-15.4 {
+  execsql { SELECT * FROM track }
+} {11 {That's Amore} 100 12 {Christmas Blues} 100 13 {My Way} 2}
+
 #-------------------------------------------------------------------------
 # /* EV: R-36018-21755 */
 # /* EV: R-25384-39337 */