3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
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
17 # $Id: tkt35xx.test,v 1.4 2009/06/05 17:09:12 drh Exp $
19 set testdir [file dirname $argv0]
20 source $testdir/tester.tcl
24 PRAGMA auto_vacuum = 0;
25 PRAGMA page_size = 1024;
29 # Trigger the problem using explicit rollback.
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));
40 INSERT INTO t1 VALUES(0, 0, zeroblob(676));
41 INSERT INTO t1 VALUES(1, 1, zeroblob(676));
43 INSERT INTO t1 VALUES(0, 0, zeroblob(676));
46 INSERT INTO t1 VALUES(1, 1, zeroblob(676));
50 # Trigger the problem using statement rollback.
55 set big [string repeat abcdefghij 22] ;# 220 byte string
56 do_test tkt35xx-1.2.1 {
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);
70 do_test tkt35xx-1.2.2 {
73 CREATE TABLE t5(e PRIMARY KEY, f);
75 INSERT INTO t3(a, b) SELECT c, d FROM t4;
77 } {1 {UNIQUE constraint failed: t3.a}}
78 do_test tkt35xx-1.2.3 {
79 # Show that the transaction has not been rolled back.
81 } {1 {cannot start a transaction within a transaction}}
82 do_test tkt35xx-1.2.4 {
83 execsql { SELECT count(*) FROM t3 }
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!
93 INSERT INTO t3 VALUES(5, $big);
97 do_test tkt35xx-1.2.6 {
98 execsql { SELECT count(*) FROM t3 }
100 integrity_check tkt35xx-1.2.7