diff options
Diffstat (limited to 'bdb/test/sdb006.tcl')
-rw-r--r-- | bdb/test/sdb006.tcl | 129 |
1 files changed, 84 insertions, 45 deletions
diff --git a/bdb/test/sdb006.tcl b/bdb/test/sdb006.tcl index 70dee5c7343..fd6066b08d6 100644 --- a/bdb/test/sdb006.tcl +++ b/bdb/test/sdb006.tcl @@ -1,17 +1,20 @@ # See the file LICENSE for redistribution information. # -# Copyright (c) 1999, 2000 +# Copyright (c) 1999-2002 # Sleepycat Software. All rights reserved. # -# $Id: sdb006.tcl,v 11.12 2000/09/20 13:22:03 sue Exp $ +# $Id: sdb006.tcl,v 11.20 2002/06/20 19:01:02 sue Exp $ # -# We'll test 2-way, 3-way, and 4-way joins and figure that if those work, -# everything else does as well. We'll create test databases called -# sub1.db, sub2.db, sub3.db, and sub4.db. The number on the database -# describes the duplication -- duplicates are of the form 0, N, 2N, 3N, ... -# where N is the number of the database. Primary.db is the primary database, -# and sub0.db is the database that has no matching duplicates. All of -# these are within a single database. +# TEST subdb006 +# TEST Tests intra-subdb join +# TEST +# TEST We'll test 2-way, 3-way, and 4-way joins and figure that if those work, +# TEST everything else does as well. We'll create test databases called +# TEST sub1.db, sub2.db, sub3.db, and sub4.db. The number on the database +# TEST describes the duplication -- duplicates are of the form 0, N, 2N, 3N, +# TEST ... where N is the number of the database. Primary.db is the primary +# TEST database, and sub0.db is the database that has no matching duplicates. +# TEST All of these are within a single database. # # We should test this on all btrees, all hash, and a combination thereof proc subdb006 {method {nentries 100} args } { @@ -27,8 +30,34 @@ proc subdb006 {method {nentries 100} args } { return } + set txnenv 0 + set eindex [lsearch -exact $args "-env"] + # + # If we are using an env, then testfile should just be the db name. + # Otherwise it is the test directory and the name. + if { $eindex == -1 } { + set testfile $testdir/subdb006.db + set env NULL + } else { + set testfile subdb006.db + incr eindex + set env [lindex $args $eindex] + set txnenv [is_txnenv $env] + if { $txnenv == 1 } { + append args " -auto_commit " + if { $nentries == 100 } { + # !!! + # nentries must be greater than the number + # of do_join_subdb calls below. + # + set nentries 35 + } + } + set testdir [get_home $env] + } berkdb srand $rand_init + set oargs $args foreach opt {" -dup" " -dupsort"} { append args $opt @@ -40,10 +69,12 @@ proc subdb006 {method {nentries 100} args } { # puts "\tSubdb006.a: Intra-subdb join" - cleanup $testdir NULL - set testfile $testdir/subdb006.db + if { $env != "NULL" } { + set testdir [get_home $env] + } + cleanup $testdir $env - set psize [list 8192] + set psize 8192 set duplist {0 50 25 16 12} set numdb [llength $duplist] build_all_subdb $testfile [list $method] $psize \ @@ -53,77 +84,85 @@ proc subdb006 {method {nentries 100} args } { puts "Subdb006: Building the primary database $method" set oflags "-create -mode 0644 [conv $omethod \ [berkdb random_int 1 2]]" - set db [eval {berkdb_open} $oflags $testfile primary.db] + set db [eval {berkdb_open} $oflags $oargs $testfile primary.db] error_check_good dbopen [is_valid_db $db] TRUE for { set i 0 } { $i < 1000 } { incr i } { + if { $txnenv == 1 } { + set t [$env txn] + error_check_good txn [is_valid_txn $t $env] TRUE + set txn "-txn $t" + } set key [format "%04d" $i] - set ret [$db put $key stub] + set ret [eval {$db put} $txn {$key stub}] error_check_good "primary put" $ret 0 + if { $txnenv == 1 } { + error_check_good txn [$t commit] 0 + } } error_check_good "primary close" [$db close] 0 set did [open $dict] gets $did str - do_join_subdb $testfile primary.db "1 0" $str + do_join_subdb $testfile primary.db "1 0" $str $oargs gets $did str - do_join_subdb $testfile primary.db "2 0" $str + do_join_subdb $testfile primary.db "2 0" $str $oargs gets $did str - do_join_subdb $testfile primary.db "3 0" $str + do_join_subdb $testfile primary.db "3 0" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4 0" $str + do_join_subdb $testfile primary.db "4 0" $str $oargs gets $did str - do_join_subdb $testfile primary.db "1" $str + do_join_subdb $testfile primary.db "1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "2" $str + do_join_subdb $testfile primary.db "2" $str $oargs gets $did str - do_join_subdb $testfile primary.db "3" $str + do_join_subdb $testfile primary.db "3" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4" $str + do_join_subdb $testfile primary.db "4" $str $oargs gets $did str - do_join_subdb $testfile primary.db "1 2" $str + do_join_subdb $testfile primary.db "1 2" $str $oargs gets $did str - do_join_subdb $testfile primary.db "1 2 3" $str + do_join_subdb $testfile primary.db "1 2 3" $str $oargs gets $did str - do_join_subdb $testfile primary.db "1 2 3 4" $str + do_join_subdb $testfile primary.db "1 2 3 4" $str $oargs gets $did str - do_join_subdb $testfile primary.db "2 1" $str + do_join_subdb $testfile primary.db "2 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "3 2 1" $str + do_join_subdb $testfile primary.db "3 2 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4 3 2 1" $str + do_join_subdb $testfile primary.db "4 3 2 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "1 3" $str + do_join_subdb $testfile primary.db "1 3" $str $oargs gets $did str - do_join_subdb $testfile primary.db "3 1" $str + do_join_subdb $testfile primary.db "3 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "1 4" $str + do_join_subdb $testfile primary.db "1 4" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4 1" $str + do_join_subdb $testfile primary.db "4 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "2 3" $str + do_join_subdb $testfile primary.db "2 3" $str $oargs gets $did str - do_join_subdb $testfile primary.db "3 2" $str + do_join_subdb $testfile primary.db "3 2" $str $oargs gets $did str - do_join_subdb $testfile primary.db "2 4" $str + do_join_subdb $testfile primary.db "2 4" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4 2" $str + do_join_subdb $testfile primary.db "4 2" $str $oargs gets $did str - do_join_subdb $testfile primary.db "3 4" $str + do_join_subdb $testfile primary.db "3 4" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4 3" $str + do_join_subdb $testfile primary.db "4 3" $str $oargs gets $did str - do_join_subdb $testfile primary.db "2 3 4" $str + do_join_subdb $testfile primary.db "2 3 4" $str $oargs gets $did str - do_join_subdb $testfile primary.db "3 4 1" $str + do_join_subdb $testfile primary.db "3 4 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4 2 1" $str + do_join_subdb $testfile primary.db "4 2 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "0 2 1" $str + do_join_subdb $testfile primary.db "0 2 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "3 2 0" $str + do_join_subdb $testfile primary.db "3 2 0" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4 3 2 1" $str + do_join_subdb $testfile primary.db "4 3 2 1" $str $oargs gets $did str - do_join_subdb $testfile primary.db "4 3 0 1" $str + do_join_subdb $testfile primary.db "4 3 0 1" $str $oargs close $did } |