wasCSharpSQLite – Blame information for rev 7
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | # 2008 November 20 |
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 | # When a transaction rolls back, make sure that dirty pages in the |
||
14 | # page cache which are not in the rollback journal are reinitialized |
||
15 | # in the btree layer. |
||
16 | # |
||
17 | # $Id: tkt35xx.test,v 1.4 2009/06/05 17:09:12 drh Exp $ |
||
18 | |||
19 | set testdir [file dirname $argv0] |
||
20 | source $testdir/tester.tcl |
||
21 | |||
22 | do_test tkt35xx-1.1 { |
||
23 | execsql { |
||
24 | PRAGMA auto_vacuum = 0; |
||
25 | PRAGMA page_size = 1024; |
||
26 | } |
||
27 | } {} |
||
28 | |||
29 | # Trigger the problem using explicit rollback. |
||
30 | # |
||
31 | do_test tkt35xx-1.1 { |
||
32 | execsql { |
||
33 | PRAGMA auto_vacuum = 0; |
||
34 | CREATE TABLE t1(a,b,c); |
||
35 | CREATE INDEX i1 ON t1(c); |
||
36 | INSERT INTO t1 VALUES(0, 0, zeroblob(676)); |
||
37 | INSERT INTO t1 VALUES(1, 1, zeroblob(676)); |
||
38 | DELETE FROM t1; |
||
39 | BEGIN; |
||
40 | INSERT INTO t1 VALUES(0, 0, zeroblob(676)); |
||
41 | INSERT INTO t1 VALUES(1, 1, zeroblob(676)); |
||
42 | ROLLBACK; |
||
43 | INSERT INTO t1 VALUES(0, 0, zeroblob(676)); |
||
44 | } |
||
45 | execsql { |
||
46 | INSERT INTO t1 VALUES(1, 1, zeroblob(676)); |
||
47 | } |
||
48 | } {} |
||
49 | |||
50 | # Trigger the problem using statement rollback. |
||
51 | # |
||
52 | db close |
||
53 | file delete test.db |
||
54 | sqlite3 db test.db |
||
55 | set big [string repeat abcdefghij 22] ;# 220 byte string |
||
56 | do_test tkt35xx-1.2.1 { |
||
57 | execsql { |
||
58 | PRAGMA auto_vacuum = 0; |
||
59 | PRAGMA page_size = 1024; |
||
60 | CREATE TABLE t3(a INTEGER PRIMARY KEY, b); |
||
61 | INSERT INTO t3 VALUES(1, $big); |
||
62 | INSERT INTO t3 VALUES(2, $big); |
||
63 | INSERT INTO t3 VALUES(3, $big); |
||
64 | INSERT INTO t3 VALUES(4, $big); |
||
65 | CREATE TABLE t4(c, d); |
||
66 | INSERT INTO t4 VALUES(5, $big); |
||
67 | INSERT INTO t4 VALUES(1, $big); |
||
68 | } |
||
69 | } {} |
||
70 | do_test tkt35xx-1.2.2 { |
||
71 | catchsql { |
||
72 | BEGIN; |
||
73 | CREATE TABLE t5(e PRIMARY KEY, f); |
||
74 | DROP TABLE t5; |
||
75 | INSERT INTO t3(a, b) SELECT c, d FROM t4; |
||
76 | } |
||
77 | } {1 {PRIMARY KEY must be unique}} |
||
78 | do_test tkt35xx-1.2.3 { |
||
79 | # Show that the transaction has not been rolled back. |
||
80 | catchsql BEGIN |
||
81 | } {1 {cannot start a transaction within a transaction}} |
||
82 | do_test tkt35xx-1.2.4 { |
||
83 | execsql { SELECT count(*) FROM t3 } |
||
84 | } {4} |
||
85 | do_test tkt35xx-1.2.5 { |
||
86 | # Before the bug was fixed, if SQLITE_DEBUG was defined an assert() |
||
87 | # would fail during the following INSERT statement. If SQLITE_DEBUG |
||
88 | # was not defined, then the statement would pass and the transaction |
||
89 | # would be committed. But, the "SELECT count(*)" in tkt35xx-1.2.6 would |
||
90 | # return 1, not 5. Data magically disappeared! |
||
91 | # |
||
92 | execsql { |
||
93 | INSERT INTO t3 VALUES(5, $big); |
||
94 | COMMIT; |
||
95 | } |
||
96 | } {} |
||
97 | do_test tkt35xx-1.2.6 { |
||
98 | execsql { SELECT count(*) FROM t3 } |
||
99 | } {5} |
||
100 | integrity_check tkt35xx-1.2.7 |
||
101 | |||
102 | finish_test |