1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2002,2008 Oracle. All rights reserved. 4# 5# $Id: test098.tcl,v 12.6 2008/01/08 20:58:53 bostic Exp $ 6# 7# TEST test098 8# TEST Test of DB_GET_RECNO and secondary indices. Open a primary and 9# TEST a secondary, and do a normal cursor get followed by a get_recno. 10# TEST (This is a smoke test for "Bug #1" in [#5811].) 11 12proc test098 { method args } { 13 source ./include.tcl 14 15 set omethod [convert_method $method] 16 set args [convert_args $method $args] 17 18 puts "Test098: $omethod ($args): DB_GET_RECNO and secondary indices." 19 20 if { [is_rbtree $method] != 1 } { 21 puts "\tTest098: Skipping for method $method." 22 return 23 } 24 25 set txnenv 0 26 set eindex [lsearch -exact $args "-env"] 27 set txn "" 28 set auto "" 29 # 30 # If we are using an env, then testfile should just be the db name. 31 # Otherwise it is the test directory and the name. 32 if { $eindex == -1 } { 33 set base $testdir/test098 34 set env NULL 35 } else { 36 set base test098 37 incr eindex 38 set env [lindex $args $eindex] 39 set rpcenv [is_rpcenv $env] 40 if { $rpcenv == 1 } { 41 puts "Test098: Skipping for RPC" 42 return 43 } 44 set txnenv [is_txnenv $env] 45 if { $txnenv == 1 } { 46 set auto " -auto_commit " 47 } 48 set testdir [get_home $env] 49 } 50 cleanup $testdir $env 51 52 puts "\tTest098.a: Set up databases." 53 54 set adb [eval {berkdb_open} $omethod $args $auto \ 55 {-create} $base-primary.db] 56 error_check_good adb_create [is_valid_db $adb] TRUE 57 58 set bdb [eval {berkdb_open} $omethod $args $auto \ 59 {-create} $base-secondary.db] 60 error_check_good bdb_create [is_valid_db $bdb] TRUE 61 62 set ret [eval $adb associate $auto [callback_n 0] $bdb] 63 error_check_good associate $ret 0 64 65 if { $txnenv == 1 } { 66 set t [$env txn] 67 error_check_good txn [is_valid_txn $t $env] TRUE 68 set txn "-txn $t" 69 } 70 set ret [eval {$adb put} $txn aaa data1] 71 error_check_good put $ret 0 72 if { $txnenv == 1 } { 73 error_check_good txn [$t commit] 0 74 } 75 76 set bc [$bdb cursor] 77 error_check_good cursor [is_valid_cursor $bc $bdb] TRUE 78 79 puts "\tTest098.b: c_get(DB_FIRST) on the secondary." 80 error_check_good get_first [$bc get -first] \ 81 [list [list [[callback_n 0] aaa data1] data1]] 82 83 puts "\tTest098.c: c_get(DB_GET_RECNO) on the secondary." 84 error_check_good get_recno [$bc get -get_recno] 1 85 86 error_check_good c_close [$bc close] 0 87 88 error_check_good bdb_close [$bdb close] 0 89 error_check_good adb_close [$adb close] 0 90} 91