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 #*********************************************************************** |
11 # | 11 # |
12 # $Id: cache.test,v 1.4 2007/08/22 02:56:44 drh Exp $ | 12 # $Id: cache.test,v 1.4 2007/08/22 02:56:44 drh Exp $ |
13 | 13 |
14 set testdir [file dirname $argv0] | 14 set testdir [file dirname $argv0] |
15 source $testdir/tester.tcl | 15 source $testdir/tester.tcl |
16 | 16 |
17 ifcapable {!pager_pragmas} { | 17 ifcapable !pager_pragmas||!compound { |
18 finish_test | 18 finish_test |
19 return | 19 return |
20 } | 20 } |
21 sqlite3_soft_heap_limit 0 | 21 sqlite3_soft_heap_limit 0 |
22 | 22 |
23 proc pager_cache_size {db} { | 23 proc pager_cache_size {db} { |
24 set bt [btree_from_db $db] | 24 set bt [btree_from_db $db] |
25 db_enter $db | 25 db_enter $db |
26 array set stats [btree_pager_stats $bt] | 26 array set stats [btree_pager_stats $bt] |
27 db_leave $db | 27 db_leave $db |
(...skipping 11 matching lines...) Expand all Loading... |
39 INSERT INTO abc VALUES(1, 2, 3); | 39 INSERT INTO abc VALUES(1, 2, 3); |
40 } | 40 } |
41 pager_cache_size db | 41 pager_cache_size db |
42 } {2} | 42 } {2} |
43 | 43 |
44 # At one point, repeatedly locking and unlocking the cache was causing | 44 # At one point, repeatedly locking and unlocking the cache was causing |
45 # a resource leak of one page per repetition. The page wasn't actually | 45 # a resource leak of one page per repetition. The page wasn't actually |
46 # leaked, but would not be reused until the pager-cache was full (i.e. | 46 # leaked, but would not be reused until the pager-cache was full (i.e. |
47 # 2000 pages by default). | 47 # 2000 pages by default). |
48 # | 48 # |
49 # This tests that once the pager-cache is initialised, it can be locked | 49 # This tests that once the pager-cache is initialized, it can be locked |
50 # and unlocked repeatedly without internally allocating any new pages. | 50 # and unlocked repeatedly without internally allocating any new pages. |
51 # | 51 # |
52 set cache_size [pager_cache_size db] | 52 set cache_size [pager_cache_size db] |
53 for {set ii 0} {$ii < 10} {incr ii} { | 53 for {set ii 0} {$ii < 10} {incr ii} { |
54 do_test cache-1.3.$ii { | 54 do_test cache-1.3.$ii { |
55 execsql {SELECT * FROM abc} | 55 execsql {SELECT * FROM abc} |
56 pager_cache_size db | 56 pager_cache_size db |
57 } $::cache_size | 57 } $::cache_size |
58 } | 58 } |
59 | 59 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 do_execsql_test cache-2.4.5 COMMIT | 131 do_execsql_test cache-2.4.5 COMMIT |
132 | 132 |
133 do_test cache-2.4.6 { pager_cache_size db } 0 | 133 do_test cache-2.4.6 { pager_cache_size db } 0 |
134 do_execsql_test cache-2.4.7 { | 134 do_execsql_test cache-2.4.7 { |
135 SELECT * FROM t1 UNION SELECT * FROM t2; | 135 SELECT * FROM t1 UNION SELECT * FROM t2; |
136 } {1 2 i j x y} | 136 } {1 2 i j x y} |
137 do_test cache-2.4.8 { pager_cache_size db } 0 | 137 do_test cache-2.4.8 { pager_cache_size db } 0 |
138 | 138 |
139 sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) | 139 sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) |
140 finish_test | 140 finish_test |
OLD | NEW |