source ./include.tcl
source $test_path/test.tcl
set usage "subdbscript testfile subdbnumber factor"
if { $argc != 3 } {
puts stderr "FAIL:[timestamp] Usage: $usage"
exit
}
set testfile [lindex $argv 0]
set n [ lindex $argv 1 ]
set factor [ lindex $argv 2 ]
set db [berkdb_open -unknown $testfile sub$n.db]
error_check_good db_open [is_valid_db $db] TRUE
set dbc [$db cursor]
error_check_good db_cursor [is_valid_cursor $dbc $db] TRUE
set i 1
for {set d [$dbc get -first]} {[llength $d] != 0} {set d [$dbc get -next]} {
set x [expr $i - $n]
if { $x >= 0 && [expr $x % $factor] == 0 } {
puts "Deleting $d"
error_check_good dbc_del [$dbc del] 0
}
incr i
}
error_check_good db_close [$db close] 0
exit