1# See the file LICENSE for redistribution information.
2#
3# Copyright (c) 1996,2008 Oracle.  All rights reserved.
4#
5# $Id: recd15scr.tcl,v 12.6 2008/01/08 20:58:53 bostic Exp $
6#
7# Recd15 - lots of txns - txn prepare script
8# Usage: recd15script envcmd dbcmd gidf numtxns
9# envcmd: command to open env
10# dbfile: name of database file
11# gidf: name of global id file
12# numtxns: number of txns to start
13
14source ./include.tcl
15source $test_path/test.tcl
16source $test_path/testutils.tcl
17
18set usage "recd15script envcmd dbfile gidfile numtxns"
19
20# Verify usage
21if { $argc != 4 } {
22	puts stderr "FAIL:[timestamp] Usage: $usage"
23	exit
24}
25
26# Initialize arguments
27set envcmd [ lindex $argv 0 ]
28set dbfile [ lindex $argv 1 ]
29set gidfile [ lindex $argv 2 ]
30set numtxns [ lindex $argv 3 ]
31
32set txnmax [expr $numtxns + 5]
33set dbenv [eval $envcmd]
34error_check_good envopen [is_valid_env $dbenv] TRUE
35
36set usedb 0
37if { $dbfile != "NULL" } {
38	set usedb 1
39	set db [berkdb_open -auto_commit -env $dbenv $dbfile]
40	error_check_good dbopen [is_valid_db $db] TRUE
41}
42
43puts "\tRecd015script.a: Begin $numtxns txns"
44for {set i 0} {$i < $numtxns} {incr i} {
45	set t [$dbenv txn]
46	error_check_good txnbegin($i) [is_valid_txn $t $dbenv] TRUE
47	set txns($i) $t
48	if { $usedb } {
49		set dbc [$db cursor -txn $t]
50		error_check_good cursor($i) [is_valid_cursor $dbc $db] TRUE
51		set curs($i) $dbc
52	}
53}
54
55puts "\tRecd015script.b: Prepare $numtxns txns"
56set gfd [open $gidfile w+]
57for {set i 0} {$i < $numtxns} {incr i} {
58	if { $usedb } {
59		set dbc $curs($i)
60		error_check_good dbc_close [$dbc close] 0
61	}
62	set t $txns($i)
63	set gid [make_gid recd015script:$t]
64	puts $gfd $gid
65	error_check_good txn_prepare:$t [$t prepare $gid] 0
66}
67close $gfd
68
69#
70# We do not close the db or env, but exit with the txns outstanding.
71#
72puts "\tRecd015script completed successfully"
73flush stdout
74