$struct = $self->_repr( @_ );
}
- return $self->_import( $struct );
+#XXX These are correct, but impossible until the other bug is fixed
+ eval {
+# $self->begin_work;
+ $self->_import( $struct );
+# $self->commit;
+ }; if ( $@ ) {
+ $self->rollback;
+ die $@;
+ }
+
+ return 1;
}
sub optimize {
# $self->_throw_error("Cannot optimize: reference count is greater than 1");
# }
+ #XXX Do we have to lock the tempfile?
+
my $db_temp = DBM::Deep->new(
file => $self->_fileobj->{file} . '.tmp',
type => $self->_type
if ( $fileobj->transaction_id == 0 ) {
my $keytag = $self->load_tag( $keyloc );
+
my ($subloc, $is_deleted, $offset) = $self->find_keyloc( $keytag );
+ return if !$subloc || $is_deleted;
+
my $value = $self->read_from_loc( $subloc, $orig_key );
my $size = $self->_length_needed( $value, $orig_key );
}
else {
my $keytag = $self->load_tag( $keyloc );
+
my ($subloc, $is_deleted, $offset) = $self->find_keyloc( $keytag );
+
$fileobj->print_at( $keytag->{offset} + $offset,
pack($self->{long_pack}, -1 ),
pack( 'C C', $fileobj->transaction_id, 1 ),
use strict;
-use Test::More tests => 3;
+use Test::More tests => 7;
use Test::Deep;
use t::common qw( new_fh );
autoflush => 1,
);
+my $x_outer = { a => 'b' };
+my $x_inner = { a => 'c' };;
+
+$db1->{x} = $x_outer;
+is( $db1->{x}{a}, 'b', "We're looking at the right value from outer" );
+
$db1->begin_work;
- my $x = { a => 'b' };;
- $db1->{x} = $x;
+ $db1->{x} = $x_inner;
+ is( $db1->{x}{a}, 'c', "We're looking at the right value from inner" );
+ is( $x_outer->{a}, 'c', "We're looking at the right value from outer" );
$db1->commit;
-is( $db1->{x}{a}, 'b', "DB1 X-A is good" );
-is( $x->{a}, 'b', "X's A is good" );
+is( $db1->{x}{a}, 'c', "Commit means x_inner is still correct" );
+is( $x_outer->{a}, 'c', "outer made the move" );
+is( $x_inner->{a}, 'c', "inner is still good" );