1#
2# 2001 September 15
3#
4# The author disclaims copyright to this source code.  In place of
5# a legal notice, here is a blessing:
6#
7#    May you do good and not evil.
8#    May you find forgiveness for yourself and forgive others.
9#    May you share freely, never taking more than you give.
10#
11#***********************************************************************
12# This file implements regression tests for SQLite library.
13#
14# This file implements tests for foreign keys.
15#
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
20# Create a table and some data to work with.
21#
22do_test fkey1-1.0 {
23  execsql {
24    CREATE TABLE t1(
25      a INTEGER PRIMARY KEY,
26      b INTEGER
27           REFERENCES t1 ON DELETE CASCADE
28           REFERENCES t2,
29      c TEXT,
30      FOREIGN KEY (b,c) REFERENCES t2(x,y) ON UPDATE CASCADE
31    );
32  }
33} {}
34do_test fkey1-1.1 {
35  execsql {
36    CREATE TABLE t2(
37      x INTEGER PRIMARY KEY,
38      y TEXT
39    );
40  }
41} {}
42do_test fkey1-1.2 {
43  execsql {
44    CREATE TABLE t3(
45      a INTEGER REFERENCES t2,
46      b INTEGER REFERENCES t1,
47      FOREIGN KEY (a,b) REFERENCES t2(x,y)
48    );
49  }
50} {}
51
52
53
54finish_test
55