File: txnscript.tcl

package info (click to toggle)
db5.3 5.3.28%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 158,500 kB
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,264; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,077; javascript: 1,998; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (66 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download | duplicates (8)
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
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1996, 2013 Oracle and/or its affiliates.  All rights reserved.
#
# $Id$
#
# 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