OLD | NEW |
1 # 2002 March 6 | 1 # 2002 March 6 |
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 12 matching lines...) Expand all Loading... |
23 # pragma2-2.*: Test freelist_count pragma on an attached database. | 23 # pragma2-2.*: Test freelist_count pragma on an attached database. |
24 # pragma2-3.*: Test trying to write to the freelist_count is a no-op. | 24 # pragma2-3.*: Test trying to write to the freelist_count is a no-op. |
25 # pragma2-4.*: Tests for PRAGMA cache_spill | 25 # pragma2-4.*: Tests for PRAGMA cache_spill |
26 # | 26 # |
27 | 27 |
28 ifcapable !pragma||!schema_pragmas { | 28 ifcapable !pragma||!schema_pragmas { |
29 finish_test | 29 finish_test |
30 return | 30 return |
31 } | 31 } |
32 | 32 |
| 33 test_set_config_pagecache 0 0 |
| 34 |
33 # Delete the preexisting database to avoid the special setup | 35 # Delete the preexisting database to avoid the special setup |
34 # that the "all.test" script does. | 36 # that the "all.test" script does. |
35 # | 37 # |
36 db close | 38 db close |
37 delete_file test.db test.db-journal | 39 delete_file test.db test.db-journal |
38 delete_file test3.db test3.db-journal | 40 delete_file test3.db test3.db-journal |
39 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] | 41 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] |
40 db eval {PRAGMA auto_vacuum=0} | 42 db eval {PRAGMA auto_vacuum=0} |
41 | 43 |
| 44 |
| 45 # EVIDENCE-OF: R-11211-21323 PRAGMA schema.freelist_count; Return the |
| 46 # number of unused pages in the database file. |
| 47 # |
42 do_test pragma2-1.1 { | 48 do_test pragma2-1.1 { |
43 execsql { | 49 execsql { |
44 PRAGMA freelist_count; | 50 PRAGMA freelist_count; |
45 } | 51 } |
46 } {0} | 52 } {0} |
47 do_test pragma2-1.2 { | 53 do_test pragma2-1.2 { |
48 execsql { | 54 execsql { |
49 CREATE TABLE abc(a, b, c); | 55 CREATE TABLE abc(a, b, c); |
50 PRAGMA freelist_count; | 56 PRAGMA freelist_count; |
51 } | 57 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 do_test pragma2-3.3 { | 118 do_test pragma2-3.3 { |
113 execsql { | 119 execsql { |
114 PRAGMA aux.freelist_count = 500; | 120 PRAGMA aux.freelist_count = 500; |
115 PRAGMA aux.freelist_count; | 121 PRAGMA aux.freelist_count; |
116 } | 122 } |
117 } {9 9} | 123 } {9 9} |
118 } | 124 } |
119 | 125 |
120 # Default setting of PRAGMA cache_spill is always ON | 126 # Default setting of PRAGMA cache_spill is always ON |
121 # | 127 # |
122 # EVIDENCE-OF: R-51036-62828 PRAGMA cache_spill; PRAGMA | 128 # EVIDENCE-OF: R-63549-59887 PRAGMA cache_spill; PRAGMA |
123 # cache_spill=boolean; | 129 # cache_spill=boolean; PRAGMA schema.cache_spill=N; |
124 # | 130 # |
125 # EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default | 131 # EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default |
126 # | 132 # |
127 db close | 133 db close |
128 delete_file test.db test.db-journal | 134 delete_file test.db test.db-journal |
129 delete_file test2.db test2.db-journal | 135 delete_file test2.db test2.db-journal |
130 sqlite3 db test.db | 136 sqlite3 db test.db |
131 do_execsql_test pragma2-4.1 { | 137 do_execsql_test pragma2-4.1 { |
| 138 PRAGMA main.cache_size=2000; |
| 139 PRAGMA temp.cache_size=2000; |
132 PRAGMA cache_spill; | 140 PRAGMA cache_spill; |
133 PRAGMA main.cache_spill; | 141 PRAGMA main.cache_spill; |
134 PRAGMA temp.cache_spill; | 142 PRAGMA temp.cache_spill; |
135 } {1 1 1} | 143 } {2000 2000 2000} |
136 do_execsql_test pragma2-4.2 { | 144 do_execsql_test pragma2-4.2 { |
137 PRAGMA cache_spill=OFF; | 145 PRAGMA cache_spill=OFF; |
138 PRAGMA cache_spill; | 146 PRAGMA cache_spill; |
139 PRAGMA main.cache_spill; | 147 PRAGMA main.cache_spill; |
140 PRAGMA temp.cache_spill; | 148 PRAGMA temp.cache_spill; |
141 } {0 0 0} | 149 } {0 0 0} |
142 do_execsql_test pragma2-4.3 { | 150 do_execsql_test pragma2-4.3 { |
143 PRAGMA page_size=1024; | 151 PRAGMA page_size=1024; |
144 PRAGMA cache_size=50; | 152 PRAGMA cache_size=50; |
145 BEGIN; | 153 BEGIN; |
(...skipping 19 matching lines...) Expand all Loading... |
165 # the ability of the pager to spill dirty cache pages to the database | 173 # the ability of the pager to spill dirty cache pages to the database |
166 # file in the middle of a transaction. | 174 # file in the middle of a transaction. |
167 # | 175 # |
168 do_test pragma2-4.4 { | 176 do_test pragma2-4.4 { |
169 db eval { | 177 db eval { |
170 BEGIN; | 178 BEGIN; |
171 UPDATE t1 SET c=c+1; | 179 UPDATE t1 SET c=c+1; |
172 PRAGMA lock_status; | 180 PRAGMA lock_status; |
173 } | 181 } |
174 } {main exclusive temp unknown} ;# EXCLUSIVE lock due to cache spill | 182 } {main exclusive temp unknown} ;# EXCLUSIVE lock due to cache spill |
175 do_test pragma2-4.5 { | 183 do_test pragma2-4.5.1 { |
176 db eval { | 184 db eval { |
177 COMMIT; | 185 ROLLBACK; |
178 PRAGMA cache_spill=OFF; | 186 PRAGMA cache_spill=OFF; |
| 187 PRAGMA Cache_Spill; |
179 BEGIN; | 188 BEGIN; |
180 UPDATE t1 SET c=c-1; | 189 UPDATE t1 SET c=c+1; |
181 PRAGMA lock_status; | 190 PRAGMA lock_status; |
182 } | 191 } |
183 } {main reserved temp unknown} ;# No cache spill, so no exclusive lock | 192 } {0 main reserved temp unknown} ;# No cache spill, so no exclusive lock |
| 193 |
| 194 |
| 195 # EVIDENCE-OF: R-34657-61226 The "PRAGMA cache_spill=N" form of this |
| 196 # pragma sets a minimum cache size threshold required for spilling to |
| 197 # occur. |
| 198 do_test pragma2-4.5.2 { |
| 199 db eval { |
| 200 ROLLBACK; |
| 201 PRAGMA cache_spill=100000; |
| 202 PRAGMA cache_spill; |
| 203 BEGIN; |
| 204 UPDATE t1 SET c=c+1; |
| 205 PRAGMA lock_status; |
| 206 } |
| 207 } {100000 main reserved temp unknown} ;# Big spill threshold -> no excl lock |
| 208 ifcapable !memorymanage { |
| 209 do_test pragma2-4.5.3 { |
| 210 db eval { |
| 211 ROLLBACK; |
| 212 PRAGMA cache_spill=25; |
| 213 PRAGMA main.cache_spill; |
| 214 BEGIN; |
| 215 UPDATE t1 SET c=c+1; |
| 216 PRAGMA lock_status; |
| 217 } |
| 218 } {50 main exclusive temp unknown} ;# Small cache spill -> exclusive lock |
| 219 do_test pragma2-4.5.4 { |
| 220 db eval { |
| 221 ROLLBACK; |
| 222 PRAGMA cache_spill(-25); |
| 223 PRAGMA main.cache_spill; |
| 224 BEGIN; |
| 225 UPDATE t1 SET c=c+1; |
| 226 PRAGMA lock_status; |
| 227 } |
| 228 } {50 main exclusive temp unknown} ;# Small cache spill -> exclusive lock |
| 229 } |
| 230 |
184 | 231 |
185 # Verify that newly attached databases inherit the cache_spill=OFF | 232 # Verify that newly attached databases inherit the cache_spill=OFF |
186 # setting. | 233 # setting. |
187 # | 234 # |
188 do_execsql_test pragma2-4.6 { | 235 do_execsql_test pragma2-4.6 { |
189 COMMIT; | 236 ROLLBACK; |
| 237 PRAGMA cache_spill=OFF; |
190 ATTACH 'test2.db' AS aux1; | 238 ATTACH 'test2.db' AS aux1; |
191 PRAGMA aux1.cache_size=50; | 239 PRAGMA aux1.cache_size=50; |
192 BEGIN; | 240 BEGIN; |
193 UPDATE t2 SET c=c+1; | 241 UPDATE t2 SET c=c+1; |
194 PRAGMA lock_status; | 242 PRAGMA lock_status; |
195 } {main unlocked temp unknown aux1 reserved} | 243 } {main unlocked temp unknown aux1 reserved} |
196 do_execsql_test pragma2-4.7 { | 244 do_execsql_test pragma2-4.7 { |
197 COMMIT; | 245 COMMIT; |
198 } | 246 } |
199 sqlite3_release_memory | 247 sqlite3_release_memory |
200 do_execsql_test pragma2-4.8 { | 248 do_execsql_test pragma2-4.8 { |
201 PRAGMA cache_spill=ON; -- Applies to all databases | 249 PRAGMA cache_spill=ON; -- Applies to all databases |
202 BEGIN; | 250 BEGIN; |
203 UPDATE t2 SET c=c-1; | 251 UPDATE t2 SET c=c-1; |
204 PRAGMA lock_status; | 252 PRAGMA lock_status; |
205 } {main unlocked temp unknown aux1 exclusive} | 253 } {main unlocked temp unknown aux1 exclusive} |
| 254 db close |
| 255 forcedelete test.db |
| 256 sqlite3 db test.db |
| 257 |
| 258 breakpoint |
| 259 do_execsql_test pragma2-5.1 { |
| 260 PRAGMA page_size=16384; |
| 261 CREATE TABLE t1(x); |
| 262 PRAGMA cache_size=2; |
| 263 PRAGMA cache_spill=YES; |
| 264 PRAGMA cache_spill; |
| 265 } {2} |
| 266 do_execsql_test pragma2-5.2 { |
| 267 PRAGMA cache_spill=NO; |
| 268 PRAGMA cache_spill; |
| 269 } {0} |
| 270 do_execsql_test pragma2-5.3 { |
| 271 PRAGMA cache_spill(-51); |
| 272 PRAGMA cache_spill; |
| 273 } {3} |
206 | 274 |
207 | 275 test_restore_config_pagecache |
208 finish_test | 276 finish_test |
OLD | NEW |