recd004.tcl
Upload User: tsgydb
Upload Date: 2007-04-14
Package Size: 10674k
Code Size: 3k
Category:

MySQL

Development Platform:

Visual C++

  1. # See the file LICENSE for redistribution information.
  2. #
  3. # Copyright (c) 1996, 1997, 1998, 1999, 2000
  4. # Sleepycat Software.  All rights reserved.
  5. #
  6. # $Id: recd004.tcl,v 11.21 2000/12/11 17:24:55 sue Exp $
  7. #
  8. # Recovery Test #4.
  9. # Verify that we work correctly when big keys get elevated.
  10. proc recd004 { method {select 0} args} {
  11. source ./include.tcl
  12. global rand_init
  13. set opts [convert_args $method $args]
  14. set omethod [convert_method $method]
  15. set pgindex [lsearch -exact $args "-pagesize"]
  16. if { $pgindex != -1 } {
  17. puts "Recd004: skipping for specific pagesizes"
  18. return
  19. }
  20. if { [is_record_based $method] == 1 } {
  21. puts "Recd004 skipping for method $method"
  22. return
  23. }
  24. puts "Recd004: $method big-key on internal page recovery tests"
  25. berkdb srand $rand_init
  26. env_cleanup $testdir
  27. set testfile recd004.db
  28. set testfile2 recd004-2.db
  29. set eflags "-create -txn -home $testdir"
  30. puts "tRecd004.a: creating environment"
  31. set env_cmd "berkdb env $eflags"
  32. set dbenv [eval $env_cmd]
  33. error_check_bad dbenv $dbenv NULL
  34. # Create the databases. We will use a small page size so that we
  35. # elevate quickly
  36. set oflags "-create -mode 0644 
  37.     $omethod -env $dbenv $opts -pagesize 512 $testfile"
  38. set db [eval {berkdb_open} $oflags]
  39. error_check_bad db_open $db NULL
  40. error_check_good db_open [is_substr $db db] 1
  41. error_check_good db_close [$db close] 0
  42. set oflags "-create -mode 0644 
  43.     $omethod -env $dbenv $opts -pagesize 512 $testfile2"
  44. set db [eval {berkdb_open} $oflags]
  45. error_check_bad db_open $db NULL
  46. error_check_good db_open [is_substr $db db] 1
  47. error_check_good db_close [$db close] 0
  48. reset_env $dbenv
  49. # List of recovery tests: {CMD MSG} pairs
  50. set slist {
  51. { {big_populate DB TXNID $n} "Recd004.b: big key elevation"}
  52. { {unpopulate DB TXNID 0} "Recd004.c: Remove keys"}
  53. }
  54. # If pages are 512 bytes, then adding 512 key/data pairs
  55. # should be more than sufficient.
  56. set n 512
  57. foreach pair $slist {
  58. set cmd [subst [lindex $pair 0]]
  59. set msg [lindex $pair 1]
  60. if { $select != 0 } {
  61. set tag [lindex $msg 0]
  62. set tail [expr [string length $tag] - 2]
  63. set tag [string range $tag $tail $tail]
  64. if { [lsearch $select $tag] == -1 } {
  65. continue
  66. }
  67. }
  68. op_recover abort $testdir $env_cmd $testfile $cmd $msg
  69. op_recover commit $testdir $env_cmd $testfile $cmd $msg
  70. op_recover prepare $testdir $env_cmd $testfile2 $cmd $msg
  71. op_recover prepare-abort $testdir $env_cmd $testfile2 
  72. $cmd $msg
  73. op_recover prepare-commit $testdir $env_cmd $testfile2 
  74. $cmd $msg
  75. }
  76. puts "tRecd004.d: Verify db_printlog can read logfile"
  77. set tmpfile $testdir/printlog.out
  78. set stat [catch {exec $util_path/db_printlog -h $testdir 
  79.     > $tmpfile} ret]
  80. error_check_good db_printlog $stat 0
  81. fileremove $tmpfile
  82. }