3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file implements tests for foreign keys. Specifically, it tests
14 # that ticket b1d3a2e531 has been fixed.
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 ifcapable {!foreignkey||!trigger} {
24 set testprefix tkt-b1d3a2e531
26 do_execsql_test 1.0 { PRAGMA foreign_keys = ON }
29 CREATE TABLE pp(x PRIMARY KEY);
30 CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);
31 INSERT INTO pp VALUES('abc');
32 INSERT INTO cc VALUES('abc');
41 CREATE TABLE pp(x PRIMARY KEY);
42 CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);
43 INSERT INTO pp VALUES('abc');
44 INSERT INTO cc VALUES('abc');
54 CREATE TABLE pp(x PRIMARY KEY);
56 y INTEGER PRIMARY KEY REFERENCES pp DEFERRABLE INITIALLY DEFERRED
58 INSERT INTO pp VALUES(5);
59 INSERT INTO cc VALUES(5);
68 CREATE TABLE pp(x PRIMARY KEY);
70 y INTEGER PRIMARY KEY REFERENCES pp DEFERRABLE INITIALLY DEFERRED
72 INSERT INTO pp VALUES(5);
73 INSERT INTO cc VALUES(5);
83 CREATE TABLE pp1(x PRIMARY KEY);
84 CREATE TABLE cc1(y REFERENCES pp1 DEFERRABLE INITIALLY DEFERRED);
86 CREATE TABLE pp2(x PRIMARY KEY);
87 CREATE TABLE cc2(y REFERENCES pp1 DEFERRABLE INITIALLY DEFERRED);
89 INSERT INTO pp1 VALUES(2200);
90 INSERT INTO cc1 VALUES(NULL);
92 INSERT INTO pp2 VALUES(2200);
93 INSERT INTO cc2 VALUES(2200);
95 do_catchsql_test 3.2 {
101 } {1 {FOREIGN KEY constraint failed}}
102 do_catchsql_test 3.3 {