e80463bc7d
FossilOrigin-Name: b7d953e1195897de4869ec241a65e8a3d1320efb
94 lines
2.4 KiB
Plaintext
94 lines
2.4 KiB
Plaintext
# 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 SELECT statement.
|
|
#
|
|
# $Id: autovacuum.test,v 1.3 2004/11/03 03:01:17 danielk1977 Exp $
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
|
|
proc make_str {char len} {
|
|
set str [string repeat $char. $len]
|
|
return [string range $str 0 [expr $len-1]]
|
|
}
|
|
|
|
proc file_pages {} {
|
|
return [expr [file size test.db] / 1024]
|
|
}
|
|
|
|
do_test autovacuum-1.1 {
|
|
execsql {
|
|
CREATE TABLE av1(a);
|
|
CREATE INDEX av1_idx ON av1(a);
|
|
}
|
|
} {}
|
|
|
|
set ENTRY_LEN 3000
|
|
|
|
set delete_orders [list]
|
|
lappend delete_orders {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
|
|
lappend delete_orders {20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}
|
|
lappend delete_orders {8 18 2 4 14 11 13 3 10 7 9 5 12 17 19 15 20 6 16 1}
|
|
lappend delete_orders {10 3 11 17 19 20 7 4 13 6 1 14 16 12 9 18 8 15 5 2}
|
|
lappend delete_orders {{1 2 3 4 5 6 7 8 9 10} {11 12 13 14 15 16 17 18 19 20}}
|
|
lappend delete_orders \
|
|
{{19 8 17 15} {16 11 9 14} {18 5 3 1} {13 20 7 2} {6 12 4 10}}
|
|
|
|
set tn 0
|
|
foreach delete_order $delete_orders {
|
|
incr tn
|
|
|
|
# Set up the table.
|
|
set ::tbl_data [list]
|
|
foreach i [lsort -integer [eval concat $delete_order]] {
|
|
execsql "INSERT INTO av1 (oid, a) VALUES($i, '[make_str $i $ENTRY_LEN]')"
|
|
lappend ::tbl_data [make_str $i $ENTRY_LEN]
|
|
}
|
|
|
|
do_test autovacuum-1.$tn.1 {
|
|
execsql {
|
|
pragma integrity_check
|
|
}
|
|
} {ok}
|
|
|
|
foreach delete $delete_order {
|
|
do_test autovacuum-1.$tn.($delete).1 {
|
|
execsql "
|
|
DELETE FROM av1 WHERE oid IN ([join $delete ,])
|
|
"
|
|
} {}
|
|
|
|
do_test autovacuum-1.$tn.($delete).2 {
|
|
execsql {
|
|
pragma integrity_check
|
|
}
|
|
} {ok}
|
|
|
|
foreach d $delete {
|
|
set idx [lsearch $::tbl_data [make_str $d $ENTRY_LEN]]
|
|
set ::tbl_data [lreplace $::tbl_data $idx $idx]
|
|
}
|
|
do_test autovacuum-1.$tn.($delete).3 {
|
|
execsql {
|
|
select a from av1
|
|
}
|
|
} $::tbl_data
|
|
}
|
|
|
|
do_test autovacuum-1.$tn.3 {
|
|
file_pages
|
|
} {4}
|
|
}
|
|
|
|
finish_test
|
|
|