1# See the file LICENSE for redistribution information.
2#
3# Copyright (c) 1996,2008 Oracle.  All rights reserved.
4#
5# $Id: txnscript.tcl,v 12.6 2008/01/08 20:58:53 bostic Exp $
6#
7# Txn003 script - outstanding child prepare script
8# Usage: txnscript envcmd dbcmd gidf key data
9# envcmd: command to open env
10# dbfile: name of database file
11# gidf: name of global id file
12# key: key to use
13# data: new data to use
14
15source ./include.tcl
16source $test_path/test.tcl
17source $test_path/testutils.tcl
18
19set usage "txnscript envcmd dbfile gidfile key data"
20
21# Verify usage
22if { $argc != 5 } {
23	puts stderr "FAIL:[timestamp] Usage: $usage"
24	exit
25}
26
27# Initialize arguments
28set envcmd [ lindex $argv 0 ]
29set dbfile [ lindex $argv 1 ]
30set gidfile [ lindex $argv 2 ]
31set key [ lindex $argv 3 ]
32set data [ lindex $argv 4 ]
33
34set dbenv [eval $envcmd]
35error_check_good envopen [is_valid_env $dbenv] TRUE
36
37set usedb 1
38set db [berkdb_open -auto_commit -env $dbenv $dbfile]
39error_check_good dbopen [is_valid_db $db] TRUE
40
41puts "\tTxnscript.a: begin parent and child txn"
42set parent [$dbenv txn]
43error_check_good parent [is_valid_txn $parent $dbenv] TRUE
44set child [$dbenv txn -parent $parent]
45error_check_good parent [is_valid_txn $child $dbenv] TRUE
46
47puts "\tTxnscript.b: Modify data"
48error_check_good db_put [$db put -txn $child $key $data] 0
49
50set gfd [open $gidfile w+]
51set gid [make_gid txnscript:$parent]
52puts $gfd $gid
53puts "\tTxnscript.c: Prepare parent only"
54error_check_good txn_prepare:$parent [$parent prepare $gid] 0
55close $gfd
56
57puts "\tTxnscript.d: Check child handle"
58set stat [catch {$child abort} ret]
59error_check_good child_handle $stat 1
60error_check_good child_h2 [is_substr $ret "invalid command name"] 1
61
62#
63# We do not close the db or env, but exit with the txns outstanding.
64#
65puts "\tTxnscript completed successfully"
66flush stdout
67