diff options
Diffstat (limited to 'bdb/test/test010.tcl')
-rw-r--r-- | bdb/test/test010.tcl | 78 |
1 files changed, 64 insertions, 14 deletions
diff --git a/bdb/test/test010.tcl b/bdb/test/test010.tcl index b3aedb2bee9..0b5f5531795 100644 --- a/bdb/test/test010.tcl +++ b/bdb/test/test010.tcl @@ -1,17 +1,19 @@ # See the file LICENSE for redistribution information. # -# Copyright (c) 1996, 1997, 1998, 1999, 2000 +# Copyright (c) 1996-2002 # Sleepycat Software. All rights reserved. # -# $Id: test010.tcl,v 11.14 2000/08/25 14:21:54 sue Exp $ +# $Id: test010.tcl,v 11.20 2002/06/11 14:09:56 sue Exp $ # -# DB Test 10 {access method} -# Use the first 10,000 entries from the dictionary. -# Insert each with self as key and data; add duplicate -# records for each. -# After all are entered, retrieve all; verify output. -# Close file, reopen, do retrieve and re-verify. -# This does not work for recno +# TEST test010 +# TEST Duplicate test +# TEST Small key/data pairs. +# TEST +# TEST Use the first 10,000 entries from the dictionary. +# TEST Insert each with self as key and data; add duplicate records for each. +# TEST After all are entered, retrieve all; verify output. +# TEST Close file, reopen, do retrieve and re-verify. +# TEST This does not work for recno proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } { source ./include.tcl @@ -25,9 +27,8 @@ proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } { return } - puts "Test0$tnum: $method ($args) $nentries small dup key/data pairs" - # Create the database and open the dictionary + set txnenv 0 set eindex [lsearch -exact $args "-env"] # # If we are using an env, then testfile should just be the db name. @@ -39,7 +40,23 @@ proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } { set testfile test0$tnum.db incr eindex set env [lindex $args $eindex] + set txnenv [is_txnenv $env] + if { $txnenv == 1 } { + append args " -auto_commit " + # + # If we are using txns and running with the + # default, set the default down a bit. + # + if { $nentries == 10000 } { + set nentries 100 + } + reduce_dups nentries ndups + } + set testdir [get_home $env] } + puts "Test0$tnum: $method ($args) $nentries \ + small $ndups dup key/data pairs" + set t1 $testdir/t1 set t2 $testdir/t2 set t3 $testdir/t3 @@ -47,7 +64,7 @@ proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } { cleanup $testdir $env set db [eval {berkdb_open \ - -create -truncate -mode 0644 -dup} $args {$omethod $testfile}] + -create -mode 0644 -dup} $args {$omethod $testfile}] error_check_good dbopen [is_valid_db $db] TRUE set did [open $dict] @@ -58,17 +75,30 @@ proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } { set count 0 # Here is the loop where we put and get each key/data pair - set dbc [eval {$db cursor} $txn] while { [gets $did str] != -1 && $count < $nentries } { for { set i 1 } { $i <= $ndups } { incr i } { set datastr $i:$str + 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 $pflags {$str [chop_data $method $datastr]}] error_check_good put $ret 0 + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } } # Now retrieve all the keys matching this key set x 1 + 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] for {set ret [$dbc get "-set" $str]} \ {[llength $ret] != 0} \ {set ret [$dbc get "-next"] } { @@ -87,9 +117,13 @@ proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } { incr x } error_check_good "Test0$tnum:ndups:$str" [expr $x - 1] $ndups + error_check_good cursor_close [$dbc close] 0 + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } + incr count } - error_check_good cursor_close [$dbc close] 0 close $did # Now we will get each key from the DB and compare the results @@ -99,7 +133,15 @@ proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } { for { set i 1 } { $i <= $ndups } {incr i} { lappend dlist $i } + if { $txnenv == 1 } { + set t [$env txn] + error_check_good txn [is_valid_txn $t $env] TRUE + set txn "-txn $t" + } dup_check $db $txn $t1 $dlist + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } # Now compare the keys to see if they match the dictionary entries set q q @@ -115,7 +157,15 @@ proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } { error_check_good dbopen [is_valid_db $db] TRUE puts "\tTest0$tnum.b: Checking file for correct duplicates after close" + if { $txnenv == 1 } { + set t [$env txn] + error_check_good txn [is_valid_txn $t $env] TRUE + set txn "-txn $t" + } dup_check $db $txn $t1 $dlist + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } # Now compare the keys to see if they match the dictionary entries filesort $t1 $t3 |