/ Check-in [e06a968a]
Login

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

Overview
Comment:Add extra crash test cases that stress the savepoint mechanism to savepoint4.test. Currently, these tests are causing database corruption which (obviously) needs to be fixed. (CVS 6044)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e06a968aa5b17ce12ea179b36a99ad74d274fd2c
User & Date: danielk1977 2008-12-19 18:45:53
Context
2008-12-20
02:06
Enhanced analysis of OR terms in a WHERE clause. Another step toward being able to use indices with OR-connected WHERE clause terms. (CVS 6045) check-in: c3f7aa01 user: drh tags: trunk
2008-12-19
18:45
Add extra crash test cases that stress the savepoint mechanism to savepoint4.test. Currently, these tests are causing database corruption which (obviously) needs to be fixed. (CVS 6044) check-in: e06a968a user: danielk1977 tags: trunk
16:31
Add some crash-tests for savepoint. Fix a bug revealed by these tests. (CVS 6043) check-in: 6f36c166 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/savepoint4.test.

5
6
7
8
9
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
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: savepoint4.test,v 1.1 2008/12/19 16:31:12 danielk1977 Exp $

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


proc signature {} {
  return [db eval {SELECT count(*), md5sum(x) FROM t3}]
}



expr srand(0)

do_test savepoint4-1 {
  execsql {
    PRAGMA cache_size=10;
    BEGIN;
    CREATE TABLE t3(x TEXT);
    INSERT INTO t3 VALUES(randstr(10,400));
    INSERT INTO t3 VALUES(randstr(10,400));
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    COMMIT;
    SELECT count(*) FROM t3;
  }
} {1024}


unset -nocomplain ::sig

for {set ii 1} {$ii<25} {incr ii} {
  set ::sig [signature]

  set crashed 1
  for {set iDelay 1} {$crashed} {incr iDelay} {

    do_test savepoint4-$ii.1.$iDelay {
      set ret [crashsql -delay $iDelay -file test.db-journal {
        PRAGMA cache_size = 20;
        SAVEPOINT one;
          DELETE FROM t3 WHERE random()%2==0;
          SAVEPOINT two;
            INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;
           ROLLBACK TO two;
            UPDATE t3 SET x = randstr(10, 400) WHERE random()%10;
          RELEASE two;
        ROLLBACK TO one;

      }]
      signature
    } $::sig

    set crashed [lindex $ret 0]
    integrity_check savepoint4-$ii.1.$iDelay.integrity
  }









  do_test savepoint4-$ii.2 {
    execsql {








































































      DELETE FROM t3 WHERE random()%10==0;
      INSERT INTO t3 SELECT randstr(10,10)||x FROM t3 WHERE random()%9==0;
    }
  } {}
}

finish_test








|






|

>
>







|
|
|
|
|
|
|
|
|
|
|
|

|






|


<
|
>
|



|

|

|


>



>

|


>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|






5
6
7
8
9
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# $Id: savepoint4.test,v 1.2 2008/12/19 18:45:53 danielk1977 Exp $

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


proc signature {} {
  return [db eval {SELECT count(*), md5sum(x) FROM t1}]
}

set ITERATIONS 3

expr srand(0)

do_test savepoint4-1 {
  execsql {
    PRAGMA cache_size=10;
    BEGIN;
    CREATE TABLE t1(x TEXT);
    INSERT INTO t1 VALUES(randstr(10,400));
    INSERT INTO t1 VALUES(randstr(10,400));
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    COMMIT;
    SELECT count(*) FROM t1;
  }
} {1024}


unset -nocomplain ::sig

for {set ii 1} {$ii<=$ITERATIONS} {incr ii} {
  set ::sig [signature]


  for {set iDelay 1 ; set crashed 1} {$crashed} {incr iDelay} {

    do_test savepoint4-1.$ii.1.$iDelay {
      set ret [crashsql -delay $iDelay -file test.db-journal {
        PRAGMA cache_size = 20;
        SAVEPOINT one;
          DELETE FROM t1 WHERE random()%2==0;
          SAVEPOINT two;
            INSERT INTO t1 SELECT randstr(10,10)||x FROM t1;
           ROLLBACK TO two;
            UPDATE t1 SET x = randstr(10, 400) WHERE random()%10;
          RELEASE two;
        ROLLBACK TO one;
        RELEASE one;
      }]
      signature
    } $::sig

    set crashed [lindex $ret 0]
    integrity_check savepoint4-1.$ii.1.$iDelay.integrity
  }

  do_test savepoint4-1.$ii.2 {
    execsql {
      DELETE FROM t1 WHERE random()%10==0;
      INSERT INTO t1 SELECT randstr(10,10)||x FROM t1 WHERE random()%9==0;
    }
  } {}
}

do_test savepoint4-2 {
  execsql {
    PRAGMA cache_size=10;
    DROP TABLE IF EXISTS t1;
    BEGIN;
    CREATE TABLE t1(x TEXT);
    CREATE INDEX i1 ON t1(x);
    INSERT INTO t1 VALUES(randstr(10,400));
    INSERT INTO t1 VALUES(randstr(10,400));
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    INSERT INTO t1 SELECT randstr(10,400) FROM t1;
    COMMIT;
    SELECT count(*) FROM t1;
  }
} {256}

for {set ii 1} {$ii<=$ITERATIONS} {incr ii} {
  set ::sig [signature]
  set file test.db-journal

  for {set iDelay 1 ; set crashed 1} {$crashed} {incr iDelay} {

    do_test savepoint4-2.$ii.1.$iDelay {

      set ret [crashsql -delay $iDelay -file $file {
        SAVEPOINT one;
          INSERT INTO t1 SELECT * FROM t1 WHERE rowid<50;
         ROLLBACK TO one;
          INSERT INTO t1 SELECT * FROM t1 WHERE rowid<50;
          SAVEPOINT two;
            DELETE FROM t1 WHERE (random()%10)==0;
            SAVEPOINT three;
              DELETE FROM t1 WHERE (random()%10)==0;
              SAVEPOINT four;
                DELETE FROM t1 WHERE (random()%10)==0;
          RELEASE two;

          SAVEPOINT three;
            UPDATE t1 SET x = x||x WHERE (rowid%12)==0;
            SAVEPOINT four;
              UPDATE t1 SET x = x||x WHERE (rowid%14)==0;
           ROLLBACK TO three;
            UPDATE t1 SET x = x||x WHERE (rowid%13)==0;
          RELEASE three;

        DELETE FROM t1 WHERE rowid > (SELECT rowid FROM t1 LIMIT 1 OFFSET 256);
        RELEASE one;
      }]

      set crashed [lindex $ret 0]
      if {$crashed} {
        signature
      } else {
        set ::sig
      }
    } $::sig

    integrity_check savepoint4-2.$ii.1.$iDelay.integrity

    if {$crashed == 0 && $file == "test.db-journal"} {
      set crashed 1
      set iDelay 0
      set file test.db
      set ::sig [signature]
    }
  }

  do_test savepoint4-2.$ii.2 {
    execsql {
      DELETE FROM t1 WHERE random()%10==0;
      INSERT INTO t1 SELECT randstr(10,10)||x FROM t1 WHERE random()%9==0;
    }
  } {}
}

finish_test