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