1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1999-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Test deleting Subdbs with overflow pages
10
# TEST Create 1 db with many large subdbs.
11
# TEST Test subdatabases with overflow pages.
12
proc subdb011 { method {ndups 13} {nsubdbs 10} args} {
16
set args [convert_args $method $args]
17
set omethod [convert_method $method]
19
if { [is_queue $method] == 1 || [is_fixed_length $method] == 1 } {
20
puts "Subdb011: skipping for method $method"
26
set eindex [lsearch -exact $args "-env"]
28
# If we are using an env, then testfile should just be the db name.
29
# Otherwise it is the test directory and the name.
30
if { $eindex == -1 } {
31
set testfile $testdir/subdb011.db
35
set testfile subdb011.db
37
set env [lindex $args $eindex]
38
set envargs " -env $env "
39
set txnenv [is_txnenv $env]
41
append args " -auto_commit "
42
append envargs " -auto_commit "
48
set testdir [get_home $env]
49
set tfpath $testdir/$testfile
52
# Create the database and open the dictionary
57
# Here is the loop where we put and get each key/data pair
58
set file_list [get_file_list]
59
if { $max_files != 0 && [llength $file_list] > $max_files } {
60
set fend [expr $max_files - 1]
61
set file_list [lrange $file_list 0 $fend]
63
set flen [llength $file_list]
64
puts "Subdb011: $method ($args) $ndups overflow dups with \
65
$flen filename=key filecontents=data pairs"
67
puts "\tSubdb011.a: Create each of $nsubdbs subdbs and dups"
71
foreach f $file_list {
72
set i [expr $i % $nsubdbs]
73
if { [is_record_based $method] == 1 } {
74
set key [expr $count + 1]
75
set names([expr $count + 1]) $f
79
# Should really catch errors
81
fconfigure $fid -translation binary
82
set filecont [read $fid]
86
set db [eval {berkdb_open -create -mode 0644} \
87
$args {$omethod $testfile $subdb}]
88
error_check_good dbopen [is_valid_db $db] TRUE
89
for {set dup 0} {$dup < $ndups} {incr dup} {
90
set data $dup:$filecont
93
error_check_good txn [is_valid_txn $t $env] TRUE
96
set ret [eval {$db put} $txn {$key \
97
[chop_data $method $data]}]
98
error_check_good put $ret 0
100
error_check_good txn [$t commit] 0
103
error_check_good dbclose [$db close] 0
108
puts "\tSubdb011.b: Verify overflow pages"
109
foreach subdb $slist {
110
set db [eval {berkdb_open -create -mode 0644} \
111
$args {$omethod $testfile $subdb}]
112
error_check_good dbopen [is_valid_db $db] TRUE
115
# What everyone else calls overflow pages, hash calls "big
116
# pages", so we need to special-case hash here. (Hash
117
# overflow pages are additional pages after the first in a
119
if { [string compare [$db get_type] hash] == 0 } {
120
error_check_bad overflow \
121
[is_substr $stat "{{Number of big pages} 0}"] 1
123
error_check_bad overflow \
124
[is_substr $stat "{{Overflow pages} 0}"] 1
126
error_check_good dbclose [$db close] 0
129
puts "\tSubdb011.c: Delete subdatabases"
130
for {set i $nsubdbs} {$i > 0} {set i [expr $i - 1]} {
132
# Randomly delete a subdatabase
133
set sindex [berkdb random_int 0 [expr $i - 1]]
134
set subdb [lindex $slist $sindex]
136
# Delete the one we did from the list
137
set slist [lreplace $slist $sindex $sindex]
138
error_check_good file_exists_before [file exists $tfpath] 1
139
error_check_good db_remove [eval {berkdb dbremove} $envargs \
140
{$testfile $subdb}] 0