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

« back to all changes in this revision

Viewing changes to libdb/test/si001.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) 2001-2002
4
 
#       Sleepycat Software.  All rights reserved.
5
 
#
6
 
# $Id$
7
 
#
8
 
# TEST  sindex001
9
 
# TEST  Basic secondary index put/delete test
10
 
proc sindex001 { methods {nentries 200} {tnum 1} args } {
11
 
        source ./include.tcl
12
 
        global dict nsecondaries
13
 
 
14
 
        # Primary method/args.
15
 
        set pmethod [lindex $methods 0]
16
 
        set pargs [convert_args $pmethod $args]
17
 
        set pomethod [convert_method $pmethod]
18
 
 
19
 
        # Method/args for all the secondaries.  If only one method
20
 
        # was specified, assume the same method and a standard N
21
 
        # secondaries.
22
 
        set methods [lrange $methods 1 end]
23
 
        if { [llength $methods] == 0 } {
24
 
                for { set i 0 } { $i < $nsecondaries } { incr i } {
25
 
                        lappend methods $pmethod
26
 
                }
27
 
        }
28
 
 
29
 
        set argses [convert_argses $methods $args]
30
 
        set omethods [convert_methods $methods]
31
 
 
32
 
        puts "Sindex00$tnum ($pmethod/$methods) $nentries equal key/data pairs"
33
 
        env_cleanup $testdir
34
 
 
35
 
        set pname "primary00$tnum.db"
36
 
        set snamebase "secondary00$tnum"
37
 
 
38
 
        # Open an environment
39
 
        # XXX if one is not supplied!
40
 
        set env [berkdb_env -create -home $testdir]
41
 
        error_check_good env_open [is_valid_env $env] TRUE
42
 
 
43
 
        # Open the primary.
44
 
        set pdb [eval {berkdb_open -create -env} $env $pomethod $pargs $pname]
45
 
        error_check_good primary_open [is_valid_db $pdb] TRUE
46
 
 
47
 
        # Open and associate the secondaries
48
 
        set sdbs {}
49
 
        for { set i 0 } { $i < [llength $omethods] } { incr i } {
50
 
                set sdb [eval {berkdb_open -create -env} $env \
51
 
                    [lindex $omethods $i] [lindex $argses $i] $snamebase.$i.db]
52
 
                error_check_good second_open($i) [is_valid_db $sdb] TRUE
53
 
 
54
 
                error_check_good db_associate($i) \
55
 
                    [$pdb associate [callback_n $i] $sdb] 0
56
 
                lappend sdbs $sdb
57
 
        }
58
 
 
59
 
        puts "\tSindex00$tnum.a: Put loop"
60
 
        set did [open $dict]
61
 
        for { set n 0 } { [gets $did str] != -1 && $n < $nentries } { incr n } {
62
 
                if { [is_record_based $pmethod] == 1 } {
63
 
                        set key [expr $n + 1]
64
 
                        set datum $str
65
 
                } else {
66
 
                        set key $str
67
 
                        gets $did datum
68
 
                }
69
 
                set keys($n) $key
70
 
                set data($n) [pad_data $pmethod $datum]
71
 
 
72
 
                set ret [eval {$pdb put} {$key [chop_data $pmethod $datum]}]
73
 
                error_check_good put($n) $ret 0
74
 
        }
75
 
        close $did
76
 
        check_secondaries $pdb $sdbs $nentries keys data "Sindex00$tnum.a"
77
 
 
78
 
        puts "\tSindex00$tnum.b: Put/overwrite loop"
79
 
        for { set n 0 } { $n < $nentries } { incr n } {
80
 
                set newd $data($n).$keys($n)
81
 
                set ret [eval {$pdb put} {$keys($n) [chop_data $pmethod $newd]}]
82
 
                error_check_good put_overwrite($n) $ret 0
83
 
                set data($n) [pad_data $pmethod $newd]
84
 
        }
85
 
        check_secondaries $pdb $sdbs $nentries keys data "Sindex00$tnum.b"
86
 
 
87
 
        # Delete the second half of the entries through the primary.
88
 
        # We do the second half so we can just pass keys(0 ... n/2)
89
 
        # to check_secondaries.
90
 
        set half [expr $nentries / 2]
91
 
        puts "\tSindex00$tnum.c: Primary delete loop: deleting $half entries"
92
 
        for { set n $half } { $n < $nentries } { incr n } {
93
 
                set ret [$pdb del $keys($n)]
94
 
                error_check_good pdel($n) $ret 0
95
 
        }
96
 
        check_secondaries $pdb $sdbs $half keys data "Sindex00$tnum.c"
97
 
 
98
 
        # Delete half of what's left, through the first secondary.
99
 
        set quar [expr $half / 2]
100
 
        puts "\tSindex00$tnum.d: Secondary delete loop: deleting $quar entries"
101
 
        set sdb [lindex $sdbs 0]
102
 
        set callback [callback_n 0]
103
 
        for { set n $quar } { $n < $half } { incr n } {
104
 
                set skey [$callback $keys($n) [pad_data $pmethod $data($n)]]
105
 
                set ret [$sdb del $skey]
106
 
                error_check_good sdel($n) $ret 0
107
 
        }
108
 
        check_secondaries $pdb $sdbs $quar keys data "Sindex00$tnum.d"
109
 
 
110
 
        puts "\tSindex00$tnum.e: Closing/disassociating primary first"
111
 
        error_check_good primary_close [$pdb close] 0
112
 
        foreach sdb $sdbs {
113
 
                error_check_good secondary_close [$sdb close] 0
114
 
        }
115
 
        error_check_good env_close [$env close] 0
116
 
}