File: recd15scr.tcl

package info (click to toggle)
evolution-data-server 1.0.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 39,504 kB
  • ctags: 26,423
  • sloc: ansic: 175,347; tcl: 30,499; sh: 20,699; perl: 11,320; xml: 9,039; java: 7,653; cpp: 6,029; makefile: 4,866; awk: 1,338; yacc: 1,103; sed: 772; cs: 505; lex: 134; asm: 14
file content (74 lines) | stat: -rw-r--r-- 1,847 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1996-2002
#	Sleepycat Software.  All rights reserved.
#
# $Id: recd15scr.tcl,v 1.1.1.1 2003/11/20 22:13:58 toshok Exp $
#
# Recd15 - lots of txns - txn prepare script
# Usage: recd15script envcmd dbcmd gidf numtxns
# envcmd: command to open env
# dbfile: name of database file
# gidf: name of global id file
# numtxns: number of txns to start

source ./include.tcl
source $test_path/test.tcl
source $test_path/testutils.tcl

set usage "recd15script envcmd dbfile gidfile numtxns"

# Verify usage
if { $argc != 4 } {
	puts stderr "FAIL:[timestamp] Usage: $usage"
	exit
}

# Initialize arguments
set envcmd [ lindex $argv 0 ]
set dbfile [ lindex $argv 1 ]
set gidfile [ lindex $argv 2 ]
set numtxns [ lindex $argv 3 ]

set txnmax [expr $numtxns + 5]
set dbenv [eval $envcmd]
error_check_good envopen [is_valid_env $dbenv] TRUE

set usedb 0
if { $dbfile != "NULL" } {
	set usedb 1
	set db [berkdb_open -auto_commit -env $dbenv $dbfile]
	error_check_good dbopen [is_valid_db $db] TRUE
}

puts "\tRecd015script.a: Begin $numtxns txns"
for {set i 0} {$i < $numtxns} {incr i} {
	set t [$dbenv txn]
	error_check_good txnbegin($i) [is_valid_txn $t $dbenv] TRUE
	set txns($i) $t
	if { $usedb } {
		set dbc [$db cursor -txn $t]
		error_check_good cursor($i) [is_valid_cursor $dbc $db] TRUE
		set curs($i) $dbc
	}
}

puts "\tRecd015script.b: Prepare $numtxns txns"
set gfd [open $gidfile w+]
for {set i 0} {$i < $numtxns} {incr i} {
	if { $usedb } {
		set dbc $curs($i)
		error_check_good dbc_close [$dbc close] 0
	}
	set t $txns($i)
	set gid [make_gid recd015script:$t]
	puts $gfd $gid
	error_check_good txn_prepare:$t [$t prepare $gid] 0
}
close $gfd

#
# We do not close the db or env, but exit with the txns outstanding.
#
puts "\tRecd015script completed successfully"
flush stdout