1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Verify that deleting and reading duplicates results in correct ordering.
10
proc test058 { method args } {
14
# If we are using an env, then skip this test. It needs its own.
15
set eindex [lsearch -exact $args "-env"]
16
if { $eindex != -1 } {
18
set env [lindex $args $eindex]
19
puts "Test058 skipping for env $env"
22
set args [convert_args $method $args]
24
set args [split_encargs $args encargs]
25
set omethod [convert_method $method]
27
if { [is_record_based $method] == 1 || [is_rbtree $method] == 1 } {
28
puts "Test058: skipping for method $method"
31
puts "Test058: $method delete dups after inserting after duped key."
35
set eflags "-create -txn $encargs -home $testdir"
36
set env [eval {berkdb_env} $eflags]
37
error_check_good env [is_valid_env $env] TRUE
40
set flags "-auto_commit -create -mode 0644 -dup -env $env $args"
41
set db [eval {berkdb_open} $flags $omethod "test058.db"]
42
error_check_good dbopen [is_valid_db $db] TRUE
49
puts "\tTest058.a: Adding 10 duplicates"
51
for { set i 0 } { $i < 10 } {incr i} {
53
[eval {$db put} $tflags {doghouse $i"DUPLICATE_DATA_VALUE"}]
54
error_check_good db_put $ret 0
57
puts "\tTest058.b: Adding key after duplicates"
58
# Now add one more key/data AFTER the dup set.
59
set ret [eval {$db put} $tflags {zebrahouse NOT_A_DUP}]
60
error_check_good db_put $ret 0
62
error_check_good txn_commit [$tn commit] 0
65
error_check_good txnbegin [is_substr $tn $env] 1
68
# Now delete everything
69
puts "\tTest058.c: Deleting duplicated key"
70
set ret [eval {$db del} $tflags {doghouse}]
71
error_check_good del $ret 0
73
# Now reput everything
75
abcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuvabcdefghijklmnopqrtsuv
77
puts "\tTest058.d: Reputting duplicates with big data vals"
78
for { set i 0 } { $i < 10 } {incr i} {
79
set ret [eval {$db put} \
80
$tflags {doghouse $i"DUPLICATE_DATA_VALUE"$pad}]
81
error_check_good db_put $ret 0
83
error_check_good txn_commit [$tn commit] 0
85
# Check duplicates for order
87
error_check_good db_cursor [is_substr $dbc $db] 1
89
puts "\tTest058.e: Verifying that duplicates are in order."
91
for { set ret [$dbc get -set doghouse] } \
92
{$i < 10 && [llength $ret] != 0} \
93
{ set ret [$dbc get -nextdup] } {
94
set data [lindex [lindex $ret 0] 1]
96
duplicate_value $data $i"DUPLICATE_DATA_VALUE"$pad
100
error_check_good dbc_close [$dbc close] 0
101
error_check_good db_close [$db close] 0