1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Small keys/large data
10
# TEST Put/get per key
11
# TEST Loop through keys by steps (which change)
12
# TEST ... delete each key at step
13
# TEST ... add each key back
14
# TEST ... change step
15
# TEST Confirm that overflow pages are getting reused
17
# TEST Take the source files and dbtest executable and enter their names as
18
# TEST the key with their contents as data. After all are entered, begin
19
# TEST looping through the entries; deleting some pairs and then readding them.
20
proc test008 { method {reopen 8} {debug 0} args} {
23
set tnum test00$reopen
24
set args [convert_args $method $args]
25
set omethod [convert_method $method]
27
if { [is_record_based $method] == 1 } {
28
puts "Test00$reopen skipping for method $method"
32
puts -nonewline "$tnum: $method filename=key filecontents=data pairs"
39
# Create the database and open the dictionary
41
set eindex [lsearch -exact $args "-env"]
43
# If we are using an env, then testfile should just be the db name.
44
# Otherwise it is the test directory and the name.
45
if { $eindex == -1 } {
46
set testfile $testdir/$tnum.db
51
set env [lindex $args $eindex]
52
set txnenv [is_txnenv $env]
54
append args " -auto_commit "
56
set testdir [get_home $env]
65
set db [eval {berkdb_open -create -mode 0644} \
66
$args {$omethod $testfile}]
67
error_check_good dbopen [is_valid_db $db] TRUE
73
# Here is the loop where we put and get each key/data pair
74
set file_list [get_file_list]
77
puts "\tTest00$reopen.a: Initial put/get loop"
78
foreach f $file_list {
84
error_check_good txn [is_valid_txn $t $env] TRUE
87
put_file $db $txn $pflags $f
89
error_check_good txn [$t commit] 0
94
error_check_good txn [is_valid_txn $t $env] TRUE
97
get_file $db $txn $gflags $f $t4
99
error_check_good txn [$t commit] 0
102
error_check_good Test00$reopen:diff($f,$t4) \
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 step through keys again (by increments) and
116
# delete all the entries, then re-insert them.
118
puts "\tTest00$reopen.b: Delete re-add loop"
119
foreach i "1 2 4 8 16" {
120
for {set ndx 0} {$ndx < $count} { incr ndx $i} {
121
if { $txnenv == 1 } {
123
error_check_good txn [is_valid_txn $t $env] TRUE
126
set r [eval {$db del} $txn {$names($ndx)}]
127
error_check_good db_del:$names($ndx) $r 0
128
if { $txnenv == 1 } {
129
error_check_good txn [$t commit] 0
132
for {set ndx 0} {$ndx < $count} { incr ndx $i} {
133
if { $txnenv == 1 } {
135
error_check_good txn [is_valid_txn $t $env] TRUE
138
put_file $db $txn $pflags $names($ndx)
139
if { $txnenv == 1 } {
140
error_check_good txn [$t commit] 0
146
error_check_good db_close [$db close] 0
147
set db [eval {berkdb_open} $args $testfile]
148
error_check_good dbopen [is_valid_db $db] TRUE
151
# Now, reopen the file and make sure the key/data pairs look right.
152
puts "\tTest00$reopen.c: Dump contents forward"
153
if { $txnenv == 1 } {
155
error_check_good txn [is_valid_txn $t $env] TRUE
158
dump_bin_file $db $txn $t1 test008.check
159
if { $txnenv == 1 } {
160
error_check_good txn [$t commit] 0
163
set oid [open $t2.tmp w]
164
foreach f $file_list {
172
error_check_good Test00$reopen:diff($t3,$t2) \
175
# Now, reopen the file and run the last test again in reverse direction.
176
puts "\tTest00$reopen.d: Dump contents backward"
177
if { $txnenv == 1 } {
179
error_check_good txn [is_valid_txn $t $env] TRUE
182
dump_bin_file_direction $db $txn $t1 test008.check "-last" "-prev"
183
if { $txnenv == 1 } {
184
error_check_good txn [$t commit] 0
189
error_check_good Test00$reopen:diff($t3,$t2) \
191
error_check_good close:$db [$db close] 0
194
proc test008.check { binfile tmpfile } {
198
error_check_good diff($binfile,$tmpfile) \
199
[filecmp $binfile $tmpfile] 0