test058.tcl
上传用户:tsgydb
上传日期:2007-04-14
资源大小:10674k
文件大小:3k
源码类别:

MySQL数据库

开发平台:

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: test058.tcl,v 11.14 2000/08/25 14:21:57 sue Exp $
  7. #
  8. proc test058 { method args } {
  9. source ./include.tcl
  10. #
  11. # If we are using an env, then skip this test.  It needs its own.
  12. set eindex [lsearch -exact $args "-env"]
  13. if { $eindex != -1 } {
  14. incr eindex
  15. set env [lindex $args $eindex]
  16. puts "Test058 skipping for env $env"
  17. return
  18. }
  19. set args [convert_args $method $args]
  20. set omethod [convert_method $method]
  21. if { [is_record_based $method] == 1 || [is_rbtree $method] == 1 } {
  22. puts "Test058: skipping for method $method"
  23. return
  24. }
  25. puts "Test058: $method delete dups after inserting after duped key."
  26. # environment
  27. env_cleanup $testdir
  28. set eflags "-create -txn -home $testdir"
  29. set env [eval {berkdb env} $eflags]
  30. error_check_good env [is_valid_env $env] TRUE
  31. # db open
  32. set flags "-create -mode 0644 -dup -env $env $args"
  33. set db [eval {berkdb_open} $flags $omethod "test058.db"]
  34. error_check_good dbopen [is_valid_db $db] TRUE
  35. set tn ""
  36. set tid ""
  37. set tn [$env txn]
  38. set tflags "-txn $tn"
  39. puts "tTest058.a: Adding 10 duplicates"
  40. # Add a bunch of dups
  41. for { set i 0 } { $i < 10 } {incr i} {
  42. set ret 
  43.     [eval {$db put} $tflags {doghouse $i"DUPLICATE_DATA_VALUE"}]
  44. error_check_good db_put $ret 0
  45. }
  46. puts "tTest058.b: Adding key after duplicates"
  47. # Now add one more key/data AFTER the dup set.
  48. set ret [eval {$db put} $tflags {zebrahouse NOT_A_DUP}]
  49. error_check_good db_put $ret 0
  50. error_check_good txn_commit [$tn commit] 0
  51. set tn [$env txn]
  52. error_check_good txnbegin [is_substr $tn $env] 1
  53. set tflags "-txn $tn"
  54. # Now delete everything
  55. puts "tTest058.c: Deleting duplicated key"
  56. set ret [eval {$db del} $tflags {doghouse}]
  57. error_check_good del $ret 0
  58. # Now reput everything
  59. set pad 
  60.     abcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuv
  61. puts "tTest058.d: Reputting duplicates with big data vals"
  62. for { set i 0 } { $i < 10 } {incr i} {
  63. set ret [eval {$db put} 
  64.     $tflags {doghouse $i"DUPLICATE_DATA_VALUE"$pad}]
  65. error_check_good db_put $ret 0
  66. }
  67. error_check_good txn_commit [$tn commit] 0
  68. # Check duplicates for order
  69. set dbc [$db cursor]
  70. error_check_good db_cursor [is_substr $dbc $db] 1
  71. puts "tTest058.e: Verifying that duplicates are in order."
  72. set i 0
  73. for { set ret [$dbc get -set doghouse] } 
  74.     {$i < 10 && [llength $ret] != 0} 
  75.     { set ret [$dbc get -nextdup] } {
  76. set data [lindex [lindex $ret 0] 1]
  77. error_check_good 
  78.     duplicate_value $data $i"DUPLICATE_DATA_VALUE"$pad
  79. incr i
  80. }
  81. error_check_good dbc_close [$dbc close] 0
  82. error_check_good db_close [$db close] 0
  83. reset_env $env
  84. }