-C Remove\sunreachable\sbranches\sfrom\sfkey.c.\sAdd\sa\sfew\stests\sto\scover\sthe\sremaining\sbranches.
-D 2009-09-30T08:11:07
+C Add\stests\sto\scheck\sthat\sFK\ssupport\sinteracts\swith\scount-changes\scorrectly.
+D 2009-10-01T04:35:06
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 4ca3f1dd6efa2075bcb27f4dc43eef749877740d
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8
F test/filefmt.test 84e3d0fe9f12d0d2ac852465c6f8450aea0d6f43
F test/fkey1.test 01c7de578e11747e720c2d9aeef27f239853c4da
-F test/fkey2.test 023917f6d133da94088fe4eafcdfceb81abade83
+F test/fkey2.test 7ca63ae07839e700698655010788502b0e5d3e65
F test/fkey3.test c17565b40c97a0dd5102610183c744611171b5ec
F test/fkey_malloc.test a5ede29bd2f6e56dea78c3d43fb86dd696c068c8
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P b733e939f785111eac987fe4a25ccfa512e4f0b4
-R b65fcb7a6b9e80aa54f47592d37aa613
+P 0a0a17d87c990a811a2755b9d9d4141b611b49db
+R 71d9a87efb7de6c5e2fcba593dc5c2be
U dan
-Z bf04350be182c658296913fed86e36e0
+Z 7c4cee03a1a1dae14dd3d77db4d5358b
# fkey2-16.*: Test that rows that refer to themselves may be inserted,
# updated and deleted.
#
+# fkey2-17.*: Test that the "count_changes" pragma does not interfere with
+# FK constraint processing.
+#
# fkey2-genfkey.*: Tests that were used with the shell tool .genfkey
# command. Recycled to test the built-in implementation.
#
} {1 {foreign key constraint failed}}
}
+#-------------------------------------------------------------------------
+# This next block of tests, fkey2-17.*, tests that if "PRAGMA count_changes"
+# is turned on statements that violate immediate FK constraints return
+# SQLITE_CONSTRAINT immediately, not after returning a number of rows.
+# Whereas statements that violate deferred FK constraints return the number
+# of rows before failing.
+#
+# Also test that rows modified by FK actions are not counted in either the
+# returned row count or the values returned by sqlite3_changes(). Like
+# trigger related changes, they are included in sqlite3_total_changes() though.
+#
+drop_all_tables
+do_test fkey2-17.1.1 {
+ execsql { PRAGMA count_changes = 1 }
+ execsql {
+ CREATE TABLE one(a, b, c, UNIQUE(b, c));
+ CREATE TABLE two(d, e, f, FOREIGN KEY(e, f) REFERENCES one(b, c));
+ INSERT INTO one VALUES(1, 2, 3);
+ }
+} {1}
+do_test fkey2-17.1.2 {
+ set STMT [sqlite3_prepare_v2 db "INSERT INTO two VALUES(4, 5, 6)" -1 dummy]
+ sqlite3_step $STMT
+} {SQLITE_CONSTRAINT}
+do_test fkey2-17.1.3 {
+ sqlite3_step $STMT
+} {SQLITE_MISUSE}
+do_test fkey2-17.1.4 {
+ sqlite3_finalize $STMT
+} {SQLITE_CONSTRAINT}
+do_test fkey2-17.1.5 {
+ execsql {
+ INSERT INTO one VALUES(2, 3, 4);
+ INSERT INTO one VALUES(3, 4, 5);
+ INSERT INTO two VALUES(1, 2, 3);
+ INSERT INTO two VALUES(2, 3, 4);
+ INSERT INTO two VALUES(3, 4, 5);
+ }
+} {1 1 1 1 1}
+do_test fkey2-17.1.6 {
+ catchsql {
+ BEGIN;
+ INSERT INTO one VALUES(0, 0, 0);
+ UPDATE two SET e=e+1, f=f+1;
+ }
+} {1 {foreign key constraint failed}}
+do_test fkey2-17.1.7 {
+ execsql { SELECT * FROM one }
+} {1 2 3 2 3 4 3 4 5 0 0 0}
+do_test fkey2-17.1.8 {
+ execsql { SELECT * FROM two }
+} {1 2 3 2 3 4 3 4 5}
+do_test fkey2-17.1.9 {
+ execsql COMMIT
+} {}
+do_test fkey2-17.1.10 {
+ execsql {
+ CREATE TABLE three(
+ g, h, i,
+ FOREIGN KEY(h, i) REFERENCES one(b, c) DEFERRABLE INITIALLY DEFERRED
+ );
+ }
+} {}
+do_test fkey2-17.1.11 {
+ set STMT [sqlite3_prepare_v2 db "INSERT INTO three VALUES(7, 8, 9)" -1 dummy]
+ sqlite3_step $STMT
+} {SQLITE_ROW}
+do_test fkey2-17.1.12 {
+ sqlite3_column_text $STMT 0
+} {1}
+do_test fkey2-17.1.13 {
+ sqlite3_step $STMT
+} {SQLITE_CONSTRAINT}
+do_test fkey2-17.1.14 {
+ sqlite3_finalize $STMT
+} {SQLITE_CONSTRAINT}
+
+drop_all_tables
+do_test fkey2-17.2.1 {
+ execsql {
+ CREATE TABLE high("a'b!" PRIMARY KEY, b);
+ CREATE TABLE low(
+ c,
+ "d&6" REFERENCES high ON UPDATE CASCADE ON DELETE CASCADE
+ );
+ }
+} {}
+do_test fkey2-17.2.2 {
+ execsql {
+ INSERT INTO high VALUES('a', 'b');
+ INSERT INTO low VALUES('b', 'a');
+ }
+ db changes
+} {1}
+set nTotal [db total_changes]
+do_test fkey2-17.2.3 {
+ execsql { UPDATE high SET "a'b!" = 'c' }
+} {1}
+do_test fkey2-17.2.4 {
+ db changes
+} {1}
+do_test fkey2-17.2.5 {
+ expr [db total_changes] - $nTotal
+} {2}
+do_test fkey2-17.2.6 {
+ execsql { SELECT * FROM high ; SELECT * FROM low }
+} {c b b c}
+do_test fkey2-17.2.7 {
+ execsql { DELETE FROM high }
+} {1}
+do_test fkey2-17.2.8 {
+ db changes
+} {1}
+do_test fkey2-17.2.9 {
+ expr [db total_changes] - $nTotal
+} {4}
+do_test fkey2-17.2.10 {
+ execsql { SELECT * FROM high ; SELECT * FROM low }
+} {}
+
+execsql { PRAGMA count_changes = 0 }
#-------------------------------------------------------------------------
# The following block of tests, those prefixed with "fkey2-genfkey.", are
# the same tests that were used to test the ".genfkey" command provided