~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/test/test067.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# See the file LICENSE for redistribution information.
2
 
#
3
 
# Copyright (c) 1999-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  test067
9
 
# TEST  Test of DB_CURRENT partial puts onto almost empty duplicate
10
 
# TEST  pages, with and without DB_DUP_SORT.
11
 
# TEST
12
 
# TEST  Test of DB_CURRENT partial puts on almost-empty duplicate pages.
13
 
# TEST  This test was written to address the following issue, #2 in the
14
 
# TEST  list of issues relating to bug #0820:
15
 
# TEST
16
 
# TEST  2. DBcursor->put, DB_CURRENT flag, off-page duplicates, hash and btree:
17
 
# TEST  In Btree, the DB_CURRENT overwrite of off-page duplicate records
18
 
# TEST  first deletes the record and then puts the new one -- this could
19
 
# TEST  be a problem if the removal of the record causes a reverse split.
20
 
# TEST  Suggested solution is to acquire a cursor to lock down the current
21
 
# TEST  record, put a new record after that record, and then delete using
22
 
# TEST  the held cursor.
23
 
# TEST
24
 
# TEST  It also tests the following, #5 in the same list of issues:
25
 
# TEST  5. DBcursor->put, DB_AFTER/DB_BEFORE/DB_CURRENT flags, DB_DBT_PARTIAL
26
 
# TEST  set, duplicate comparison routine specified.
27
 
# TEST  The partial change does not change how data items sort, but the
28
 
# TEST  record to be put isn't built yet, and that record supplied is the
29
 
# TEST  one that's checked for ordering compatibility.
30
 
proc test067 { method {ndups 1000} {tnum 67} args } {
31
 
        source ./include.tcl
32
 
        global alphabet
33
 
        global errorCode
34
 
 
35
 
        set args [convert_args $method $args]
36
 
        set omethod [convert_method $method]
37
 
 
38
 
        if { [is_record_based $method] == 1 || [is_rbtree $method] == 1 } {
39
 
            puts "\tTest0$tnum: skipping for method $method."
40
 
            return
41
 
        }
42
 
        set txn ""
43
 
        set txnenv 0
44
 
        set eindex [lsearch -exact $args "-env"]
45
 
 
46
 
        # If we are using an env, then testfile should just be the db name.
47
 
        # Otherwise it is the test directory and the name.
48
 
        if { $eindex == -1 } {
49
 
                set testfile $testdir/test0$tnum.db
50
 
                set env NULL
51
 
        } else {
52
 
                set testfile test0$tnum.db
53
 
                incr eindex
54
 
                set env [lindex $args $eindex]
55
 
                set txnenv [is_txnenv $env]
56
 
                if { $txnenv == 1 } {
57
 
                        append args " -auto_commit "
58
 
                        if { $ndups == 1000 } {
59
 
                                set ndups 100
60
 
                        }
61
 
                }
62
 
                set testdir [get_home $env]
63
 
        }
64
 
 
65
 
        puts "Test0$tnum:\
66
 
            $method ($args) Partial puts on near-empty duplicate pages."
67
 
 
68
 
        foreach dupopt { "-dup" "-dup -dupsort" } {
69
 
                #
70
 
                # Testdir might get reset from the env's home dir back
71
 
                # to the default if this calls something that sources
72
 
                # include.tcl, since testdir is a global.  Set it correctly
73
 
                # here each time through the loop.
74
 
                #
75
 
                if { $env != "NULL" } {
76
 
                        set testdir [get_home $env]
77
 
                }
78
 
                cleanup $testdir $env
79
 
                set db [eval {berkdb_open -create -mode 0644 \
80
 
                    $omethod} $args $dupopt {$testfile}]
81
 
                error_check_good db_open [is_valid_db $db] TRUE
82
 
 
83
 
                puts "\tTest0$tnum.a ($dupopt): Put $ndups duplicates."
84
 
 
85
 
                set key "key_test$tnum"
86
 
 
87
 
                for { set ndx 0 } { $ndx < $ndups } { incr ndx } {
88
 
                        set data $alphabet$ndx
89
 
 
90
 
                        if { $txnenv == 1 } {
91
 
                                set t [$env txn]
92
 
                                error_check_good txn [is_valid_txn $t $env] TRUE
93
 
                                set txn "-txn $t"
94
 
                        }
95
 
                        # No need for pad_data since we're skipping recno.
96
 
                        set ret [eval {$db put} $txn {$key $data}]
97
 
                        error_check_good put($key,$data) $ret 0
98
 
                        if { $txnenv == 1 } {
99
 
                                error_check_good txn [$t commit] 0
100
 
                        }
101
 
                }
102
 
 
103
 
                # Sync so we can inspect database if the next section bombs.
104
 
                error_check_good db_sync [$db sync] 0
105
 
                puts "\tTest0$tnum.b ($dupopt):\
106
 
                    Deleting dups (last first), overwriting each."
107
 
 
108
 
                if { $txnenv == 1 } {
109
 
                        set t [$env txn]
110
 
                        error_check_good txn [is_valid_txn $t $env] TRUE
111
 
                        set txn "-txn $t"
112
 
                }
113
 
                set dbc [eval {$db cursor} $txn]
114
 
                error_check_good cursor_create [is_valid_cursor $dbc $db] TRUE
115
 
 
116
 
                set count 0
117
 
                while { $count < $ndups - 1 } {
118
 
                        # set cursor to last item in db
119
 
                        set ret [$dbc get -last]
120
 
                        error_check_good \
121
 
                            verify_key [lindex [lindex $ret 0] 0] $key
122
 
 
123
 
                        # for error reporting
124
 
                        set currdatum [lindex [lindex $ret 0] 1]
125
 
 
126
 
                        # partial-overwrite it
127
 
                        # (overwrite offsets 1-4 with "bcde"--which they
128
 
                        # already are)
129
 
 
130
 
                        # Even though we expect success, we catch this
131
 
                        # since it might return EINVAL, and we want that
132
 
                        # to FAIL.
133
 
                        set errorCode NONE
134
 
                        set ret [catch {eval $dbc put -current \
135
 
                                {-partial [list 1 4]} "bcde"} \
136
 
                                res]
137
 
                        error_check_good \
138
 
                                partial_put_valid($currdatum) $errorCode NONE
139
 
                        error_check_good partial_put($currdatum) $res 0
140
 
 
141
 
                        # delete it
142
 
                        error_check_good dbc_del [$dbc del] 0
143
 
 
144
 
                        #puts $currdatum
145
 
 
146
 
                        incr count
147
 
                }
148
 
 
149
 
                error_check_good dbc_close [$dbc close] 0
150
 
                if { $txnenv == 1 } {
151
 
                        error_check_good txn [$t commit] 0
152
 
                }
153
 
                error_check_good db_close [$db close] 0
154
 
        }
155
 
}