/ Check-in [74c08b8d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add another test case to tkt35xx.test showing that a statement rollback can also trigger the problem. (CVS 5937)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:74c08b8dd9577d1997b4bc8147beed786150f22b
User & Date: danielk1977 2008-11-21 08:50:50
Context
2008-11-21
09:09
Fix the problems demonstrated in tkt35xx.test in a different way to (5936). (CVS 5938) check-in: ddf980a5 user: danielk1977 tags: trunk
08:50
Add another test case to tkt35xx.test showing that a statement rollback can also trigger the problem. (CVS 5937) check-in: 74c08b8d user: danielk1977 tags: trunk
03:23
On a ROLLBACK, if there page cache entries which are dirty but not in the rollback journal, make sure they get reinitialized in the btree layer. (CVS 5936) check-in: faded96f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/tkt35xx.test.

    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # When a transaction rolls back, make sure that dirty pages in the
    14     14   # page cache which are not in the rollback journal are reinitialized
    15     15   # in the btree layer.
    16     16   #
    17         -# $Id: tkt35xx.test,v 1.1 2008/11/21 03:23:43 drh Exp $
           17  +# $Id: tkt35xx.test,v 1.2 2008/11/21 08:50:50 danielk1977 Exp $
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     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  +#
    22     31   do_test tkt35xx-1.1 {
    23     32     execsql {
    24     33       PRAGMA auto_vacuum = 0;
    25     34       CREATE TABLE t1(a,b,c);
    26     35       CREATE INDEX i1 ON t1(c);
    27     36       INSERT INTO t1 VALUES(0, 0, zeroblob(676));
    28     37       INSERT INTO t1 VALUES(1, 1, zeroblob(676));
................................................................................
    33     42       ROLLBACK;
    34     43       INSERT INTO t1 VALUES(0, 0, zeroblob(676));
    35     44     }
    36     45     execsql {
    37     46       INSERT INTO t1 VALUES(1, 1, zeroblob(676));
    38     47     }
    39     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  +
           79  +do_test tkt35xx-1.2.3 {
           80  +  # Show that the transaction has not been rolled back.
           81  +  catchsql BEGIN
           82  +} {1 {cannot start a transaction within a transaction}}
           83  +
           84  +# Before the bug was fixed, if SQLITE_DEBUG was defined an assert()
           85  +# would fail during the following INSERT statement. If SQLITE_DEBUG
           86  +# was not defined, then the statement would pass and the transaction
           87  +# would be committed. But, the "SELECT count(*)" in tkt35xx-1.2.6 would
           88  +# return 1, not 5. Data magically disappeared!
           89  +#
           90  +do_test tkt35xx-1.2.4 {
           91  +  execsql { SELECT count(*) FROM t3 }
           92  +} {4}
           93  +do_test tkt35xx-1.2.5 {
           94  +  execsql { 
           95  +    INSERT INTO t3 VALUES(5, $big);
           96  +    COMMIT;
           97  +  }
           98  +} {}
           99  +do_test tkt35xx-1.2.6 {
          100  +  execsql { SELECT count(*) FROM t3 }
          101  +} {5}
          102  +
          103  +integrity_check tkt35xx-1.2.7
          104  +
          105  +finish_test
          106  +