summaryrefslogtreecommitdiff
path: root/test/fkey2.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/fkey2.test')
-rw-r--r--test/fkey2.test36
1 files changed, 31 insertions, 5 deletions
diff --git a/test/fkey2.test b/test/fkey2.test
index f0cc4d2..3e5b27c 100644
--- a/test/fkey2.test
+++ b/test/fkey2.test
@@ -139,14 +139,21 @@ set FkeySimpleTests {
4.17 "UPDATE t7 SET a = 10" {0 {}}
5.1 "INSERT INTO t9 VALUES(1, 3)" {1 {no such table: main.nosuchtable}}
- 5.2 "INSERT INTO t10 VALUES(1, 3)" {1 {foreign key mismatch}}
+ 5.2 "INSERT INTO t10 VALUES(1, 3)"
+ {1 {foreign key mismatch - "t10" referencing "t9"}}
}
do_test fkey2-1.1.0 {
execsql [string map {/D/ {}} $FkeySimpleSchema]
} {}
foreach {tn zSql res} $FkeySimpleTests {
- do_test fkey2-1.1.$tn { catchsql $zSql } $res
+ do_test fkey2-1.1.$tn.1 { catchsql $zSql } $res
+ do_test fkey2-1.1.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test fkey2-1.1.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test fkey2-1.1.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test fkey2-1.1.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test fkey2-1.1.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test fkey2-1.1.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
}
drop_all_tables
@@ -155,6 +162,12 @@ do_test fkey2-1.2.0 {
} {}
foreach {tn zSql res} $FkeySimpleTests {
do_test fkey2-1.2.$tn { catchsql $zSql } $res
+ do_test fkey2-1.2.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test fkey2-1.2.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test fkey2-1.2.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test fkey2-1.2.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test fkey2-1.2.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test fkey2-1.2.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
}
drop_all_tables
@@ -165,6 +178,12 @@ do_test fkey2-1.3.0 {
foreach {tn zSql res} $FkeySimpleTests {
if {$res == "0 {}"} { set res {0 1} }
do_test fkey2-1.3.$tn { catchsql $zSql } $res
+ do_test fkey2-1.3.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}
+ do_test fkey2-1.3.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}
+ do_test fkey2-1.3.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}
+ do_test fkey2-1.3.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}
+ do_test fkey2-1.3.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}
+ do_test fkey2-1.3.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}
}
execsql { PRAGMA count_changes = 0 }
drop_all_tables
@@ -681,7 +700,7 @@ foreach zSql [list {
do_test fkey2-10.1.[incr tn] {
execsql $zSql
catchsql { INSERT INTO c DEFAULT VALUES }
- } {1 {foreign key mismatch}}
+ } {/1 {foreign key mismatch - "c" referencing "."}/}
}
# "rowid" cannot be used as part of a child or parent key definition
@@ -709,7 +728,7 @@ do_test fkey2-10.2.1 {
INSERT INTO t1(rowid, a, b) VALUES(1, 1, 1);
INSERT INTO t2 VALUES(1, 1);
}
-} {1 {foreign key mismatch}}
+} {1 {foreign key mismatch - "t2" referencing "t1"}}
do_test fkey2-10.2.2 {
drop_all_tables
catchsql {
@@ -1223,7 +1242,7 @@ do_test fkey-2.14.3.8 {
CREATE TABLE cc(a, b, FOREIGN KEY(a, b) REFERENCES pp(x, z));
}
catchsql { INSERT INTO cc VALUES(1, 2) }
-} {1 {foreign key mismatch}}
+} {1 {foreign key mismatch - "cc" referencing "pp"}}
do_test fkey-2.14.3.9 {
execsql { DROP TABLE cc }
} {}
@@ -1414,10 +1433,12 @@ 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}
+verify_ex_errcode fkey2-17.1.2b SQLITE_CONSTRAINT_FOREIGNKEY
ifcapable autoreset {
do_test fkey2-17.1.3 {
sqlite3_step $STMT
} {SQLITE_CONSTRAINT}
+ verify_ex_errcode fkey2-17.1.3b SQLITE_CONSTRAINT_FOREIGNKEY
} else {
do_test fkey2-17.1.3 {
sqlite3_step $STMT
@@ -1426,6 +1447,7 @@ ifcapable autoreset {
do_test fkey2-17.1.4 {
sqlite3_finalize $STMT
} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey2-17.1.4b SQLITE_CONSTRAINT_FOREIGNKEY
do_test fkey2-17.1.5 {
execsql {
INSERT INTO one VALUES(2, 3, 4);
@@ -1469,9 +1491,11 @@ do_test fkey2-17.1.12 {
do_test fkey2-17.1.13 {
sqlite3_step $STMT
} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey2-17.1.13b SQLITE_CONSTRAINT_FOREIGNKEY
do_test fkey2-17.1.14 {
sqlite3_finalize $STMT
} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey2-17.1.14b SQLITE_CONSTRAINT_FOREIGNKEY
drop_all_tables
do_test fkey2-17.2.1 {
@@ -1625,9 +1649,11 @@ do_test fkey2-19.2 {
sqlite3_bind_int $S 1 2
sqlite3_step $S
} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey2-19.2b SQLITE_CONSTRAINT_FOREIGNKEY
do_test fkey2-19.3 {
sqlite3_reset $S
} {SQLITE_CONSTRAINT}
+verify_ex_errcode fkey2-19.3b SQLITE_CONSTRAINT_FOREIGNKEY
do_test fkey2-19.4 {
sqlite3_bind_int $S 1 1
sqlite3_step $S