# 2001 September 15 # # 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 VACUUM statement. # # $Id: vacuum.test,v 1.6 2001/09/16 00:13:28 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl if {0} { # Try to vacuum a non-existant table. # do_test vacuum-1.1 { set v [catch {execsql {VACUUM dummy1}} msg] lappend v $msg } {1 {no such table or index: dummy1}} # It is OK to vacuum sqlite_master... # do_test vacuum-1.2 { set v [catch {execsql {VACUUM sqlite_master}} msg] lappend v $msg } {0 {}} # Create some tables and indices to test against. # execsql {CREATE TABLE test1(a int)} execsql {CREATE TABLE test2(b int)} execsql {CREATE INDEX index1 ON test1(a)} execsql {INSERT INTO test1 VALUES(1)} execsql {INSERT INTO test1 VALUES(1)} execsql {INSERT INTO test1 VALUES(2)} execsql {INSERT INTO test1 VALUES(3)} execsql {INSERT INTO test2 VALUES(4)} do_test vacuum-1.3 { set b1 [file mtime testdb/test1.tbl] set b2 [file mtime testdb/test2.tbl] set b3 [file mtime testdb/index1.tbl] after 1000 execsql {VACUUM test1} set a1 [file mtime testdb/test1.tbl] set a2 [file mtime testdb/test2.tbl] set a3 [file mtime testdb/index1.tbl] expr {$a1>$b1 && $a2==$b2 && $a3==$b3} } {1} if {$::tcl_platform(platform)!="windows"} { do_test vacuum-1.4 { set b1 [file mtime testdb/test1.tbl] set b2 [file mtime testdb/test2.tbl] set b3 [file mtime testdb/index1.tbl] after 1000 execsql {VACUUM} set a1 [file mtime testdb/test1.tbl] set a2 [file mtime testdb/test2.tbl] set a3 [file mtime testdb/index1.tbl] expr {$a1>$b1 && $a2>$b2 && $a3>$b3} } {1} } ;# End if( platform!=windows ) finish_test }