proc test067 { method {ndups 1000} {tnum "067"} args } {
source ./include.tcl
global alphabet
global errorCode
global is_je_test
set args [convert_args $method $args]
set omethod [convert_method $method]
set txn ""
set txnenv 0
set eindex [lsearch -exact $args "-env"]
if { $eindex == -1 } {
set testfile $testdir/test$tnum.db
set env NULL
} else {
set testfile test$tnum.db
incr eindex
set env [lindex $args $eindex]
set txnenv [is_txnenv $env]
if { $txnenv == 1 } {
append args " -auto_commit "
if { $ndups == 1000 } {
set ndups 100
}
}
set testdir [get_home $env]
}
cleanup $testdir $env
if { [is_record_based $method] == 1 || [is_rbtree $method] == 1 } {
puts "\tTest$tnum: skipping for method $method."
return
}
puts "Test$tnum:\
$method ($args) Partial puts on near-empty duplicate pages."
foreach dupopt { "-dup" "-dup -dupsort" } {
if { $is_je_test && $dupopt == "-dup" } {
continue
}
if { $env != "NULL" } {
set testdir [get_home $env]
}
cleanup $testdir $env
set db [eval {berkdb_open -create -mode 0644 \
$omethod} $args $dupopt {$testfile}]
error_check_good db_open [is_valid_db $db] TRUE
puts "\tTest$tnum.a ($dupopt): Put $ndups duplicates."
set key "key_test$tnum"
for { set ndx 0 } { $ndx < $ndups } { incr ndx } {
set data $alphabet$ndx
if { $txnenv == 1 } {
set t [$env txn]
error_check_good txn [is_valid_txn $t $env] TRUE
set txn "-txn $t"
}
set ret [eval {$db put} $txn {$key $data}]
error_check_good put($key,$data) $ret 0
if { $txnenv == 1 } {
error_check_good txn [$t commit] 0
}
}
error_check_good db_sync [$db sync] 0
puts "\tTest$tnum.b ($dupopt):\
Deleting dups (last first), overwriting each."
if { $txnenv == 1 } {
set t [$env txn]
error_check_good txn [is_valid_txn $t $env] TRUE
set txn "-txn $t"
}
set dbc [eval {$db cursor} $txn]
error_check_good cursor_create [is_valid_cursor $dbc $db] TRUE
set count 0
while { $count < $ndups - 1 } {
set ret [$dbc get -last]
error_check_good \
verify_key [lindex [lindex $ret 0] 0] $key
set currdatum [lindex [lindex $ret 0] 1]
set errorCode NONE
set ret [catch {eval $dbc put -current \
{-partial [list 1 4]} "bcde"} \
res]
error_check_good \
partial_put_valid($currdatum) $errorCode NONE
error_check_good partial_put($currdatum) $res 0
error_check_good dbc_del [$dbc del] 0
incr count
}
error_check_good dbc_close [$dbc close] 0
if { $txnenv == 1 } {
error_check_good txn [$t commit] 0
}
error_check_good db_close [$db close] 0
}
}