dan | 29c7f9c | 2009-09-22 15:53:47 +0000 | [diff] [blame] | 1 | # 2009 September 22 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 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. |
| 9 | # |
| 10 | #*********************************************************************** |
| 11 | # |
| 12 | # |
| 13 | |
| 14 | set testdir [file dirname $argv0] |
| 15 | source $testdir/tester.tcl |
| 16 | |
| 17 | ifcapable !foreignkey||!trigger { |
| 18 | finish_test |
| 19 | return |
| 20 | } |
| 21 | source $testdir/malloc_common.tcl |
| 22 | |
| 23 | do_malloc_test fkey_malloc-1 -sqlprep { |
| 24 | PRAGMA foreign_keys = 1; |
| 25 | CREATE TABLE t1(a PRIMARY KEY, b); |
| 26 | CREATE TABLE t2(x REFERENCES t1 ON UPDATE CASCADE ON DELETE CASCADE); |
| 27 | } -sqlbody { |
| 28 | INSERT INTO t1 VALUES('aaa', 1); |
| 29 | INSERT INTO t2 VALUES('aaa'); |
| 30 | UPDATE t1 SET a = 'bbb'; |
| 31 | DELETE FROM t1; |
| 32 | } |
| 33 | |
dan | f59c5ca | 2009-09-22 16:55:38 +0000 | [diff] [blame^] | 34 | do_malloc_test fkey_malloc-2 -sqlprep { |
| 35 | PRAGMA foreign_keys = 1; |
| 36 | CREATE TABLE t1(a, b, UNIQUE(a, b)); |
| 37 | } -sqlbody { |
| 38 | CREATE TABLE t2(x, y, |
| 39 | FOREIGN KEY(x, y) REFERENCES t1(a, b) DEFERRABLE INITIALLY DEFERRED |
| 40 | ); |
| 41 | BEGIN; |
| 42 | INSERT INTO t2 VALUES('a', 'b'); |
| 43 | INSERT INTO t1 VALUES('a', 'b'); |
| 44 | UPDATE t1 SET a = 'c'; |
| 45 | DELETE FROM t2; |
| 46 | INSERT INTO t2 VALUES('d', 'b'); |
| 47 | UPDATE t2 SET x = 'c'; |
| 48 | COMMIT; |
| 49 | } |
| 50 | |
dan | 29c7f9c | 2009-09-22 15:53:47 +0000 | [diff] [blame] | 51 | finish_test |
| 52 | |
| 53 | |