File: txnscript.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 (67 lines) | stat: -rw-r--r-- 1,846 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
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1996-2002
#	Sleepycat Software.  All rights reserved.
#
# $Id: txnscript.tcl,v 1.1.1.1 2003/11/20 22:14:02 toshok Exp $
#
# Txn003 script - outstanding child prepare script
# Usage: txnscript envcmd dbcmd gidf key data
# envcmd: command to open env
# dbfile: name of database file
# gidf: name of global id file
# key: key to use
# data: new data to use

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

set usage "txnscript envcmd dbfile gidfile key data"

# Verify usage
if { $argc != 5 } {
	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 key [ lindex $argv 3 ]
set data [ lindex $argv 4 ]

set dbenv [eval $envcmd]
error_check_good envopen [is_valid_env $dbenv] TRUE

set usedb 1
set db [berkdb_open -auto_commit -env $dbenv $dbfile]
error_check_good dbopen [is_valid_db $db] TRUE

puts "\tTxnscript.a: begin parent and child txn"
set parent [$dbenv txn]
error_check_good parent [is_valid_txn $parent $dbenv] TRUE
set child [$dbenv txn -parent $parent]
error_check_good parent [is_valid_txn $child $dbenv] TRUE

puts "\tTxnscript.b: Modify data"
error_check_good db_put [$db put -txn $child $key $data] 0

set gfd [open $gidfile w+]
set gid [make_gid txnscript:$parent]
puts $gfd $gid
puts "\tTxnscript.c: Prepare parent only"
error_check_good txn_prepare:$parent [$parent prepare $gid] 0
close $gfd

puts "\tTxnscript.d: Check child handle"
set stat [catch {$child abort} ret]
error_check_good child_handle $stat 1
error_check_good child_h2 [is_substr $ret "invalid command name"] 1

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