1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1999-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Tests intra-subdb join
11
# TEST We'll test 2-way, 3-way, and 4-way joins and figure that if those work,
12
# TEST everything else does as well. We'll create test databases called
13
# TEST sub1.db, sub2.db, sub3.db, and sub4.db. The number on the database
14
# TEST describes the duplication -- duplicates are of the form 0, N, 2N, 3N,
15
# TEST ... where N is the number of the database. Primary.db is the primary
16
# TEST database, and sub0.db is the database that has no matching duplicates.
17
# TEST All of these are within a single database.
19
# We should test this on all btrees, all hash, and a combination thereof
20
proc subdb006 {method {nentries 100} args } {
24
# NB: these flags are internal only, ok
25
set args [convert_args $method $args]
26
set omethod [convert_method $method]
28
if { [is_record_based $method] == 1 || [is_rbtree $method] } {
29
puts "\tSubdb006 skipping for method $method."
34
set eindex [lsearch -exact $args "-env"]
36
# If we are using an env, then testfile should just be the db name.
37
# Otherwise it is the test directory and the name.
38
if { $eindex == -1 } {
39
set testfile $testdir/subdb006.db
42
set testfile subdb006.db
44
set env [lindex $args $eindex]
45
set txnenv [is_txnenv $env]
47
append args " -auto_commit "
48
if { $nentries == 100 } {
50
# nentries must be greater than the number
51
# of do_join_subdb calls below.
56
set testdir [get_home $env]
58
berkdb srand $rand_init
61
foreach opt {" -dup" " -dupsort"} {
64
puts "Subdb006: $method ( $args ) Intra-subdb join"
67
# Get a cursor in each subdb and move past the end of each
68
# subdb. Make sure we don't end up in another subdb.
70
puts "\tSubdb006.a: Intra-subdb join"
72
if { $env != "NULL" } {
73
set testdir [get_home $env]
78
set duplist {0 50 25 16 12}
79
set numdb [llength $duplist]
80
build_all_subdb $testfile [list $method] $psize \
81
$duplist $nentries $args
84
puts "Subdb006: Building the primary database $method"
85
set oflags "-create -mode 0644 [conv $omethod \
86
[berkdb random_int 1 2]]"
87
set db [eval {berkdb_open} $oflags $oargs $testfile primary.db]
88
error_check_good dbopen [is_valid_db $db] TRUE
89
for { set i 0 } { $i < 1000 } { incr i } {
92
error_check_good txn [is_valid_txn $t $env] TRUE
95
set key [format "%04d" $i]
96
set ret [eval {$db put} $txn {$key stub}]
97
error_check_good "primary put" $ret 0
99
error_check_good txn [$t commit] 0
102
error_check_good "primary close" [$db close] 0
105
do_join_subdb $testfile primary.db "1 0" $str $oargs
107
do_join_subdb $testfile primary.db "2 0" $str $oargs
109
do_join_subdb $testfile primary.db "3 0" $str $oargs
111
do_join_subdb $testfile primary.db "4 0" $str $oargs
113
do_join_subdb $testfile primary.db "1" $str $oargs
115
do_join_subdb $testfile primary.db "2" $str $oargs
117
do_join_subdb $testfile primary.db "3" $str $oargs
119
do_join_subdb $testfile primary.db "4" $str $oargs
121
do_join_subdb $testfile primary.db "1 2" $str $oargs
123
do_join_subdb $testfile primary.db "1 2 3" $str $oargs
125
do_join_subdb $testfile primary.db "1 2 3 4" $str $oargs
127
do_join_subdb $testfile primary.db "2 1" $str $oargs
129
do_join_subdb $testfile primary.db "3 2 1" $str $oargs
131
do_join_subdb $testfile primary.db "4 3 2 1" $str $oargs
133
do_join_subdb $testfile primary.db "1 3" $str $oargs
135
do_join_subdb $testfile primary.db "3 1" $str $oargs
137
do_join_subdb $testfile primary.db "1 4" $str $oargs
139
do_join_subdb $testfile primary.db "4 1" $str $oargs
141
do_join_subdb $testfile primary.db "2 3" $str $oargs
143
do_join_subdb $testfile primary.db "3 2" $str $oargs
145
do_join_subdb $testfile primary.db "2 4" $str $oargs
147
do_join_subdb $testfile primary.db "4 2" $str $oargs
149
do_join_subdb $testfile primary.db "3 4" $str $oargs
151
do_join_subdb $testfile primary.db "4 3" $str $oargs
153
do_join_subdb $testfile primary.db "2 3 4" $str $oargs
155
do_join_subdb $testfile primary.db "3 4 1" $str $oargs
157
do_join_subdb $testfile primary.db "4 2 1" $str $oargs
159
do_join_subdb $testfile primary.db "0 2 1" $str $oargs
161
do_join_subdb $testfile primary.db "3 2 0" $str $oargs
163
do_join_subdb $testfile primary.db "4 3 2 1" $str $oargs
165
do_join_subdb $testfile primary.db "4 3 0 1" $str $oargs