proc test121 { method {tnum "121"} args } {
source ./include.tcl
set eindex [lsearch -exact $args "-env"]
if { $eindex != -1 } {
incr eindex
set env [lindex $args $eindex]
puts "Test$tnum skipping for env $env"
return
}
if { [is_queue $method] == 1 } {
puts "Test$tnum skipping for method $method"
return
}
puts "\tTest$tnum ($method): MVCC and cursor adjustment."
set args [convert_args $method $args]
set omethod [convert_method $method]
set encargs ""
set args [split_encargs $args encargs]
set filename "test.db"
env_cleanup $testdir
puts "\tTest$tnum.a: Creating txn env."
set cachesize [expr 1024 * 1024]
set max_locks 2000
set max_objects 2000
set env [eval {berkdb_env -create -cachesize "0 $cachesize 1"}\
-lock_max_locks $max_locks -lock_max_objects $max_objects\
-txn -multiversion $encargs -home $testdir]
error_check_good env_open [is_valid_env $env] TRUE
puts "\tTest$tnum.b: Creating -multiversion db."
set db [eval {berkdb_open} \
-create -auto_commit -env $env $omethod $args $filename]
error_check_good db_open [is_valid_db $db] TRUE
puts "\tTest$tnum.c: Start txns with -snapshot."
set t1 [$env txn -snapshot]
set txn1 "-txn $t1"
set niter 10000
set data DATA
for { set i 1 } { $i <= $niter } { incr i } {
set key [expr $i * 2]
error_check_good t1_put [eval {$db put} $txn1 $key $data.$key] 0
}
error_check_good t1_commit [$t1 commit] 0
set t2 [$env txn -snapshot]
set txn2 "-txn $t2"
set cursor [eval {$db cursor} $txn2]
error_check_good db_cursor [is_valid_cursor $cursor $db] TRUE
set i 1
set halfway [expr $niter / 2]
for { set ret [$cursor get -first] } \
{ $i <= $halfway } \
{ set ret [$cursor get -next] } {
incr i
}
set currentkey [lindex [lindex $ret 0] 0]
set currentdata [lindex [lindex $ret 0] 1]
puts "\tTest$tnum.c: Enter more data."
set t1 [$env txn -snapshot]
set txn1 "-txn $t1"
for { set i 1 } { $i <= $niter } { incr i } {
set key [expr [expr $i * 2] - 1]
error_check_good t1_put [eval {$db put} $txn1 $key $data.$key] 0
set ret [$cursor get -current]
set k [lindex [lindex $ret 0] 0]
set d [lindex [lindex $ret 0] 1]
error_check_good current_key $k $currentkey
error_check_good current_data $d $currentdata
}
error_check_good t1_commit [$t1 commit] 0
error_check_good cursor_close [$cursor close] 0
error_check_good t2_commit [$t2 commit] 0
error_check_good db_close [$db close] 0
error_check_good env_close [$env close] 0
}