wasCSharpSQLite – Blame information for rev 7
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | # 2011 Feb 04 |
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 | # This file implements regression tests for SQLite library. |
||
12 | # |
||
13 | # This file test deferred foreign key constraint processing to make |
||
14 | # sure that when a statement not within BEGIN...END fails a constraint, |
||
15 | # that statement doesn't hold the transaction open thus allowing |
||
16 | # a subsequent statement to fail a deferred constraint with impunity. |
||
17 | # |
||
18 | |||
19 | set testdir [file dirname $argv0] |
||
20 | source $testdir/tester.tcl |
||
21 | |||
22 | ifcapable {!foreignkey||!trigger} { |
||
23 | finish_test |
||
24 | return |
||
25 | } |
||
26 | |||
27 | # Create a table and some data to work with. |
||
28 | # |
||
29 | do_test fkey4-1.1 { |
||
30 | execsql { |
||
31 | PRAGMA foreign_keys = ON; |
||
32 | CREATE TABLE t1(a PRIMARY KEY, b); |
||
33 | CREATE TABLE t2(c REFERENCES t1 DEFERRABLE INITIALLY DEFERRED, d); |
||
34 | INSERT INTO t1 VALUES(1,2); |
||
35 | INSERT INTO t2 VALUES(1,3); |
||
36 | } |
||
37 | } {} |
||
38 | |||
39 | do_test fkey4-1.2 { |
||
40 | set ::DB [sqlite3_connection_pointer db] |
||
41 | set ::SQL {INSERT INTO t2 VALUES(2,4)} |
||
42 | set ::STMT1 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL] |
||
43 | sqlite3_step $::STMT1 |
||
44 | } {SQLITE_CONSTRAINT} |
||
45 | do_test fkey4-1.3 { |
||
46 | set ::STMT2 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL] |
||
47 | sqlite3_step $::STMT2 |
||
48 | } {SQLITE_CONSTRAINT} |
||
49 | do_test fkey4-1.4 { |
||
50 | db eval {SELECT * FROM t2} |
||
51 | } {1 3} |
||
52 | sqlite3_finalize $::STMT1 |
||
53 | sqlite3_finalize $::STMT2 |
||
54 | |||
55 | finish_test |