mariadb/bdb/test/test066.tcl

100 lines
2.5 KiB
Tcl
Raw Normal View History

2001-03-05 01:42:05 +01:00
# See the file LICENSE for redistribution information.
#
2002-10-30 12:57:05 +01:00
# Copyright (c) 1999-2002
2001-03-05 01:42:05 +01:00
# Sleepycat Software. All rights reserved.
#
2002-10-30 12:57:05 +01:00
# $Id: test066.tcl,v 11.12 2002/05/24 15:24:56 sue Exp $
2001-03-05 01:42:05 +01:00
#
2002-10-30 12:57:05 +01:00
# TEST test066
# TEST Test of cursor overwrites of DB_CURRENT w/ duplicates.
# TEST
# TEST Make sure a cursor put to DB_CURRENT acts as an overwrite in a
# TEST database with duplicates.
2001-03-05 01:42:05 +01:00
proc test066 { method args } {
set omethod [convert_method $method]
set args [convert_args $method $args]
set tnum 66
if { [is_record_based $method] || [is_rbtree $method] } {
puts "Test0$tnum: Skipping for method $method."
return
}
puts "Test0$tnum: Test of cursor put to DB_CURRENT with duplicates."
source ./include.tcl
2002-10-30 12:57:05 +01:00
set txnenv 0
2001-03-05 01:42:05 +01:00
set eindex [lsearch -exact $args "-env"]
#
# If we are using an env, then testfile should just be the db name.
# Otherwise it is the test directory and the name.
if { $eindex == -1 } {
set testfile $testdir/test066.db
set env NULL
} else {
set testfile test066.db
incr eindex
set env [lindex $args $eindex]
2002-10-30 12:57:05 +01:00
set txnenv [is_txnenv $env]
if { $txnenv == 1 } {
append args " -auto_commit "
}
set testdir [get_home $env]
2001-03-05 01:42:05 +01:00
}
cleanup $testdir $env
2002-10-30 12:57:05 +01:00
set txn ""
2001-03-05 01:42:05 +01:00
set key "test"
set data "olddata"
set db [eval {berkdb_open -create -mode 0644 -dup} $omethod $args \
$testfile]
error_check_good db_open [is_valid_db $db] TRUE
2002-10-30 12:57:05 +01:00
if { $txnenv == 1 } {
set t [$env txn]
error_check_good txn [is_valid_txn $t $env] TRUE
set txn "-txn $t"
}
set ret [eval {$db put} $txn {$key [chop_data $method $data]}]
2001-03-05 01:42:05 +01:00
error_check_good db_put $ret 0
2002-10-30 12:57:05 +01:00
if { $txnenv == 1 } {
error_check_good txn [$t commit] 0
}
2001-03-05 01:42:05 +01:00
2002-10-30 12:57:05 +01:00
if { $txnenv == 1 } {
set t [$env txn]
error_check_good txn [is_valid_txn $t $env] TRUE
set txn "-txn $t"
}
set dbc [eval {$db cursor} $txn]
2001-03-05 01:42:05 +01:00
error_check_good db_cursor [is_valid_cursor $dbc $db] TRUE
set ret [$dbc get -first]
error_check_good db_get $ret [list [list $key [pad_data $method $data]]]
set newdata "newdata"
set ret [$dbc put -current [chop_data $method $newdata]]
error_check_good dbc_put $ret 0
# There should be only one (key,data) pair in the database, and this
# is it.
set ret [$dbc get -first]
error_check_good db_get_first $ret \
[list [list $key [pad_data $method $newdata]]]
# and this one should come up empty.
set ret [$dbc get -next]
error_check_good db_get_next $ret ""
error_check_good dbc_close [$dbc close] 0
2002-10-30 12:57:05 +01:00
if { $txnenv == 1 } {
error_check_good txn [$t commit] 0
}
2001-03-05 01:42:05 +01:00
error_check_good db_close [$db close] 0
puts "\tTest0$tnum: Test completed successfully."
}