| OLD | NEW |
| 1 # 2007 March 24 | 1 # 2007 March 24 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 execsql {SELECT count(*), md5sum(a) FROM t1} $db | 76 execsql {SELECT count(*), md5sum(a) FROM t1} $db |
| 77 } | 77 } |
| 78 do_test exclusive2-1.0 { | 78 do_test exclusive2-1.0 { |
| 79 readPagerChangeCounter test.db | 79 readPagerChangeCounter test.db |
| 80 } {0} | 80 } {0} |
| 81 | 81 |
| 82 #----------------------------------------------------------------------- | 82 #----------------------------------------------------------------------- |
| 83 # The following tests - exclusive2-1.X - check that: | 83 # The following tests - exclusive2-1.X - check that: |
| 84 # | 84 # |
| 85 # 1-3: Build a database with connection 1, calculate a signature. | 85 # 1-3: Build a database with connection 1, calculate a signature. |
| 86 # 4-9: Modify the database using a second connection in a way that | 86 # 4-7: Modify the database using a second connection in a way that |
| 87 # does not modify the freelist, then reset the pager change-counter | 87 # does not modify the freelist, then reset the pager change-counter |
| 88 # to the value it had before the modifications. | 88 # to the value it had before the modifications. |
| 89 # 8: Check that using the first connection, the database signature | 89 # 8: Check that using the first connection, the database signature |
| 90 # is still the same. This is because it uses the in-memory cache. | 90 # is still the same. This is because it uses the in-memory cache. |
| 91 # It can't tell the db has changed because we reset the change-counter. | 91 # It can't tell the db has changed because we reset the change-counter. |
| 92 # 9: Increment the change-counter. | 92 # 9: Increment the change-counter. |
| 93 # 10: Ensure that the first connection now sees the updated database. It | 93 # 10: Ensure that the first connection now sees the updated database. It |
| 94 # sees the change-counter has been incremented and discards the | 94 # sees the change-counter has been incremented and discards the |
| 95 # invalid in-memory cache. | 95 # invalid in-memory cache. |
| 96 # | 96 # |
| 97 # This will only work if the database cache is large enough to hold | 97 # This will only work if the database cache is large enough to hold |
| 98 # the entire database. In the case of 1024 byte pages, this means | 98 # the entire database. In the case of 1024 byte pages, this means |
| 99 # the cache size must be at least 17. Otherwise, some pages will be | 99 # the cache size must be at least 17. Otherwise, some pages will be |
| 100 # loaded from the database file in step 8. | 100 # loaded from the database file in step 8. |
| 101 # | 101 # |
| 102 # For similar reasons, this test does not work with the memsubsys1 permutation. |
| 103 # Permutation memsubsys1 configures the pcache subsystem to use a static |
| 104 # allocation of 24 pages (shared between all pagers). This is not enough for |
| 105 # this test. |
| 106 # |
| 102 do_test exclusive2-1.1 { | 107 do_test exclusive2-1.1 { |
| 103 execsql { | 108 execsql { |
| 104 BEGIN; | 109 BEGIN; |
| 105 CREATE TABLE t1(a, b); | 110 CREATE TABLE t1(a, b); |
| 106 INSERT INTO t1(a) VALUES(randstr(10, 400)); | 111 INSERT INTO t1(a) VALUES(randstr(10, 400)); |
| 107 INSERT INTO t1(a) VALUES(randstr(10, 400)); | 112 INSERT INTO t1(a) VALUES(randstr(10, 400)); |
| 108 INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1; | 113 INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1; |
| 109 INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1; | 114 INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1; |
| 110 INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1; | 115 INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1; |
| 111 INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1; | 116 INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 139 UPDATE t1 SET b=a, a=NULL; | 144 UPDATE t1 SET b=a, a=NULL; |
| 140 } db2 | 145 } db2 |
| 141 expr {[t1sig db2] eq $::sig} | 146 expr {[t1sig db2] eq $::sig} |
| 142 } 0 | 147 } 0 |
| 143 do_test exclusive2-1.6 { | 148 do_test exclusive2-1.6 { |
| 144 readPagerChangeCounter test.db | 149 readPagerChangeCounter test.db |
| 145 } {2} | 150 } {2} |
| 146 do_test exclusive2-1.7 { | 151 do_test exclusive2-1.7 { |
| 147 pagerChangeCounter test.db 1 | 152 pagerChangeCounter test.db 1 |
| 148 } {1} | 153 } {1} |
| 149 do_test exclusive2-1.9 { | 154 if {[permutation] != "memsubsys1"} { |
| 150 t1sig | 155 do_test exclusive2-1.9 { |
| 151 expr {[t1sig] eq $::sig} | 156 t1sig |
| 152 } {1} | 157 expr {[t1sig] eq $::sig} |
| 158 } {1} |
| 159 } |
| 153 do_test exclusive2-1.10 { | 160 do_test exclusive2-1.10 { |
| 154 pagerChangeCounter test.db 2 | 161 pagerChangeCounter test.db 2 |
| 155 } {2} | 162 } {2} |
| 156 do_test exclusive2-1.11 { | 163 do_test exclusive2-1.11 { |
| 157 expr {[t1sig] eq $::sig} | 164 expr {[t1sig] eq $::sig} |
| 158 } {0} | 165 } {0} |
| 159 | 166 |
| 160 #-------------------------------------------------------------------- | 167 #-------------------------------------------------------------------- |
| 161 # These tests - exclusive2-2.X - are similar to exclusive2-1.X, | 168 # These tests - exclusive2-2.X - are similar to exclusive2-1.X, |
| 162 # except that they are run with locking_mode=EXCLUSIVE. | 169 # except that they are run with locking_mode=EXCLUSIVE. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 INSERT INTO t1 VALUES(randstr(10, 400)); | 299 INSERT INTO t1 VALUES(randstr(10, 400)); |
| 293 } | 300 } |
| 294 readPagerChangeCounter test.db | 301 readPagerChangeCounter test.db |
| 295 } {4} | 302 } {4} |
| 296 do_test exclusive2-3.6 { | 303 do_test exclusive2-3.6 { |
| 297 execsql { | 304 execsql { |
| 298 INSERT INTO t1 VALUES(randstr(10, 400)); | 305 INSERT INTO t1 VALUES(randstr(10, 400)); |
| 299 } | 306 } |
| 300 readPagerChangeCounter test.db | 307 readPagerChangeCounter test.db |
| 301 } {5} | 308 } {5} |
| 302 sqlite3_soft_heap_limit $soft_limit | 309 sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) |
| 303 | 310 |
| 304 finish_test | 311 finish_test |
| OLD | NEW |