~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to bdb/test/txn005.tcl

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
VirginĀ 5.0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See the file LICENSE for redistribution information.
 
2
#
 
3
# Copyright (c) 1996-2002
 
4
#       Sleepycat Software.  All rights reserved.
 
5
#
 
6
# $Id: txn005.tcl,v 11.35 2002/08/08 15:38:14 bostic Exp $
 
7
#
 
8
 
 
9
# TEST  txn005
 
10
# TEST  Test transaction ID wraparound and recovery.
 
11
proc txn005 {} {
 
12
        source ./include.tcl
 
13
        global txn_curid
 
14
        global txn_maxid
 
15
 
 
16
        env_cleanup $testdir
 
17
        puts "Txn005: Test transaction wraparound recovery"
 
18
 
 
19
        # Open/create the txn region
 
20
        puts "\tTxn005.a: Create environment"
 
21
        set e [berkdb_env -create -txn -home $testdir]
 
22
        error_check_good env_open [is_valid_env $e] TRUE
 
23
 
 
24
        set txn1 [$e txn]
 
25
        error_check_good txn1 [is_valid_txn $txn1 $e] TRUE
 
26
 
 
27
        set db [berkdb_open -env $e -txn $txn1 -create -btree txn005.db]
 
28
        error_check_good db [is_valid_db $db] TRUE
 
29
        error_check_good txn1_commit [$txn1 commit] 0
 
30
 
 
31
        puts "\tTxn005.b: Set txn ids"
 
32
        error_check_good txn_id_set \
 
33
            [$e txn_id_set [expr $txn_maxid - 1] $txn_maxid] 0
 
34
 
 
35
        # txn2 and txn3 will require a wraparound txnid
 
36
        set txn2 [$e txn]
 
37
        error_check_good txn2 [is_valid_txn $txn2 $e] TRUE
 
38
 
 
39
        error_check_good put [$db put -txn $txn2 "a" ""] 0
 
40
        error_check_good txn2_commit [$txn2 commit] 0
 
41
 
 
42
        error_check_good get_a [$db get "a"] "{a {}}"
 
43
 
 
44
        error_check_good close [$db close] 0
 
45
 
 
46
        set txn3 [$e txn]
 
47
        error_check_good txn3 [is_valid_txn $txn3 $e] TRUE
 
48
 
 
49
        set db [berkdb_open -env $e -txn $txn3 -btree txn005.db]
 
50
        error_check_good db [is_valid_db $db] TRUE
 
51
 
 
52
        error_check_good put2 [$db put -txn $txn3 "b" ""] 0
 
53
        error_check_good sync [$db sync] 0
 
54
        error_check_good txn3_abort [$txn3 abort] 0
 
55
        error_check_good dbclose [$db close] 0
 
56
        error_check_good eclose [$e close] 0
 
57
 
 
58
        puts "\tTxn005.c: Run recovery"
 
59
        set stat [catch {exec $util_path/db_recover -h $testdir -e -c} result]
 
60
        if { $stat == 1 } {
 
61
                error "FAIL: Recovery error: $result."
 
62
        }
 
63
 
 
64
        puts "\tTxn005.d: Check data"
 
65
        set e [berkdb_env -txn -home $testdir]
 
66
        error_check_good env_open [is_valid_env $e] TRUE
 
67
 
 
68
        set db [berkdb_open -env $e -auto_commit -btree txn005.db]
 
69
        error_check_good db [is_valid_db $db] TRUE
 
70
 
 
71
        error_check_good get_a [$db get "a"] "{a {}}"
 
72
        error_check_bad get_b [$db get "b"] "{b {}}"
 
73
        error_check_good dbclose [$db close] 0
 
74
        error_check_good eclose [$e close] 0
 
75
}