13 my $Dfile = "dbhash.tmp";
20 my $lex = new LexFile $Dfile ;
25 ok my $lexD = new LexDir($home);
26 ok my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
27 -Flags => DB_CREATE| DB_INIT_MPOOL;
28 eval { $env->txn_begin() ; } ;
29 ok $@ =~ /^BerkeleyDB Aborting: Transaction Manager not enabled at/ ;
31 eval { my $txn_mgr = $env->TxnMgr() ; } ;
32 ok $@ =~ /^BerkeleyDB Aborting: Transaction Manager not enabled at/ ;
38 # transaction - abort works
40 my $lex = new LexFile $Dfile ;
45 ok my $lexD = new LexDir($home);
46 ok my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
47 -Flags => DB_CREATE|DB_INIT_TXN|
48 DB_INIT_MPOOL|DB_INIT_LOCK ;
49 ok my $txn = $env->txn_begin() ;
50 ok my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
56 ok $txn->txn_commit() == 0 ;
57 ok $txn = $env->txn_begin() ;
68 while (my ($k, $v) = each %data) {
69 $ret += $db1->db_put($k, $v) ;
73 # should be able to see all the records
75 ok my $cursor = $db1->db_cursor() ;
76 my ($k, $v) = ("", "") ;
79 while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
85 # now abort the transaction
86 ok $txn->txn_abort() == 0 ;
88 # there shouldn't be any records in the database
91 ok $cursor = $db1->db_cursor() ;
92 while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
97 my $stat = $env->txn_stat() ;
98 ok $stat->{'st_naborts'} == 1 ;
108 # transaction - abort works via txnmgr
110 my $lex = new LexFile $Dfile ;
114 my $home = "./fred" ;
115 ok my $lexD = new LexDir($home);
116 ok my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
117 -Flags => DB_CREATE|DB_INIT_TXN|
118 DB_INIT_MPOOL|DB_INIT_LOCK ;
119 ok my $txn_mgr = $env->TxnMgr() ;
120 ok my $txn = $txn_mgr->txn_begin() ;
121 ok my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
122 -Flags => DB_CREATE ,
126 ok $txn->txn_commit() == 0 ;
127 ok $txn = $env->txn_begin() ;
138 while (my ($k, $v) = each %data) {
139 $ret += $db1->db_put($k, $v) ;
143 # should be able to see all the records
145 ok my $cursor = $db1->db_cursor() ;
146 my ($k, $v) = ("", "") ;
149 while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
155 # now abort the transaction
156 ok $txn->txn_abort() == 0 ;
158 # there shouldn't be any records in the database
161 ok $cursor = $db1->db_cursor() ;
162 while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
167 my $stat = $txn_mgr->txn_stat() ;
168 ok $stat->{'st_naborts'} == 1 ;
179 # transaction - commit works
181 my $lex = new LexFile $Dfile ;
185 my $home = "./fred" ;
186 ok my $lexD = new LexDir($home);
187 ok my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
188 -Flags => DB_CREATE|DB_INIT_TXN|
189 DB_INIT_MPOOL|DB_INIT_LOCK ;
190 ok my $txn = $env->txn_begin() ;
191 ok my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
192 -Flags => DB_CREATE ,
197 ok $txn->txn_commit() == 0 ;
198 ok $txn = $env->txn_begin() ;
209 while (my ($k, $v) = each %data) {
210 $ret += $db1->db_put($k, $v) ;
214 # should be able to see all the records
216 ok my $cursor = $db1->db_cursor() ;
217 my ($k, $v) = ("", "") ;
220 while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
226 # now commit the transaction
227 ok $txn->txn_commit() == 0 ;
231 ok $cursor = $db1->db_cursor() ;
232 while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
237 my $stat = $env->txn_stat() ;
238 ok $stat->{'st_naborts'} == 0 ;
248 # transaction - commit works via txnmgr
250 my $lex = new LexFile $Dfile ;
254 my $home = "./fred" ;
255 ok my $lexD = new LexDir($home);
256 ok my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
257 -Flags => DB_CREATE|DB_INIT_TXN|
258 DB_INIT_MPOOL|DB_INIT_LOCK ;
259 ok my $txn_mgr = $env->TxnMgr() ;
260 ok my $txn = $txn_mgr->txn_begin() ;
261 ok my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
262 -Flags => DB_CREATE ,
266 ok $txn->txn_commit() == 0 ;
267 ok $txn = $env->txn_begin() ;
278 while (my ($k, $v) = each %data) {
279 $ret += $db1->db_put($k, $v) ;
283 # should be able to see all the records
285 ok my $cursor = $db1->db_cursor() ;
286 my ($k, $v) = ("", "") ;
289 while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
295 # now commit the transaction
296 ok $txn->txn_commit() == 0 ;
300 ok $cursor = $db1->db_cursor() ;
301 while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
306 my $stat = $txn_mgr->txn_stat() ;
307 ok $stat->{'st_naborts'} == 0 ;