OLD | NEW |
1 # 2010 September 24 | 1 # 2010 September 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 do_test e_vacuum-1.3.1.1 { | 152 do_test e_vacuum-1.3.1.1 { |
153 create_db "PRAGMA page_size = 1024 ; PRAGMA auto_vacuum = FULL" | 153 create_db "PRAGMA page_size = 1024 ; PRAGMA auto_vacuum = FULL" |
154 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } | 154 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } |
155 } {1024 1} | 155 } {1024 1} |
156 do_test e_vacuum-1.3.1.2 { | 156 do_test e_vacuum-1.3.1.2 { |
157 execsql { PRAGMA page_size = 2048 } | 157 execsql { PRAGMA page_size = 2048 } |
158 execsql { PRAGMA auto_vacuum = NONE } | 158 execsql { PRAGMA auto_vacuum = NONE } |
159 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } | 159 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } |
160 } {1024 1} | 160 } {1024 1} |
161 | 161 |
162 # EVIDENCE-OF: R-08570-19916 However, when not in write-ahead log mode, | 162 if {![nonzero_reserved_bytes]} { |
163 # the page_size and/or auto_vacuum properties of an existing database | 163 # EVIDENCE-OF: R-08570-19916 However, when not in write-ahead log mode, |
164 # may be changed by using the page_size and/or pragma auto_vacuum | 164 # the page_size and/or auto_vacuum properties of an existing database |
165 # pragmas and then immediately VACUUMing the database. | 165 # may be changed by using the page_size and/or pragma auto_vacuum |
166 # | 166 # pragmas and then immediately VACUUMing the database. |
167 do_test e_vacuum-1.3.2.1 { | 167 # |
168 execsql { PRAGMA journal_mode = delete } | 168 do_test e_vacuum-1.3.2.1 { |
169 execsql { PRAGMA page_size = 2048 } | 169 execsql { PRAGMA journal_mode = delete } |
170 execsql { PRAGMA auto_vacuum = NONE } | 170 execsql { PRAGMA page_size = 2048 } |
171 execsql VACUUM | 171 execsql { PRAGMA auto_vacuum = NONE } |
172 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } | 172 execsql VACUUM |
173 } {2048 0} | 173 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } |
174 | 174 } {2048 0} |
175 # EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the | 175 |
176 # auto_vacuum support property can be changed using VACUUM. | 176 # EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the |
177 # | 177 # auto_vacuum support property can be changed using VACUUM. |
178 ifcapable wal { | 178 # |
179 do_test e_vacuum-1.3.3.1 { | 179 if {[wal_is_capable]} { |
180 execsql { PRAGMA journal_mode = wal } | 180 do_test e_vacuum-1.3.3.1 { |
181 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } | 181 execsql { PRAGMA journal_mode = wal } |
182 } {2048 0} | 182 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } |
183 do_test e_vacuum-1.3.3.2 { | 183 } {2048 0} |
184 execsql { PRAGMA page_size = 1024 } | 184 do_test e_vacuum-1.3.3.2 { |
185 execsql { PRAGMA auto_vacuum = FULL } | 185 execsql { PRAGMA page_size = 1024 } |
186 execsql VACUUM | 186 execsql { PRAGMA auto_vacuum = FULL } |
187 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } | 187 execsql VACUUM |
188 } {2048 1} | 188 execsql { PRAGMA page_size ; PRAGMA auto_vacuum } |
| 189 } {2048 1} |
| 190 } |
189 } | 191 } |
190 | 192 |
191 # EVIDENCE-OF: R-38001-03952 VACUUM only works on the main database. It | 193 # EVIDENCE-OF: R-55119-57913 By default, VACUUM only works only on the |
192 # is not possible to VACUUM an attached database file. | 194 # main database. |
193 forcedelete test.db2 | 195 forcedelete test.db2 |
194 create_db { PRAGMA auto_vacuum = NONE } | 196 create_db { PRAGMA auto_vacuum = NONE } |
195 do_execsql_test e_vacuum-2.1.1 { | 197 do_execsql_test e_vacuum-2.1.1 { |
196 ATTACH 'test.db2' AS aux; | 198 ATTACH 'test.db2' AS aux; |
197 PRAGMA aux.page_size = 1024; | 199 PRAGMA aux.page_size = 1024; |
198 CREATE TABLE aux.t3 AS SELECT * FROM t1; | 200 CREATE TABLE aux.t3 AS SELECT * FROM t1; |
199 DELETE FROM t3; | 201 DELETE FROM t3; |
200 } {} | 202 } {} |
201 set original_size [file size test.db2] | 203 set original_size [file size test.db2] |
202 | 204 |
203 # Try everything we can think of to get the aux database vacuumed: | 205 # Vacuuming the main database does not affect aux |
204 do_execsql_test e_vacuum-2.1.3 { VACUUM } {} | 206 do_execsql_test e_vacuum-2.1.3 { VACUUM } {} |
205 do_execsql_test e_vacuum-2.1.4 { VACUUM aux } {} | 207 do_test e_vacuum-2.1.6 { expr {[file size test.db2]==$::original_size} } 1 |
206 do_execsql_test e_vacuum-2.1.5 { VACUUM 'test.db2' } {} | |
207 | 208 |
208 # Despite our efforts, space in the aux database has not been reclaimed: | 209 # EVIDENCE-OF: R-36598-60500 Attached databases can be vacuumed by |
209 do_test e_vacuum-2.1.6 { expr {[file size test.db2]==$::original_size} } 1 | 210 # appending the appropriate schema-name to the VACUUM statement. |
| 211 do_execsql_test e_vacuum-2.1.7 { VACUUM aux; } {} |
| 212 do_test e_vacuum-2.1.8 { expr {[file size test.db2]<$::original_size} } 1 |
210 | 213 |
211 # EVIDENCE-OF: R-17495-17419 The VACUUM command may change the ROWIDs of | 214 # EVIDENCE-OF: R-17495-17419 The VACUUM command may change the ROWIDs of |
212 # entries in any tables that do not have an explicit INTEGER PRIMARY | 215 # entries in any tables that do not have an explicit INTEGER PRIMARY |
213 # KEY. | 216 # KEY. |
214 # | 217 # |
215 # Tests e_vacuum-3.1.1 - 3.1.2 demonstrate that rowids can change when | 218 # Tests e_vacuum-3.1.1 - 3.1.2 demonstrate that rowids can change when |
216 # a database is VACUUMed. Tests e_vacuum-3.1.3 - 3.1.4 show that adding | 219 # a database is VACUUMed. Tests e_vacuum-3.1.3 - 3.1.4 show that adding |
217 # an INTEGER PRIMARY KEY column to a table stops this from happening. | 220 # an INTEGER PRIMARY KEY column to a table stops this from happening. |
218 # | 221 # |
219 do_execsql_test e_vacuum-3.1.1 { | 222 do_execsql_test e_vacuum-3.1.1 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 create_db | 265 create_db |
263 do_test e_vacuum-3.2.2.1 { | 266 do_test e_vacuum-3.2.2.1 { |
264 set res "" | 267 set res "" |
265 db eval { SELECT a FROM t1 } { | 268 db eval { SELECT a FROM t1 } { |
266 if {$a == 10} { set res [catchsql VACUUM] } | 269 if {$a == 10} { set res [catchsql VACUUM] } |
267 } | 270 } |
268 set res | 271 set res |
269 } {1 {cannot VACUUM - SQL statements in progress}} | 272 } {1 {cannot VACUUM - SQL statements in progress}} |
270 | 273 |
271 | 274 |
272 # EVIDENCE-OF: R-38735-12540 As of SQLite version 3.1, an alternative to | 275 # EVIDENCE-OF: R-55138-13241 An alternative to using the VACUUM command |
273 # using the VACUUM command to reclaim space after data has been deleted | 276 # to reclaim space after data has been deleted is auto-vacuum mode, |
274 # is auto-vacuum mode, enabled using the auto_vacuum pragma. | 277 # enabled using the auto_vacuum pragma. |
275 # | 278 # |
276 do_test e_vacuum-3.3.1 { | 279 do_test e_vacuum-3.3.1 { |
277 create_db { PRAGMA auto_vacuum = FULL } | 280 create_db { PRAGMA auto_vacuum = FULL } |
278 execsql { PRAGMA auto_vacuum } | 281 execsql { PRAGMA auto_vacuum } |
279 } {1} | 282 } {1} |
280 | 283 |
281 # EVIDENCE-OF: R-64844-34873 When auto_vacuum is enabled for a database | 284 # EVIDENCE-OF: R-64844-34873 When auto_vacuum is enabled for a database |
282 # free pages may be reclaimed after deleting data, causing the file to | 285 # free pages may be reclaimed after deleting data, causing the file to |
283 # shrink, without rebuilding the entire database using VACUUM. | 286 # shrink, without rebuilding the entire database using VACUUM. |
284 # | 287 # |
285 do_test e_vacuum-3.3.2.1 { | 288 do_test e_vacuum-3.3.2.1 { |
286 create_db { PRAGMA auto_vacuum = FULL } | 289 create_db { PRAGMA auto_vacuum = FULL } |
287 execsql { | 290 execsql { |
288 DELETE FROM t1; | 291 DELETE FROM t1; |
289 DELETE FROM t2; | 292 DELETE FROM t2; |
290 } | 293 } |
291 expr {[file size test.db] / 1024} | 294 expr {[file size test.db] / 1024} |
292 } {8} | 295 } {8} |
293 do_test e_vacuum-3.3.2.2 { | 296 do_test e_vacuum-3.3.2.2 { |
294 create_db { PRAGMA auto_vacuum = INCREMENTAL } | 297 create_db { PRAGMA auto_vacuum = INCREMENTAL } |
295 execsql { | 298 execsql { |
296 DELETE FROM t1; | 299 DELETE FROM t1; |
297 DELETE FROM t2; | 300 DELETE FROM t2; |
298 PRAGMA incremental_vacuum; | 301 PRAGMA incremental_vacuum; |
299 } | 302 } |
300 expr {[file size test.db] / 1024} | 303 expr {[file size test.db] / 1024} |
301 } {8} | 304 } {8} |
302 | 305 |
303 finish_test | 306 finish_test |
OLD | NEW |