summaryrefslogtreecommitdiff
path: root/bdb/test/test030.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'bdb/test/test030.tcl')
-rw-r--r--bdb/test/test030.tcl58
1 files changed, 49 insertions, 9 deletions
diff --git a/bdb/test/test030.tcl b/bdb/test/test030.tcl
index 7395adf82bd..d91359f07a0 100644
--- a/bdb/test/test030.tcl
+++ b/bdb/test/test030.tcl
@@ -1,11 +1,12 @@
# See the file LICENSE for redistribution information.
#
-# Copyright (c) 1996, 1997, 1998, 1999, 2000
+# Copyright (c) 1996-2002
# Sleepycat Software. All rights reserved.
#
-# $Id: test030.tcl,v 11.13 2000/08/25 14:21:55 sue Exp $
+# $Id: test030.tcl,v 11.18 2002/05/22 15:42:50 sue Exp $
#
-# DB Test 30: Test DB_NEXT_DUP Functionality.
+# TEST test030
+# TEST Test DB_NEXT_DUP Functionality.
proc test030 { method {nentries 10000} args } {
global rand_init
source ./include.tcl
@@ -18,11 +19,10 @@ proc test030 { method {nentries 10000} args } {
puts "Test030 skipping for method $method"
return
}
-
- puts "Test030: $method ($args) $nentries DB_NEXT_DUP testing"
berkdb srand $rand_init
# 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.
@@ -36,20 +36,34 @@ proc test030 { method {nentries 10000} args } {
set cntfile cntfile.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
+ }
+ }
+ set testdir [get_home $env]
}
+
+ puts "Test030: $method ($args) $nentries DB_NEXT_DUP testing"
set t1 $testdir/t1
set t2 $testdir/t2
set t3 $testdir/t3
cleanup $testdir $env
- set db [eval {berkdb_open -create -truncate \
+ set db [eval {berkdb_open -create \
-mode 0644 -dup} $args {$omethod $testfile}]
error_check_good dbopen [is_valid_db $db] TRUE
# Use a second DB to keep track of how many duplicates
# we enter per key
- set cntdb [eval {berkdb_open -create -truncate \
+ set cntdb [eval {berkdb_open -create \
-mode 0644} $args {-btree $cntfile}]
error_check_good dbopen:cntfile [is_valid_db $db] TRUE
@@ -64,15 +78,30 @@ proc test030 { method {nentries 10000} args } {
set did [open $dict]
puts "\tTest030.a: put and get duplicate keys."
+ 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]
while { [gets $did str] != -1 && $count < $nentries } {
set ndup [berkdb random_int 1 10]
for { set i 1 } { $i <= $ndup } { incr i 1 } {
+ set ctxn ""
+ if { $txnenv == 1 } {
+ set ct [$env txn]
+ error_check_good txn \
+ [is_valid_txn $ct $env] TRUE
+ set ctxn "-txn $ct"
+ }
set ret [eval {$cntdb put} \
- $txn $pflags {$str [chop_data $method $ndup]}]
+ $ctxn $pflags {$str [chop_data $method $ndup]}]
error_check_good put_cnt $ret 0
+ if { $txnenv == 1 } {
+ error_check_good txn [$ct commit] 0
+ }
set datastr $i:$str
set ret [eval {$db put} \
$txn $pflags {$str [chop_data $method $datastr]}]
@@ -132,8 +161,16 @@ proc test030 { method {nentries 10000} args } {
set lastkey $k
# Figure out how may dups we should have
- set ret [eval {$cntdb get} $txn $pflags {$k}]
+ if { $txnenv == 1 } {
+ set ct [$env txn]
+ error_check_good txn [is_valid_txn $ct $env] TRUE
+ set ctxn "-txn $ct"
+ }
+ set ret [eval {$cntdb get} $ctxn $pflags {$k}]
set ndup [lindex [lindex $ret 0] 1]
+ if { $txnenv == 1 } {
+ error_check_good txn [$ct commit] 0
+ }
set howmany 1
for { set ret [$dbc get -nextdup] } \
@@ -186,6 +223,9 @@ proc test030 { method {nentries 10000} args } {
}
error_check_good cnt_curs_close [$cnt_dbc close] 0
error_check_good db_curs_close [$dbc close] 0
+ if { $txnenv == 1 } {
+ error_check_good txn [$t commit] 0
+ }
error_check_good cnt_file_close [$cntdb close] 0
error_check_good db_file_close [$db close] 0
}