1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
10
# TEST Small key/data pairs.
12
# TEST Use the first 10,000 entries from the dictionary.
13
# TEST Insert each with self as key and data; add duplicate records for each.
14
# TEST After all are entered, retrieve all; verify output.
15
# TEST Close file, reopen, do retrieve and re-verify.
16
# TEST This does not work for recno
17
proc test010 { method {nentries 10000} {ndups 5} {tnum 10} args } {
21
set args [convert_args $method $args]
22
set omethod [convert_method $method]
24
if { [is_record_based $method] == 1 || \
25
[is_rbtree $method] == 1 } {
26
puts "Test0$tnum skipping for method $method"
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/test0$tnum.db
40
set testfile test0$tnum.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 } {
53
reduce_dups nentries ndups
55
set testdir [get_home $env]
57
puts "Test0$tnum: $method ($args) $nentries \
58
small $ndups dup key/data pairs"
66
set db [eval {berkdb_open \
67
-create -mode 0644 -dup} $args {$omethod $testfile}]
68
error_check_good dbopen [is_valid_db $db] TRUE
77
# Here is the loop where we put and get each key/data pair
78
while { [gets $did str] != -1 && $count < $nentries } {
79
for { set i 1 } { $i <= $ndups } { incr i } {
83
error_check_good txn [is_valid_txn $t $env] TRUE
86
set ret [eval {$db put} \
87
$txn $pflags {$str [chop_data $method $datastr]}]
88
error_check_good put $ret 0
90
error_check_good txn [$t commit] 0
94
# Now retrieve all the keys matching this key
98
error_check_good txn [is_valid_txn $t $env] TRUE
101
set dbc [eval {$db cursor} $txn]
102
for {set ret [$dbc get "-set" $str]} \
103
{[llength $ret] != 0} \
104
{set ret [$dbc get "-next"] } {
105
if {[llength $ret] == 0} {
108
set k [lindex [lindex $ret 0] 0]
109
if { [string compare $k $str] != 0 } {
112
set datastr [lindex [lindex $ret 0] 1]
113
set d [data_of $datastr]
114
error_check_good "Test0$tnum:get" $d $str
115
set id [ id_of $datastr ]
116
error_check_good "Test0$tnum:dup#" $id $x
119
error_check_good "Test0$tnum:ndups:$str" [expr $x - 1] $ndups
120
error_check_good cursor_close [$dbc close] 0
121
if { $txnenv == 1 } {
122
error_check_good txn [$t commit] 0
129
# Now we will get each key from the DB and compare the results
131
puts "\tTest0$tnum.a: Checking file for correct duplicates"
133
for { set i 1 } { $i <= $ndups } {incr i} {
136
if { $txnenv == 1 } {
138
error_check_good txn [is_valid_txn $t $env] TRUE
141
dup_check $db $txn $t1 $dlist
142
if { $txnenv == 1 } {
143
error_check_good txn [$t commit] 0
146
# Now compare the keys to see if they match the dictionary entries
148
filehead $nentries $dict $t3
152
error_check_good Test0$tnum:diff($t3,$t2) \
155
error_check_good db_close [$db close] 0
156
set db [eval {berkdb_open} $args $testfile]
157
error_check_good dbopen [is_valid_db $db] TRUE
159
puts "\tTest0$tnum.b: Checking file for correct duplicates after close"
160
if { $txnenv == 1 } {
162
error_check_good txn [is_valid_txn $t $env] TRUE
165
dup_check $db $txn $t1 $dlist
166
if { $txnenv == 1 } {
167
error_check_good txn [$t commit] 0
170
# Now compare the keys to see if they match the dictionary entries
172
error_check_good Test0$tnum:diff($t3,$t2) \
175
error_check_good db_close [$db close] 0