2001-09-16 00:13:26 +00:00
|
|
|
# 2001 September 15
|
2000-06-03 18:06:52 +00:00
|
|
|
#
|
2001-09-16 00:13:26 +00:00
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
2000-06-03 18:06:52 +00:00
|
|
|
#
|
2001-09-16 00:13:26 +00:00
|
|
|
# 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.
|
2000-06-03 18:06:52 +00:00
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
# This file implements regression tests for SQLite library. The
|
|
|
|
# focus of this file is testing the VACUUM statement.
|
|
|
|
#
|
2001-09-16 00:13:26 +00:00
|
|
|
# $Id: vacuum.test,v 1.6 2001/09/16 00:13:28 drh Exp $
|
2000-06-03 18:06:52 +00:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
2001-09-14 03:24:23 +00:00
|
|
|
if {0} {
|
|
|
|
|
2000-06-03 18:06:52 +00:00
|
|
|
# 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}
|
2001-03-20 12:55:13 +00:00
|
|
|
if {$::tcl_platform(platform)!="windows"} {
|
2000-06-03 18:06:52 +00:00
|
|
|
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}
|
2001-03-20 12:55:13 +00:00
|
|
|
} ;# End if( platform!=windows )
|
2000-06-03 18:06:52 +00:00
|
|
|
|
|
|
|
finish_test
|
2001-09-14 03:24:23 +00:00
|
|
|
|
|
|
|
}
|