6
unless(grep /blib/, @INC) {
8
@INC = '../lib' if -d '../lib';
17
my $Dfile = "dbhash.tmp";
23
# closing a database & an environment in the correct order.
24
my $lex = new LexFile $Dfile ;
28
ok 1, my $lexD = new LexDir($home);
29
ok 2, my $env = new BerkeleyDB::Env -Home => $home,
30
-Flags => DB_CREATE|DB_INIT_TXN|
31
DB_INIT_MPOOL|DB_INIT_LOCK ;
33
ok 3, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
37
ok 4, $db1->db_close() == 0 ;
39
eval { $status = $env->db_appexit() ; } ;
47
# closing an environment with an open database
48
my $lex = new LexFile $Dfile ;
51
ok 7, my $lexD = new LexDir($home);
52
ok 8, my $env = new BerkeleyDB::Env -Home => $home,
53
-Flags => DB_CREATE|DB_INIT_TXN|
54
DB_INIT_MPOOL|DB_INIT_LOCK ;
56
ok 9, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
60
eval { $env->db_appexit() ; } ;
61
ok 10, $@ =~ /BerkeleyDB Aborting: attempted to close an environment with 1 open database/ ;
70
# closing a transaction & a database
71
my $lex = new LexFile $Dfile ;
75
ok 11, my $lexD = new LexDir($home);
76
ok 12, my $env = new BerkeleyDB::Env -Home => $home,
77
-Flags => DB_CREATE|DB_INIT_TXN|
78
DB_INIT_MPOOL|DB_INIT_LOCK ;
80
ok 13, my $txn = $env->txn_begin() ;
81
ok 14, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
86
ok 15, $txn->txn_commit() == 0 ;
87
eval { $status = $db->db_close() ; } ;
91
eval { $status = $env->db_appexit() ; } ;
98
# closing a database with an open transaction
99
my $lex = new LexFile $Dfile ;
102
ok 20, my $lexD = new LexDir($home);
103
ok 21, my $env = new BerkeleyDB::Env -Home => $home,
104
-Flags => DB_CREATE|DB_INIT_TXN|
105
DB_INIT_MPOOL|DB_INIT_LOCK ;
107
ok 22, my $txn = $env->txn_begin() ;
108
ok 23, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
109
-Flags => DB_CREATE ,
113
eval { $db->db_close() ; } ;
114
ok 24, $@ =~ /BerkeleyDB Aborting: attempted to close a database while a transaction was still open at/ ;
119
# closing a cursor & a database
120
my $lex = new LexFile $Dfile ;
123
ok 25, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
124
-Flags => DB_CREATE ;
125
ok 26, my $cursor = $db->db_cursor() ;
126
ok 27, $cursor->c_close() == 0 ;
127
eval { $status = $db->db_close() ; } ;
128
ok 28, $status == 0 ;
134
# closing a database with an open cursor
135
my $lex = new LexFile $Dfile ;
137
ok 30, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
138
-Flags => DB_CREATE ;
139
ok 31, my $cursor = $db->db_cursor() ;
140
eval { $db->db_close() ; } ;
141
ok 32, $@ =~ /\QBerkeleyDB Aborting: attempted to close a database with 1 open cursor(s) at/;
146
# closing a transaction & a cursor
147
my $lex = new LexFile $Dfile ;
151
ok 33, my $lexD = new LexDir($home);
152
ok 34, my $env = new BerkeleyDB::Env -Home => $home,
153
-Flags => DB_CREATE|DB_INIT_TXN|
154
DB_INIT_MPOOL|DB_INIT_LOCK ;
155
ok 35, my $txn = $env->txn_begin() ;
156
ok 36, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
157
-Flags => DB_CREATE ,
160
ok 37, my $cursor = $db->db_cursor() ;
161
eval { $status = $cursor->c_close() ; } ;
162
ok 38, $status == 0 ;
163
ok 39, ($status = $txn->txn_commit()) == 0 ;
165
eval { $status = $db->db_close() ; } ;
166
ok 41, $status == 0 ;
169
eval { $status = $env->db_appexit() ; } ;
170
ok 43, $status == 0 ;