/ Check-in [04a13fe4]
Login

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

Overview
Comment:Modify the tests in exclusive2.test to account for the fact that the pager cache may be very small by default. These tests are only valid if the entire database fitting in the cache. (CVS 4082)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 04a13fe43e61bd0dbff42c448e763078503b00bf
User & Date: danielk1977 2007-06-16 14:43:52
Context
2007-06-16
18:39
Fix a faulty assert() in the pager. (CVS 4083) check-in: 4cff47b0 user: drh tags: trunk
14:43
Modify the tests in exclusive2.test to account for the fact that the pager cache may be very small by default. These tests are only valid if the entire database fitting in the cache. (CVS 4082) check-in: 04a13fe4 user: danielk1977 tags: trunk
14:19
Add another scenario to the soak1.tcl script. (CVS 4081) check-in: 10e6822d user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/exclusive2.test.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
63
64
65
66
67
68
69





70
71
72
73
74
75
76
..
78
79
80
81
82
83
84









85
86
87
88
89
90
91
...
127
128
129
130
131
132
133




134
135
136
137
138
139
140
...
144
145
146
147
148
149
150









151
152
153
154
155
156
157
#    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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: exclusive2.test,v 1.5 2007/04/25 12:06:59 drh Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
................................................................................
#        is still the same. This is because it uses the in-memory cache.
#        It can't tell the db has changed because we reset the change-counter.
# 9:     Increment the change-counter.
# 10:    Ensure that the first connection now sees the updated database. It
#        sees the change-counter has been incremented and discards the 
#        invalid in-memory cache.
#





do_test exclusive2-1.1 {
  execsql {
    BEGIN;
    CREATE TABLE t1(a, b);
    INSERT INTO t1(a) VALUES(randstr(10, 400));
    INSERT INTO t1(a) VALUES(randstr(10, 400));
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
................................................................................
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    COMMIT;
    SELECT count(*) FROM t1;
  }
} {64}









do_test exclusive2-1.2 {
  set ::sig [t1sig]
  pagerChangeCounter test.db
} {1}
do_test exclusive2-1.3 {
  t1sig
} $::sig
................................................................................
#        still works. It should be accessing the in-memory cache.
# 5-6:   Modify the dataase change-counter. Connection 1 still works
#        entirely from in-memory cache, because it doesn't check the
#        change-counter.
# 7-8    Set the locking-mode back to normal. After the db is unlocked,
#        SQLite detects the modified change-counter and discards the
#        in-memory cache. Then it finds the corruption caused in step 4....




#
do_test exclusive2-2.1 {
  execsql {PRAGMA locking_mode = exclusive;}
  execsql {
    BEGIN;
    DELETE FROM t1;
    INSERT INTO t1(a) VALUES(randstr(10, 400));
................................................................................
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    COMMIT;
    SELECT count(*) FROM t1;
  }
} {64}









do_test exclusive2-2.2 {
  set ::sig [t1sig]
  pagerChangeCounter test.db
} {3}
do_test exclusive2-2.3 {
  t1sig
} $::sig







|







 







>
>
>
>
>







 







>
>
>
>
>
>
>
>
>







 







>
>
>
>







 







>
>
>
>
>
>
>
>
>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
..
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#    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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# $Id: exclusive2.test,v 1.6 2007/06/16 14:43:52 danielk1977 Exp $

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

ifcapable {!pager_pragmas} {
  finish_test
  return
................................................................................
#        is still the same. This is because it uses the in-memory cache.
#        It can't tell the db has changed because we reset the change-counter.
# 9:     Increment the change-counter.
# 10:    Ensure that the first connection now sees the updated database. It
#        sees the change-counter has been incremented and discards the 
#        invalid in-memory cache.
#
# This will only work if the database cache is large enough to hold 
# the entire database. In the case of 1024 byte pages, this means
# the cache size must be at least 17. Otherwise, some pages will be
# loaded from the database file in step 8.
#
do_test exclusive2-1.1 {
  execsql {
    BEGIN;
    CREATE TABLE t1(a, b);
    INSERT INTO t1(a) VALUES(randstr(10, 400));
    INSERT INTO t1(a) VALUES(randstr(10, 400));
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
................................................................................
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    COMMIT;
    SELECT count(*) FROM t1;
  }
} {64}
do_test exclusive2-1.2.1 {
  # Make sure the pager cache is large enough to store the 
  # entire database.
  set nPage [expr [file size test.db]/1024]
  if {$::SQLITE_DEFAULT_CACHE_SIZE < $nPage} {
    execsql "PRAGMA cache_size = $nPage"
  }
  expr {[execsql {PRAGMA cache_size}] >= $nPage}
} {1}
do_test exclusive2-1.2 {
  set ::sig [t1sig]
  pagerChangeCounter test.db
} {1}
do_test exclusive2-1.3 {
  t1sig
} $::sig
................................................................................
#        still works. It should be accessing the in-memory cache.
# 5-6:   Modify the dataase change-counter. Connection 1 still works
#        entirely from in-memory cache, because it doesn't check the
#        change-counter.
# 7-8    Set the locking-mode back to normal. After the db is unlocked,
#        SQLite detects the modified change-counter and discards the
#        in-memory cache. Then it finds the corruption caused in step 4....
#
# As above, this test is only applicable if the pager cache is
# large enough to hold the entire database. With 1024 byte pages,
# this means 19 pages.
#
do_test exclusive2-2.1 {
  execsql {PRAGMA locking_mode = exclusive;}
  execsql {
    BEGIN;
    DELETE FROM t1;
    INSERT INTO t1(a) VALUES(randstr(10, 400));
................................................................................
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;
    COMMIT;
    SELECT count(*) FROM t1;
  }
} {64}
do_test exclusive2-2.2.1 {
  # Make sure the pager cache is large enough to store the 
  # entire database.
  set nPage [expr [file size test.db]/1024]
  if {$::SQLITE_DEFAULT_CACHE_SIZE < $nPage} {
    execsql "PRAGMA cache_size = $nPage"
  }
  expr {[execsql {PRAGMA cache_size}] >= $nPage}
} {1}
do_test exclusive2-2.2 {
  set ::sig [t1sig]
  pagerChangeCounter test.db
} {3}
do_test exclusive2-2.3 {
  t1sig
} $::sig