Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Extra tests for incremental vacuum. (CVS 3879) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
40ba6493e9e8ba135552a2a0943ab499 |
User & Date: | danielk1977 2007-04-27 07:55:38.000 |
Context
2007-04-27
| ||
17:16 | Make sure sqlite3_value_bytes() does not reformat the content after a call to sqlite3_value_blob(). Add documentation to explain this hazard. Add many new tests. Ticket #2321. (CVS 3880) (check-in: e92bd97a37 user: drh tags: trunk) | |
07:55 | Extra tests for incremental vacuum. (CVS 3879) (check-in: 40ba6493e9 user: danielk1977 tags: trunk) | |
07:05 | Modifications to btree integrity check so that it can be run inside a transaction after an incr vacuum. (CVS 3878) (check-in: 4d4180d647 user: danielk1977 tags: trunk) | |
Changes
Changes to test/incrvacuum.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2007 April 26 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # 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. The # focus of this file is testing the incremental vacuum feature. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2007 April 26 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # 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. The # focus of this file is testing the incremental vacuum feature. # # $Id: incrvacuum.test,v 1.3 2007/04/27 07:55:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If this build of the library does not support auto-vacuum, omit this # whole file. ifcapable {!autovacuum || !pragma} { |
︙ | ︙ | |||
222 223 224 225 226 227 228 | expr {[file size test.db] / 1024} } {6} do_test incrvacuum-5.2.4 { execsql { SELECT * FROM tbl2; } } {{a nice string}} | > > > > > | > > > > > > > > > > | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | expr {[file size test.db] / 1024} } {6} do_test incrvacuum-5.2.4 { execsql { SELECT * FROM tbl2; } } {{a nice string}} do_test incrvacuum-5.2.5 { execsql { DROP TABLE tbl1; DROP TABLE tbl2; INCREMENTAL VACUUM; } expr {[file size test.db] / 1024} } {1} # Test cases incrvacuum-5.3.* use the following list as input data. # Two new databases are opened, one with incremental vacuum enabled, # the other with no auto-vacuum completely disabled. After executing # each element of the following list on both databases, test that # the integrity-check passes and the contents of each are identical. # set TestScriptList [list { BEGIN; CREATE TABLE t1(a, b); CREATE TABLE t2(a, b); CREATE INDEX t1_i ON t1(a); CREATE INDEX t2_i ON t2(a); } { |
︙ | ︙ | |||
248 249 250 251 252 253 254 | CREATE TABLE t3(a, b); INSERT INTO t3 SELECT * FROM t2; DROP TABLE t2; INCREMENTAL VACUUM; } { CREATE INDEX t3_i ON t3(a); COMMIT; | | > > > > > > > | < < | > > | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | CREATE TABLE t3(a, b); INSERT INTO t3 SELECT * FROM t2; DROP TABLE t2; INCREMENTAL VACUUM; } { CREATE INDEX t3_i ON t3(a); COMMIT; } { BEGIN; DROP INDEX t3_i; INCREMENTAL VACUUM; INSERT INTO t3 VALUES('hello', 'world'); ROLLBACK; } { INSERT INTO t3 VALUES('hello', 'world'); } ] # Compare the contents of databases $A and $B. # proc compare_dbs {A B tname} { set tbl_list [execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table' } $A] do_test ${tname}.1 [subst { execsql { |
︙ | ︙ | |||
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | execsql "SELECT * FROM $tbl" $B }] $control } } set ::str1 [string repeat abcdefghij 130] set ::str2 [string repeat 1234567890 105] sqlite3 db1 test1.db sqlite3 db2 test2.db execsql { PRAGMA auto_vacuum = 'none' } db1 execsql { PRAGMA auto_vacuum = 'incremental' } db2 set tn 1 foreach sql $::TestScriptList { execsql $sql db1 execsql $sql db2 compare_dbs db1 db2 incrvacuum-5.3.${tn} | > > | | > > | < > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | > > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > | > > > > | | > > > | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | execsql "SELECT * FROM $tbl" $B }] $control } } set ::str1 [string repeat abcdefghij 130] set ::str2 [string repeat 1234567890 105] file delete -force test1.db test1.db-journal test2.db test2.db-journal sqlite3 db1 test1.db sqlite3 db2 test2.db execsql { PRAGMA auto_vacuum = 'none' } db1 execsql { PRAGMA auto_vacuum = 'incremental' } db2 set tn 1 foreach sql $::TestScriptList { execsql $sql db1 execsql $sql db2 compare_dbs db1 db2 incrvacuum-5.3.${tn} do_test incrvacuum-5.3.${tn}.integrity1 { execsql { PRAGMA integrity_check; } db1 } {ok} do_test incrvacuum-5.3.${tn}.integrity2 { execsql { PRAGMA integrity_check; } db2 } {ok} incr tn } db1 close db2 close # # End of test cases 5.3.* #--------------------------------------------------------------------- # The following tests - incrvacuum-6.* - test running incremental # vacuum while another statement (a read) is being executed. # for {set jj 0} {$jj < 10} {incr jj} { # Build some test data. Two tables are created in an empty # database. tbl1 data is a contiguous block starting at page 5 (pages # 3 and 4 are the table roots). tbl2 is a contiguous block starting # right after tbl1. # # Then drop tbl1 so that when an incr vacuum is run the pages # of tbl2 have to be moved to fill the gap. # do_test incrvacuum-6.${jj}.1 { execsql { DROP TABLE IF EXISTS tbl1; DROP TABLE IF EXISTS tbl2; INCREMENTAL VACUUM; CREATE TABLE tbl1(a, b); CREATE TABLE tbl2(a, b); BEGIN; } for {set ii 0} {$ii < 1000} {incr ii} { db eval {INSERT INTO tbl1 VALUES($ii, $ii || $ii)} } execsql { INSERT INTO tbl2 SELECT * FROM tbl1; COMMIT; DROP TABLE tbl1; } expr {[file size test.db] / 1024} } {36} # Run a linear scan query on tbl2. After reading ($jj*100) rows, # run the incremental vacuum to shrink the database. # do_test incrvacuum-6.${jj}.2 { set ::nRow 0 db eval {SELECT a FROM tbl2} {} { if {$a == [expr $jj*100]} { db eval {INCREMENTAL VACUUM} } incr ::nRow } list [expr {[file size test.db] / 1024}] $nRow } {19 1000} } #--------------------------------------------------------------------- # This test - incrvacuum-7.* - is to check that the database can be # written in the middle of an incremental vacuum. # set ::iWrite 1 while 1 { do_test incrvacuum-7.${::iWrite}.1 { execsql { DROP TABLE IF EXISTS tbl1; DROP TABLE IF EXISTS tbl2; INCREMENTAL VACUUM; CREATE TABLE tbl1(a, b); CREATE TABLE tbl2(a, b); BEGIN; } for {set ii 0} {$ii < 1000} {incr ii} { db eval {INSERT INTO tbl1 VALUES($ii, $ii || $ii)} } execsql { INSERT INTO tbl2 SELECT * FROM tbl1; COMMIT; DROP TABLE tbl1; } expr {[file size test.db] / 1024} } {36} do_test incrvacuum-7.${::iWrite}.2 { set ::nRow 0 db eval {INCREMENTAL VACUUM} { incr ::nRow if {$::nRow == $::iWrite} { db eval { CREATE TABLE tbl1(a, b); INSERT INTO tbl1 VALUES('hello', 'world'); } } } list [expr {[file size test.db] / 1024}] } {20} do_test incrvacuum-7.${::iWrite}.3 { execsql { SELECT * FROM tbl1; } } {hello world} if {$::nRow == $::iWrite} break incr ::iWrite } finish_test |