SQLite

Check-in [74c08b8dd9]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 74c08b8dd9577d1997b4bc8147beed786150f22b
User & Date: danielk1977 2008-11-21 08:50:50.000
Context
2008-11-21
09:09
Fix the problems demonstrated in tkt35xx.test in a different way to (5936). (CVS 5938) (check-in: ddf980a501 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: 74c08b8dd9 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: faded96f36 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/tkt35xx.test.
10
11
12
13
14
15
16
17
18
19
20
21









22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39


























































#***********************************************************************
# This file implements regression tests for SQLite library.
#
# When a transaction rolls back, make sure that dirty pages in the
# page cache which are not in the rollback journal are reinitialized
# in the btree layer.
#
# $Id: tkt35xx.test,v 1.1 2008/11/21 03:23:43 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl










do_test tkt35xx-1.1 {
  execsql {
    PRAGMA auto_vacuum = 0;
    CREATE TABLE t1(a,b,c);
    CREATE INDEX i1 ON t1(c);
    INSERT INTO t1 VALUES(0, 0, zeroblob(676));
    INSERT INTO t1 VALUES(1, 1, zeroblob(676));
    DELETE FROM t1;
    BEGIN;
    INSERT INTO t1 VALUES(0, 0, zeroblob(676));
    INSERT INTO t1 VALUES(1, 1, zeroblob(676));
    ROLLBACK;
    INSERT INTO t1 VALUES(0, 0, zeroblob(676));
  }
  execsql {
    INSERT INTO t1 VALUES(1, 1, zeroblob(676));
  }
} {}

































































|




>
>
>
>
>
>
>
>
>


















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# When a transaction rolls back, make sure that dirty pages in the
# page cache which are not in the rollback journal are reinitialized
# in the btree layer.
#
# $Id: tkt35xx.test,v 1.2 2008/11/21 08:50:50 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test tkt35xx-1.1 {
  execsql {
    PRAGMA auto_vacuum = 0;
    PRAGMA page_size = 1024;
  }
} {}

# Trigger the problem using explicit rollback.
#
do_test tkt35xx-1.1 {
  execsql {
    PRAGMA auto_vacuum = 0;
    CREATE TABLE t1(a,b,c);
    CREATE INDEX i1 ON t1(c);
    INSERT INTO t1 VALUES(0, 0, zeroblob(676));
    INSERT INTO t1 VALUES(1, 1, zeroblob(676));
    DELETE FROM t1;
    BEGIN;
    INSERT INTO t1 VALUES(0, 0, zeroblob(676));
    INSERT INTO t1 VALUES(1, 1, zeroblob(676));
    ROLLBACK;
    INSERT INTO t1 VALUES(0, 0, zeroblob(676));
  }
  execsql {
    INSERT INTO t1 VALUES(1, 1, zeroblob(676));
  }
} {}

# Trigger the problem using statement rollback.
#
db close
file delete test.db
sqlite3 db test.db
set big [string repeat abcdefghij 22]    ;# 220 byte string
do_test tkt35xx-1.2.1 {
  execsql {
    PRAGMA auto_vacuum = 0;
    PRAGMA page_size = 1024;
    CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
    INSERT INTO t3 VALUES(1, $big);
    INSERT INTO t3 VALUES(2, $big);
    INSERT INTO t3 VALUES(3, $big);
    INSERT INTO t3 VALUES(4, $big);
    CREATE TABLE t4(c, d);
    INSERT INTO t4 VALUES(5, $big);
    INSERT INTO t4 VALUES(1, $big);
  }
} {}
do_test tkt35xx-1.2.2 {
  catchsql {
    BEGIN;
    CREATE TABLE t5(e PRIMARY KEY, f);
    DROP TABLE t5;
    INSERT INTO t3(a, b) SELECT c, d FROM t4;
  }
} {1 {PRIMARY KEY must be unique}}

do_test tkt35xx-1.2.3 {
  # Show that the transaction has not been rolled back.
  catchsql BEGIN
} {1 {cannot start a transaction within a transaction}}

# Before the bug was fixed, if SQLITE_DEBUG was defined an assert()
# would fail during the following INSERT statement. If SQLITE_DEBUG
# was not defined, then the statement would pass and the transaction
# would be committed. But, the "SELECT count(*)" in tkt35xx-1.2.6 would
# return 1, not 5. Data magically disappeared!
#
do_test tkt35xx-1.2.4 {
  execsql { SELECT count(*) FROM t3 }
} {4}
do_test tkt35xx-1.2.5 {
  execsql { 
    INSERT INTO t3 VALUES(5, $big);
    COMMIT;
  }
} {}
do_test tkt35xx-1.2.6 {
  execsql { SELECT count(*) FROM t3 }
} {5}

integrity_check tkt35xx-1.2.7

finish_test