OLD | NEW |
1 # 2005 February 15 | 1 # 2005 February 15 |
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 # This file implements regression tests for SQLite library. The | 11 # This file implements regression tests for SQLite library. The |
12 # focus of this file is testing the VACUUM statement. | 12 # focus of this file is testing the VACUUM statement. |
13 # | 13 # |
14 # $Id: vacuum2.test,v 1.10 2009/02/18 20:31:18 drh Exp $ | 14 # $Id: vacuum2.test,v 1.10 2009/02/18 20:31:18 drh Exp $ |
15 | 15 |
16 set testdir [file dirname $argv0] | 16 set testdir [file dirname $argv0] |
17 source $testdir/tester.tcl | 17 source $testdir/tester.tcl |
18 | 18 |
| 19 # Do not use a codec for tests in this file, as the database file is |
| 20 # manipulated directly using tcl scripts (using the [hexio_write] command). |
| 21 # |
| 22 do_not_use_codec |
| 23 |
19 # If the VACUUM statement is disabled in the current build, skip all | 24 # If the VACUUM statement is disabled in the current build, skip all |
20 # the tests in this file. | 25 # the tests in this file. |
21 # | 26 # |
22 ifcapable {!vacuum||!autoinc} { | 27 ifcapable {!vacuum||!autoinc} { |
23 finish_test | 28 finish_test |
24 return | 29 return |
25 } | 30 } |
26 if $AUTOVACUUM { | 31 if $AUTOVACUUM { |
27 finish_test | 32 finish_test |
28 return | 33 return |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 } {ok} | 180 } {ok} |
176 do_test vacuum2-4.7 { | 181 do_test vacuum2-4.7 { |
177 db close | 182 db close |
178 sqlite3 db test.db | 183 sqlite3 db test.db |
179 execsql { | 184 execsql { |
180 pragma auto_vacuum; | 185 pragma auto_vacuum; |
181 } | 186 } |
182 } {2} | 187 } {2} |
183 } | 188 } |
184 | 189 |
| 190 |
| 191 #------------------------------------------------------------------------- |
| 192 # The following block of tests verify the behaviour of the library when |
| 193 # a database is VACUUMed when there are one or more unfinalized SQL |
| 194 # statements reading the same database using the same db handle. |
| 195 # |
| 196 db close |
| 197 forcedelete test.db |
| 198 sqlite3 db test.db |
| 199 do_execsql_test vacuum2-5.1 { |
| 200 CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); |
| 201 INSERT INTO t1 VALUES(1, randomblob(500)); |
| 202 INSERT INTO t1 SELECT a+1, randomblob(500) FROM t1; -- 2 |
| 203 INSERT INTO t1 SELECT a+2, randomblob(500) FROM t1; -- 4 |
| 204 INSERT INTO t1 SELECT a+4, randomblob(500) FROM t1; -- 8 |
| 205 INSERT INTO t1 SELECT a+8, randomblob(500) FROM t1; -- 16 |
| 206 } {} |
| 207 |
| 208 do_test vacuum2-5.2 { |
| 209 list [catch { |
| 210 db eval {SELECT a, b FROM t1} { if {$a == 8} { execsql VACUUM } } |
| 211 } msg] $msg |
| 212 } {1 {cannot VACUUM - SQL statements in progress}} |
| 213 |
| 214 do_test vacuum2-5.3 { |
| 215 list [catch { |
| 216 db eval {SELECT 1, 2, 3} { execsql VACUUM } |
| 217 } msg] $msg |
| 218 } {1 {cannot VACUUM - SQL statements in progress}} |
| 219 |
| 220 do_test vacuum2-5.4 { |
| 221 set res "" |
| 222 set res2 "" |
| 223 db eval {SELECT a, b FROM t1 WHERE a<=10} { |
| 224 if {$a==6} { set res [catchsql VACUUM] } |
| 225 lappend res2 $a |
| 226 } |
| 227 lappend res2 $res |
| 228 } {1 2 3 4 5 6 7 8 9 10 {1 {cannot VACUUM - SQL statements in progress}}} |
| 229 |
| 230 |
185 finish_test | 231 finish_test |
OLD | NEW |