1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1999-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Tests many subdbs
10
# TEST Creates many subdbs and puts a small amount of
11
# TEST data in each (many defaults to 2000)
13
# TEST Use the first 10,000 entries from the dictionary as subdbnames.
14
# TEST Insert each with entry as name of subdatabase and a partial list
15
# TEST as key/data. After all are entered, retrieve all; compare output
16
# TEST to original. Close file, reopen, do retrieve and re-verify.
17
proc subdb003 { method {nentries 1000} args } {
20
set args [convert_args $method $args]
21
set omethod [convert_method $method]
23
if { [is_queue $method] == 1 } {
24
puts "Subdb003: skipping for method $method"
28
puts "Subdb003: $method ($args) many subdb tests"
31
set eindex [lsearch -exact $args "-env"]
33
# If we are using an env, then testfile should just be the db name.
34
# Otherwise it is the test directory and the name.
35
if { $eindex == -1 } {
36
set testfile $testdir/subdb003.db
39
set testfile subdb003.db
41
set env [lindex $args $eindex]
42
set txnenv [is_txnenv $env]
44
append args " -auto_commit "
45
if { $nentries == 1000 } {
49
set testdir [get_home $env]
51
# Create the database and open the dictionary
62
if { [is_record_based $method] == 1 } {
63
set checkfunc subdb003_recno.check
64
append gflags " -recno"
66
set checkfunc subdb003.check
69
# Here is the loop where we put and get each key/data pair
72
while { [gets $fdid str] != -1 && $fcount < $nentries } {
74
set db [eval {berkdb_open -create -mode 0644} \
75
$args {$omethod $testfile $subdb}]
76
error_check_good dbopen [is_valid_db $db] TRUE
80
while { [gets $did str] != -1 && $count < $ndataent } {
81
if { [is_record_based $method] == 1 } {
84
set key [expr $count + 1]
85
set kvals($key) [pad_data $method $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 $str]}]
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 get $ret [list [list $key \
103
[pad_data $method $str]]]
109
if { $txnenv == 1 } {
111
error_check_good txn [is_valid_txn $t $env] TRUE
114
dump_file $db $txn $t1 $checkfunc
115
if { $txnenv == 1 } {
116
error_check_good txn [$t commit] 0
118
error_check_good db_close [$db close] 0
120
# Now compare the keys to see if they match
121
if { [is_record_based $method] == 1 } {
123
for {set i 1} {$i <= $ndataent} {set i [incr i]} {
127
file rename -force $t1 $t3
130
filehead $ndataent $dict $t3
135
error_check_good Subdb003:diff($t3,$t2) \
138
# Now, reopen the file and run the last test again.
139
open_and_dump_subfile $testfile $env $t1 $checkfunc \
140
dump_file_direction "-first" "-next" $subdb
141
if { [is_record_based $method] != 1 } {
145
error_check_good Subdb003:diff($t2,$t3) \
148
# Now, reopen the file and run the last test again in the
150
open_and_dump_subfile $testfile $env $t1 $checkfunc \
151
dump_file_direction "-last" "-prev" $subdb
153
if { [is_record_based $method] != 1 } {
157
error_check_good Subdb003:diff($t3,$t2) \
159
if { [expr $fcount % 100] == 0 } {
160
puts -nonewline "$fcount "
168
# Check function for Subdb003; keys and data are identical
169
proc subdb003.check { key data } {
170
error_check_good "key/data mismatch" $data $key
173
proc subdb003_recno.check { key data } {
177
error_check_good key"$key"_exists [info exists kvals($key)] 1
178
error_check_good "key/data mismatch, key $key" $data $kvals($key)