| OLD | NEW |
| (Empty) |
| 1 # 2007 May 04 | |
| 2 # | |
| 3 # The author disclaims copyright to this source code. In place of | |
| 4 # a legal notice, here is a blessing: | |
| 5 # | |
| 6 # May you do good and not evil. | |
| 7 # May you find forgiveness for yourself and forgive others. | |
| 8 # May you share freely, never taking more than you give. | |
| 9 # | |
| 10 #*********************************************************************** | |
| 11 # This file implements regression tests for SQLite library. The | |
| 12 # focus of this file is testing the incremental vacuum feature. | |
| 13 # | |
| 14 # $Id: incrvacuum2.test,v 1.6 2009/07/25 13:42:50 danielk1977 Exp $ | |
| 15 | |
| 16 set testdir [file dirname $argv0] | |
| 17 source $testdir/tester.tcl | |
| 18 | |
| 19 # If this build of the library does not support auto-vacuum, omit this | |
| 20 # whole file. | |
| 21 ifcapable {!autovacuum || !pragma} { | |
| 22 finish_test | |
| 23 return | |
| 24 } | |
| 25 | |
| 26 | |
| 27 # Create a database in incremental vacuum mode that has many | |
| 28 # pages on the freelist. | |
| 29 # | |
| 30 do_test incrvacuum2-1.1 { | |
| 31 execsql { | |
| 32 PRAGMA page_size=1024; | |
| 33 PRAGMA auto_vacuum=incremental; | |
| 34 CREATE TABLE t1(x); | |
| 35 INSERT INTO t1 VALUES(zeroblob(30000)); | |
| 36 DELETE FROM t1; | |
| 37 } | |
| 38 file size test.db | |
| 39 } {32768} | |
| 40 | |
| 41 # Vacuum off a single page. | |
| 42 # | |
| 43 do_test incrvacuum2-1.2 { | |
| 44 execsql { | |
| 45 PRAGMA incremental_vacuum(1); | |
| 46 } | |
| 47 file size test.db | |
| 48 } {31744} | |
| 49 | |
| 50 # Vacuum off five pages | |
| 51 # | |
| 52 do_test incrvacuum2-1.3 { | |
| 53 execsql { | |
| 54 PRAGMA incremental_vacuum(5); | |
| 55 } | |
| 56 file size test.db | |
| 57 } {26624} | |
| 58 | |
| 59 # Vacuum off all the rest | |
| 60 # | |
| 61 do_test incrvacuum2-1.4 { | |
| 62 execsql { | |
| 63 PRAGMA incremental_vacuum(1000); | |
| 64 } | |
| 65 file size test.db | |
| 66 } {3072} | |
| 67 | |
| 68 # Make sure incremental vacuum works on attached databases. | |
| 69 # | |
| 70 ifcapable attach { | |
| 71 do_test incrvacuum2-2.1 { | |
| 72 file delete -force test2.db test2.db-journal | |
| 73 execsql { | |
| 74 ATTACH DATABASE 'test2.db' AS aux; | |
| 75 PRAGMA aux.auto_vacuum=incremental; | |
| 76 CREATE TABLE aux.t2(x); | |
| 77 INSERT INTO t2 VALUES(zeroblob(30000)); | |
| 78 INSERT INTO t1 SELECT * FROM t2; | |
| 79 DELETE FROM t2; | |
| 80 DELETE FROM t1; | |
| 81 } | |
| 82 list [file size test.db] [file size test2.db] | |
| 83 } {32768 32768} | |
| 84 do_test incrvacuum2-2.2 { | |
| 85 execsql { | |
| 86 PRAGMA aux.incremental_vacuum(1) | |
| 87 } | |
| 88 list [file size test.db] [file size test2.db] | |
| 89 } {32768 31744} | |
| 90 do_test incrvacuum2-2.3 { | |
| 91 execsql { | |
| 92 PRAGMA aux.incremental_vacuum(5) | |
| 93 } | |
| 94 list [file size test.db] [file size test2.db] | |
| 95 } {32768 26624} | |
| 96 do_test incrvacuum2-2.4 { | |
| 97 execsql { | |
| 98 PRAGMA main.incremental_vacuum(5) | |
| 99 } | |
| 100 list [file size test.db] [file size test2.db] | |
| 101 } {27648 26624} | |
| 102 do_test incrvacuum2-2.5 { | |
| 103 execsql { | |
| 104 PRAGMA aux.incremental_vacuum | |
| 105 } | |
| 106 list [file size test.db] [file size test2.db] | |
| 107 } {27648 3072} | |
| 108 do_test incrvacuum2-2.6 { | |
| 109 execsql { | |
| 110 PRAGMA incremental_vacuum(1) | |
| 111 } | |
| 112 list [file size test.db] [file size test2.db] | |
| 113 } {26624 3072} | |
| 114 } | |
| 115 | |
| 116 do_test incrvacuum2-3.1 { | |
| 117 execsql { | |
| 118 PRAGMA auto_vacuum = 'full'; | |
| 119 BEGIN; | |
| 120 CREATE TABLE abc(a); | |
| 121 INSERT INTO abc VALUES(randstr(1500,1500)); | |
| 122 COMMIT; | |
| 123 } | |
| 124 } {} | |
| 125 do_test incrvacuum2-3.2 { | |
| 126 execsql { | |
| 127 BEGIN; | |
| 128 DELETE FROM abc; | |
| 129 PRAGMA incremental_vacuum; | |
| 130 COMMIT; | |
| 131 } | |
| 132 } {} | |
| 133 | |
| 134 integrity_check incremental2-3.3 | |
| 135 | |
| 136 finish_test | |
| OLD | NEW |