1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/fkey1.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,77 @@
1.4 +# 2001 September 15
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library.
1.15 +#
1.16 +# This file implements tests for foreign keys.
1.17 +#
1.18 +
1.19 +set testdir [file dirname $argv0]
1.20 +source $testdir/tester.tcl
1.21 +
1.22 +ifcapable {!foreignkey} {
1.23 + finish_test
1.24 + return
1.25 +}
1.26 +
1.27 +# Create a table and some data to work with.
1.28 +#
1.29 +do_test fkey1-1.0 {
1.30 + execsql {
1.31 + CREATE TABLE t1(
1.32 + a INTEGER PRIMARY KEY,
1.33 + b INTEGER
1.34 + REFERENCES t1 ON DELETE CASCADE
1.35 + REFERENCES t2,
1.36 + c TEXT,
1.37 + FOREIGN KEY (b,c) REFERENCES t2(x,y) ON UPDATE CASCADE
1.38 + );
1.39 + }
1.40 +} {}
1.41 +do_test fkey1-1.1 {
1.42 + execsql {
1.43 + CREATE TABLE t2(
1.44 + x INTEGER PRIMARY KEY,
1.45 + y TEXT
1.46 + );
1.47 + }
1.48 +} {}
1.49 +do_test fkey1-1.2 {
1.50 + execsql {
1.51 + CREATE TABLE t3(
1.52 + a INTEGER REFERENCES t2 ON INSERT RESTRICT,
1.53 + b INTEGER REFERENCES t1,
1.54 + FOREIGN KEY (a,b) REFERENCES t2(x,y)
1.55 + );
1.56 + }
1.57 +} {}
1.58 +
1.59 +do_test fkey1-2.1 {
1.60 + execsql {
1.61 + CREATE TABLE t4(a integer primary key);
1.62 + CREATE TABLE t5(x references t4);
1.63 + CREATE TABLE t6(x references t4);
1.64 + CREATE TABLE t7(x references t4);
1.65 + CREATE TABLE t8(x references t4);
1.66 + CREATE TABLE t9(x references t4);
1.67 + CREATE TABLE t10(x references t4);
1.68 + DROP TABLE t7;
1.69 + DROP TABLE t9;
1.70 + DROP TABLE t5;
1.71 + DROP TABLE t8;
1.72 + DROP TABLE t6;
1.73 + DROP TABLE t10;
1.74 + }
1.75 +} {}
1.76 +
1.77 +
1.78 +
1.79 +
1.80 +finish_test