1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Small keys/medium data
10
# TEST Put/get per key
11
# TEST Keyed delete and verify
13
# TEST Keyed delete test.
14
# TEST Create database.
15
# TEST Go through database, deleting all entries by key.
16
proc test006 { method {nentries 10000} {reopen 0} {tnum 6} args} {
19
set do_renumber [is_rrecno $method]
20
set args [convert_args $method $args]
21
set omethod [convert_method $method]
25
set dbname test00$tnum
30
# Create the database and open the dictionary
32
set eindex [lsearch -exact $args "-env"]
34
# If we are using an env, then testfile should just be the db name.
35
# Otherwise it is the test directory and the name.
36
if { $eindex == -1 } {
37
set testfile $testdir/$dbname.db
40
set testfile $dbname.db
42
set env [lindex $args $eindex]
43
set txnenv [is_txnenv $env]
45
append args " -auto_commit "
47
# If we are using txns and running with the
48
# default, set the default down a bit.
50
if { $nentries == 10000 } {
54
set testdir [get_home $env]
56
puts -nonewline "$tname: $method ($args) "
57
puts -nonewline "$nentries equal small key; medium data pairs"
68
if { [is_record_based $method] == 1 } {
69
append gflags " -recno"
72
# Here is the loop where we put and get each key/data pair
75
set db [eval {berkdb_open \
76
-create -mode 0644} $args {$omethod $testfile}]
77
error_check_good dbopen [is_valid_db $db] TRUE
80
while { [gets $did str] != -1 && $count < $nentries } {
81
if { [is_record_based $method] == 1 } {
82
set key [expr $count + 1 ]
87
set datastr [make_data_str $str]
91
error_check_good txn [is_valid_txn $t $env] TRUE
94
set ret [eval {$db put} \
95
$txn $pflags {$key [chop_data $method $datastr]}]
96
error_check_good put $ret 0
98
error_check_good txn [$t commit] 0
101
set ret [eval {$db get} $gflags {$key}]
102
error_check_good "$tname: put $datastr got $ret" \
103
$ret [list [list $key [pad_data $method $datastr]]]
108
if { $reopen == 1 } {
109
error_check_good db_close [$db close] 0
111
set db [eval {berkdb_open} $args {$testfile}]
112
error_check_good dbopen [is_valid_db $db] TRUE
115
# Now we will get each key from the DB and compare the results
116
# to the original, then delete it.
120
while { [gets $did str] != -1 && $count < $nentries } {
121
if { $do_renumber == 1 } {
123
} elseif { [is_record_based $method] == 1 } {
129
set datastr [make_data_str $str]
131
set ret [eval {$db get} $gflags {$key}]
132
error_check_good "$tname: get $datastr got $ret" \
133
$ret [list [list $key [pad_data $method $datastr]]]
135
if { $txnenv == 1 } {
137
error_check_good txn [is_valid_txn $t $env] TRUE
140
set ret [eval {$db del} $txn {$key}]
141
error_check_good db_del:$key $ret 0
142
if { $txnenv == 1 } {
143
error_check_good txn [$t commit] 0
149
error_check_good db_close [$db close] 0