1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1999-2002
4
# Sleepycat Software. All rights reserved.
6
# $Id: test066.tcl,v 11.12 2002/05/24 15:24:56 sue Exp $
9
# TEST Test of cursor overwrites of DB_CURRENT w/ duplicates.
11
# TEST Make sure a cursor put to DB_CURRENT acts as an overwrite in a
12
# TEST database with duplicates.
13
proc test066 { method args } {
14
set omethod [convert_method $method]
15
set args [convert_args $method $args]
19
if { [is_record_based $method] || [is_rbtree $method] } {
20
puts "Test0$tnum: Skipping for method $method."
24
puts "Test0$tnum: Test of cursor put to DB_CURRENT with duplicates."
29
set eindex [lsearch -exact $args "-env"]
31
# If we are using an env, then testfile should just be the db name.
32
# Otherwise it is the test directory and the name.
33
if { $eindex == -1 } {
34
set testfile $testdir/test066.db
37
set testfile test066.db
39
set env [lindex $args $eindex]
40
set txnenv [is_txnenv $env]
42
append args " -auto_commit "
44
set testdir [get_home $env]
52
set db [eval {berkdb_open -create -mode 0644 -dup} $omethod $args \
54
error_check_good db_open [is_valid_db $db] TRUE
58
error_check_good txn [is_valid_txn $t $env] TRUE
61
set ret [eval {$db put} $txn {$key [chop_data $method $data]}]
62
error_check_good db_put $ret 0
64
error_check_good txn [$t commit] 0
69
error_check_good txn [is_valid_txn $t $env] TRUE
72
set dbc [eval {$db cursor} $txn]
73
error_check_good db_cursor [is_valid_cursor $dbc $db] TRUE
75
set ret [$dbc get -first]
76
error_check_good db_get $ret [list [list $key [pad_data $method $data]]]
79
set ret [$dbc put -current [chop_data $method $newdata]]
80
error_check_good dbc_put $ret 0
82
# There should be only one (key,data) pair in the database, and this
84
set ret [$dbc get -first]
85
error_check_good db_get_first $ret \
86
[list [list $key [pad_data $method $newdata]]]
88
# and this one should come up empty.
89
set ret [$dbc get -next]
90
error_check_good db_get_next $ret ""
92
error_check_good dbc_close [$dbc close] 0
94
error_check_good txn [$t commit] 0
96
error_check_good db_close [$db close] 0
98
puts "\tTest0$tnum: Test completed successfully."