1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 1999,2008 Oracle. All rights reserved. 4# 5# $Id: sdb007.tcl,v 12.8 2008/01/08 20:58:53 bostic Exp $ 6# 7# TEST sdb007 8# TEST Tests page size difference errors between subdbs. 9# TEST If the physical file already exists, we ignore pagesize specifications 10# TEST on any subsequent -creates. 11# TEST 12# TEST 1. Create/open a subdb with system default page size. 13# TEST Create/open a second subdb specifying a different page size. 14# TEST The create should succeed, but the pagesize of the new db 15# TEST will be the system default page size. 16# TEST 2. Create/open a subdb with a specified, non-default page size. 17# TEST Create/open a second subdb specifying a different page size. 18# TEST The create should succeed, but the pagesize of the new db 19# TEST will be the specified page size from the first create. 20 21proc sdb007 { method args } { 22 source ./include.tcl 23 24 set db2args [convert_args -btree $args] 25 set args [convert_args $method $args] 26 set omethod [convert_method $method] 27 28 if { [is_queue $method] == 1 } { 29 puts "Subdb007: skipping for method $method" 30 return 31 } 32 set pgindex [lsearch -exact $args "-pagesize"] 33 if { $pgindex != -1 } { 34 puts "Subdb007: skipping for specific page sizes" 35 return 36 } 37 38 puts "Subdb007: $method ($args) subdb tests with different page sizes" 39 40 set txnenv 0 41 set envargs "" 42 set eindex [lsearch -exact $args "-env"] 43 # 44 # If we are using an env, then testfile should just be the db name. 45 # Otherwise it is the test directory and the name. 46 if { $eindex == -1 } { 47 set testfile $testdir/subdb007.db 48 set env NULL 49 } else { 50 set testfile subdb007.db 51 incr eindex 52 set env [lindex $args $eindex] 53 set envargs " -env $env " 54 set txnenv [is_txnenv $env] 55 if { $txnenv == 1 } { 56 append args " -auto_commit " 57 append envargs " -auto_commit " 58 append db2args " -auto_commit " 59 } 60 set testdir [get_home $env] 61 } 62 set sub1 "sub1" 63 set sub2 "sub2" 64 cleanup $testdir $env 65 set txn "" 66 67 puts "\tSubdb007.a.0: create subdb with default page size" 68 set db [eval {berkdb_open -create -mode 0644} \ 69 $args $envargs {$omethod $testfile $sub1}] 70 error_check_good subdb [is_valid_db $db] TRUE 71 72 # Figure out what the default page size is so that we can send 73 # a different value to the next -create call. 74 set default_psize [stat_field $db stat "Page size"] 75 error_check_good dbclose [$db close] 0 76 77 if { $default_psize == 512 } { 78 set psize 2048 79 } else { 80 set psize 512 81 } 82 83 puts "\tSubdb007.a.1: Create 2nd subdb with different specified page size" 84 set db2 [eval {berkdb_open -create -btree} \ 85 $db2args $envargs {-pagesize $psize $testfile $sub2}] 86 error_check_good db2_create [is_valid_db $db2] TRUE 87 88 set actual_psize [stat_field $db2 stat "Page size"] 89 error_check_good check_pagesize [expr $actual_psize == $default_psize] 1 90 error_check_good db2close [$db2 close] 0 91 92 set ret [eval {berkdb dbremove} $envargs {$testfile}] 93 94 puts "\tSubdb007.b.0: Create subdb with specified page size" 95 set db [eval {berkdb_open -create -mode 0644} \ 96 $args $envargs {-pagesize $psize $omethod $testfile $sub1}] 97 error_check_good subdb [is_valid_db $db] TRUE 98 error_check_good dbclose [$db close] 0 99 100 puts "\tSubdb007.b.1: Create 2nd subdb with different specified page size" 101 set newpsize [expr $psize * 2] 102 set db2 [eval {berkdb_open -create -mode 0644} $args \ 103 $envargs {-pagesize $newpsize $omethod $testfile $sub2}] 104 error_check_good subdb [is_valid_db $db2] TRUE 105 set actual_psize [stat_field $db2 stat "Page size"] 106 error_check_good check_pagesize [expr $actual_psize == $psize] 1 107 error_check_good db2close [$db2 close] 0 108} 109