1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1999-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Verify record numbering across split/reverse splits and recovery.
10
proc recd009 { method {select 0} args} {
14
if { [is_rbtree $method] != 1 && [is_rrecno $method] != 1} {
15
puts "Recd009 skipping for method $method."
19
set opts [convert_args $method $args]
20
set method [convert_method $method]
22
puts "\tRecd009: Test record numbers across splits and recovery"
24
set testfile recd009.db
30
puts "\tRecd009.a: Create $method environment and database."
31
set flags "-create -txn -home $testdir"
33
set env_cmd "berkdb_env $flags"
34
set dbenv [eval $env_cmd]
35
error_check_good dbenv [is_valid_env $dbenv] TRUE
37
set oflags "-env $dbenv -pagesize 8192 -create -mode 0644 $opts $method"
38
set db [eval {berkdb_open} $oflags $testfile]
39
error_check_good dbopen [is_valid_db $db] TRUE
41
# Fill page with small key/data pairs. Keep at leaf.
42
puts "\tRecd009.b: Fill page with $nkeys small key/data pairs."
43
for { set i 1 } { $i <= $nkeys } { incr i } {
44
if { [is_recno $method] == 1 } {
49
set ret [$db put $key $data$i]
50
error_check_good dbput $ret 0
52
error_check_good db_close [$db close] 0
53
error_check_good env_close [$dbenv close] 0
55
set newnkeys [expr $nkeys + 1]
56
# List of recovery tests: {CMD MSG} pairs.
58
{ {recd009_split DB TXNID 1 $method $newnkeys $mkeys}
60
{ {recd009_split DB TXNID 0 $method $newnkeys $mkeys}
61
"Recd009.d: reverse split"}
65
set cmd [subst [lindex $pair 0]]
66
set msg [lindex $pair 1]
68
set tag [lindex $msg 0]
69
set tail [expr [string length $tag] - 2]
70
set tag [string range $tag $tail $tail]
71
if { [lsearch $select $tag] == -1 } {
75
set reverse [string first "reverse" $msg]
76
if { $reverse == -1 } {
87
op_recover abort $testdir $env_cmd $testfile $cmd $msg
88
recd009_recnocheck $testdir $testfile $opts $abortkeys $abortpg
89
op_recover commit $testdir $env_cmd $testfile $cmd $msg
90
recd009_recnocheck $testdir $testfile $opts \
93
puts "\tRecd009.e: Verify db_printlog can read logfile"
94
set tmpfile $testdir/printlog.out
95
set stat [catch {exec $util_path/db_printlog -h $testdir \
97
error_check_good db_printlog $stat 0
102
# This procedure verifies that the database has only numkeys number
103
# of keys and that they are in order.
105
proc recd009_recnocheck { tdir testfile opts numkeys numpg} {
108
set db [eval {berkdb_open} $opts $tdir/$testfile]
109
error_check_good dbopen [is_valid_db $db] TRUE
111
puts "\tRecd009_recnocheck: Verify page count of $numpg on split."
113
error_check_bad stat:check-split [is_substr $stat \
114
"{{Internal pages} 0}"] $numpg
116
set type [$db get_type]
118
error_check_good dbcursor [is_valid_cursor $dbc $db] TRUE
120
puts "\tRecd009_recnocheck: Checking $numkeys record numbers."
121
for {set d [$dbc get -first]} { [llength $d] != 0 } {
122
set d [$dbc get -next]} {
123
if { [is_btree $type] } {
124
set thisi [$dbc get -get_recno]
126
set thisi [lindex [lindex $d 0] 0]
128
error_check_good recno_check $i $thisi
129
error_check_good record_count [expr $i <= $numkeys] 1
132
error_check_good curs_close [$dbc close] 0
133
error_check_good db_close [$db close] 0
136
proc recd009_split { db txn split method nkeys mkeys } {
142
set isrecno [is_recno $method]
143
# if mkeys is above 1000, need to adjust below for lexical order
145
puts "\tRecd009_split: Add $mkeys pairs to force split."
146
for {set i $nkeys} { $i <= $mkeys } { incr i } {
147
if { $isrecno == 1 } {
152
} elseif { $i >= 10 } {
158
set ret [$db put -txn $txn $key $data$i]
159
error_check_good dbput:more $ret 0
162
puts "\tRecd009_split: Delete added keys to force reverse split."
163
# Since rrecno renumbers, we delete downward.
164
for {set i $mkeys} { $i >= $nkeys } { set i [expr $i - 1] } {
165
if { $isrecno == 1 } {
170
} elseif { $i >= 10 } {
176
error_check_good db_del:$i [$db del -txn $txn $key] 0