summaryrefslogtreecommitdiff
path: root/db/test/recd007.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'db/test/recd007.tcl')
-rw-r--r--db/test/recd007.tcl141
1 files changed, 136 insertions, 5 deletions
diff --git a/db/test/recd007.tcl b/db/test/recd007.tcl
index 9764d840f..266ab2200 100644
--- a/db/test/recd007.tcl
+++ b/db/test/recd007.tcl
@@ -1,9 +1,9 @@
# See the file LICENSE for redistribution information.
#
-# Copyright (c) 1999-2004
-# Sleepycat Software. All rights reserved.
+# Copyright (c) 1999-2006
+# Oracle Corporation. All rights reserved.
#
-# $Id: recd007.tcl,v 11.64 2004/07/07 19:08:21 carol Exp $
+# $Id: recd007.tcl,v 12.6 2006/08/24 14:46:36 bostic Exp $
#
# TEST recd007
# TEST File create/delete tests.
@@ -51,6 +51,7 @@ proc recd007 { method args} {
set fixed_len [expr $pg / 4]
error_check_good db_close [$db close] 0
error_check_good dbremove [berkdb dbremove -env $env $testfile] 0
+ error_check_good log_flush [$env log_flush] 0
error_check_good envclose [$env close] 0
# Convert the args again because fixed_len is now real.
@@ -110,6 +111,7 @@ proc recd007 { method args} {
{ {"predestroy" "postdestroy"} "Recd007.o: predestroy/postdestroy"}
{ {"postdestroy" "postdestroy"} "Recd007.p: postdestroy/postdestroy"}
}
+
foreach op { dbremove dbrename dbtruncate } {
foreach pair $rlist {
set cmd [lindex $pair 0]
@@ -186,6 +188,7 @@ proc do_file_recover_create { dir env_cmd method opts dbfile sub cmd msg } {
puts "\tSkipping for method $method"
$env test copy none
$env test abort none
+ error_check_good log_flush [$env log_flush] 0
error_check_good env_close [$env close] 0
return
}
@@ -280,6 +283,7 @@ proc do_file_recover_create { dir env_cmd method opts dbfile sub cmd msg } {
copy_extent_file $dir $dbfile init
}
}
+ error_check_good log_flush [$env log_flush] 0
error_check_good env_close [$env close] 0
#
@@ -555,6 +559,7 @@ proc do_file_recover_delete { dir env_cmd method opts dbfile sub cmd msg op } {
[dbdump_diff $dflags $init_file $dir $dbfile] 0
}
$env mpool_sync
+ error_check_good log_flush [$env log_flush] 0
error_check_good env_close [$env close] 0
catch { file copy -force $dir/$dbfile $init_file } res
if { [is_queue $method] == 1} {
@@ -585,6 +590,7 @@ proc do_file_recover_delete { dir env_cmd method opts dbfile sub cmd msg op } {
#
set env [eval $env_cmd]
recd007_check $op $sub $dir $dbfile $subdb $new $env $oflags
+ error_check_good log_flush [$env log_flush] 0
error_check_good env_close [$env close] 0
} else {
#
@@ -623,6 +629,7 @@ proc do_file_recover_delete { dir env_cmd method opts dbfile sub cmd msg op } {
if { [string first "none" $abort] != -1} {
set env [eval $env_cmd]
recd007_check $op $sub $dir $dbfile $subdb $new $env $oflags
+ error_check_good log_flush [$env log_flush] 0
error_check_good env_close [$env close] 0
} else {
#
@@ -668,6 +675,7 @@ proc do_file_recover_delmk { dir env_cmd method opts dbfile } {
}
set data1 recd007_data
set data2 NEWrecd007_data2
+ set data3 LASTrecd007_data3
set oflags \
"-create $omethod -auto_commit -mode 0644 $opts $dbfile"
@@ -683,6 +691,7 @@ proc do_file_recover_delmk { dir env_cmd method opts dbfile } {
error_check_good db_put $ret 0
error_check_good commit [$txn commit] 0
error_check_good db_close [$db close] 0
+ file copy -force $testdir/$dbfile $testdir/${dbfile}.1
set ret \
[catch { berkdb dbremove -env $env -auto_commit $dbfile } remret]
@@ -717,7 +726,7 @@ proc do_file_recover_delmk { dir env_cmd method opts dbfile } {
}
puts "complete"
error_check_good db_recover $stat 0
- error_check_good db_recover.1 [file exists $dir/$dbfile] 1
+ error_check_good file_exist [file exists $dir/$dbfile] 1
#
# Since we ran recovery on the open db/env, we need to
# catch these calls. Basically they are there to clean
@@ -726,6 +735,7 @@ proc do_file_recover_delmk { dir env_cmd method opts dbfile } {
set stat [catch {$db close} ret]
error_check_bad dbclose_after_remove $stat 0
error_check_good dbclose_after_remove [is_substr $ret recovery] 1
+ set stat [catch {$env log_flush} ret]
set stat [catch {$env close} ret]
error_check_bad envclose_after_remove $stat 0
error_check_good envclose_after_remove [is_substr $ret recovery] 1
@@ -744,6 +754,127 @@ proc do_file_recover_delmk { dir env_cmd method opts dbfile } {
error_check_good data2 [lindex $kd 1] [pad_data $method $data2]
error_check_good dbclose [$db close] 0
+ error_check_good log_flush [$env log_flush] 0
+ error_check_good envclose [$env close] 0
+
+ #
+ # Copy back the original database and run recovery again.
+ # SR [#13026]
+ #
+ puts "\t\tRecover from first database"
+ file copy -force $testdir/${dbfile}.1 $testdir/$dbfile
+ berkdb debug_check
+ puts -nonewline "\t\tAbout to run recovery ... "
+ flush stdout
+
+ set stat [catch {exec $util_path/db_recover -h $dir -c} result]
+ if { $stat == 1 } {
+ error "FAIL: Recovery error: $result."
+ return
+ }
+ puts "complete"
+ error_check_good db_recover $stat 0
+ error_check_good db_recover.1 [file exists $dir/$dbfile] 1
+
+ #
+ # Reopen env and db and verify 2nd database is there.
+ #
+ set env [eval $env_cmd]
+ error_check_good env_open [is_valid_env $env] TRUE
+ set db [eval {berkdb_open_noerr} -env $env $oflags]
+ error_check_good db_open [is_valid_db $db] TRUE
+ set ret [$db get $key]
+ error_check_good dbget [llength $ret] 1
+ set kd [lindex $ret 0]
+ error_check_good key [lindex $kd 0] $key
+ error_check_good data2 [lindex $kd 1] [pad_data $method $data2]
+
+ error_check_good dbclose [$db close] 0
+
+ file copy -force $testdir/$dbfile $testdir/${dbfile}.2
+
+ puts "\t\tRemove second db"
+ set ret \
+ [catch { berkdb dbremove -env $env -auto_commit $dbfile } remret]
+
+ #
+ # Operation was committed, verify it does
+ # not exist.
+ #
+ puts "\t\tCommand executed and committed."
+ error_check_good dbremove $ret 0
+ error_check_good dbremove.2 [file exists $dir/$dbfile] 0
+
+ #
+ # Now create a new db with the same name.
+ #
+ puts "\t\tAdd a third version of the database"
+ set db [eval {berkdb_open_noerr} -env $env $oflags]
+ error_check_good db_open [is_valid_db $db] TRUE
+ set txn [$env txn]
+ set ret [$db put -txn $txn $key [chop_data $method $data3]]
+ error_check_good db_put $ret 0
+ error_check_good commit [$txn commit] 0
+ error_check_good db_sync [$db sync] 0
+
+ berkdb debug_check
+ puts -nonewline "\t\tAbout to run recovery ... "
+ flush stdout
+
+ set stat [catch {exec $util_path/db_recover -h $dir -c} result]
+ if { $stat == 1 } {
+ error "FAIL: Recovery error: $result."
+ return
+ }
+ puts "complete"
+ error_check_good db_recover $stat 0
+ error_check_good file_exist [file exists $dir/$dbfile] 1
+
+ #
+ # Since we ran recovery on the open db/env, we need to
+ # catch these calls to clean up the Tcl widgets.
+ #
+ set stat [catch {$db close} ret]
+ error_check_bad dbclose_after_remove $stat 0
+ error_check_good dbclose_after_remove [is_substr $ret recovery] 1
+ set stat [catch {$env log_flush} ret]
+ set stat [catch {$env close} ret]
+ error_check_bad envclose_after_remove $stat 0
+ error_check_good envclose_after_remove [is_substr $ret recovery] 1
+
+ #
+ # Copy back the second database and run recovery again.
+ #
+ puts "\t\tRecover from second database"
+ file copy -force $testdir/${dbfile}.2 $testdir/$dbfile
+ berkdb debug_check
+ puts -nonewline "\t\tAbout to run recovery ... "
+ flush stdout
+
+ set stat [catch {exec $util_path/db_recover -h $dir -c} result]
+ if { $stat == 1 } {
+ error "FAIL: Recovery error: $result."
+ return
+ }
+ puts "complete"
+ error_check_good db_recover $stat 0
+ error_check_good file_exist.2 [file exists $dir/$dbfile] 1
+
+ #
+ # Reopen env and db and verify 3rd database is there.
+ #
+ set env [eval $env_cmd]
+ error_check_good env_open [is_valid_env $env] TRUE
+ set db [eval {berkdb_open} -env $env $oflags]
+ error_check_good db_open [is_valid_db $db] TRUE
+ set ret [$db get $key]
+ error_check_good dbget [llength $ret] 1
+ set kd [lindex $ret 0]
+ error_check_good key [lindex $kd 0] $key
+ error_check_good data2 [lindex $kd 1] [pad_data $method $data3]
+
+ error_check_good dbclose [$db close] 0
+ error_check_good log_flush [$env log_flush] 0
error_check_good envclose [$env close] 0
}
@@ -811,7 +942,7 @@ proc recd007_check { op sub dir dbfile subdb new env oflags } {
#
if { $sub == 0 } {
if { $op == "dbremove" } {
- error_check_good $op:not-exist \
+ error_check_good $op:not-exist:$dir/$dbfile \
[file exists $dir/$dbfile] 0
} elseif { $op == "dbrename"} {
error_check_good $op:exist \