$db->{foo} = [ 1 .. 3];
my $x = $db->{foo};
my $y = $db->{foo};
- is( $x == $y ); # Now passes
+ is( $x, $y ); # Now passes
- This means that Data::Dumper now properly reports when $db->{foo} = $db->{bar}
1.0004 Sep 28 12:15:00 2007 EDT
use strict;
use warnings;
-our $VERSION = q(1.0004);
+our $VERSION = q(1.0005);
use Fcntl qw( :flock );
use DBM::Deep::Engine;
use DBM::Deep::File;
+use overload
+ '""' => sub { overload::StrVal( $_[0] ) },
+ fallback => 1;
+
##
# Setup constants for users to pass to new()
##
=back
-=head2 Data::Dumper and references
+=head2 External references and transactions
-As of 1.0003, support for independent Perl datastructures was added (q.v. L</CIRCULAR REFERENCES>
-for more info). However, because DBM::Deep doesn't properly provide the same
-in-memory data-structure for a given location on disk, Data::Dumper (and
-friends) doesn't properly note this. This will be addressed in a future release.
+If you do C<my $x = $db-E<gt>{foo};>, then start a transaction, $x will be
+referencing the database from outside the transaction. A fix for this (and other
+issues with how external references into the database) is being looked into. This
+is the skipped set of tests in t/39_singletons.t and a related issue is the focus
+of t/37_delete_edge_cases.t
=head2 File corruption
use strict;
use warnings;
-our $VERSION = q(1.0004);
+our $VERSION = q(1.0005);
# This is to allow DBM::Deep::Array to handle negative indices on
# its own. Otherwise, Perl would intercept the call to negative
use strict;
use warnings;
-our $VERSION = q(1.0004);
+our $VERSION = q(1.0005);
use Scalar::Util ();
}
# Rebless the object into DBM::Deep::Null.
- my $x = $self->engine->cache->{ $self->offset };
%{ $self->engine->cache->{ $self->offset } } = ();
bless $self->engine->cache->{ $self->offset }, 'DBM::Deep::Null';
+ delete $self->engine->cache->{ $self->offset };
my $blist_loc = $self->get_blist_loc;
$self->engine->_load_sector( $blist_loc )->free if $blist_loc;
use strict;
use warnings;
-our $VERSION = q(1.0004);
+our $VERSION = q(1.0005);
use Fcntl qw( :DEFAULT :flock :seek );
use strict;
use warnings;
-our $VERSION = q(1.0004);
+our $VERSION = q(1.0005);
use base 'DBM::Deep';
}
__END__
-
-Tests to add:
-* Two transactions running at the same time
-* Doing a clear on the head while a transaction is running
use strict;
-use Test::More tests => 9;
+use Test::More tests => 11;
use Test::Deep;
use t::common qw( new_fh );
use_ok( 'DBM::Deep' );
-my ($fh, $filename) = new_fh();
-my $db = DBM::Deep->new(
- file => $filename,
- locking => 1,
- autoflush => 1,
-);
-
-$db->{a} = 1;
-$db->{foo} = { a => 'b' };
-my $x = $db->{foo};
-my $y = $db->{foo};
-
-is( $x, $y, "The references are the same" );
-
-delete $db->{foo};
-is( $x, undef );
-is( $y, undef );
-warn "$x\n";
-is( $x + 0, 0 );
-is( $y + 0, 0 );
-is( $db->{foo}, undef );
-
-# These shenanigans work to get another hashref
-# into the same data location as $db->{foo} was.
-$db->{foo} = {};
-delete $db->{foo};
-$db->{foo} = {};
-$db->{bar} = {};
-
-is( $x, undef );
-is( $y, undef );
+{
+ my ($fh, $filename) = new_fh();
+ my $db = DBM::Deep->new(
+ file => $filename,
+ locking => 1,
+ autoflush => 1,
+ );
+
+ $db->{a} = 1;
+ $db->{foo} = { a => 'b' };
+ my $x = $db->{foo};
+ my $y = $db->{foo};
+
+ is( $x, $y, "The references are the same" );
+
+ delete $db->{foo};
+ is( $x, undef );
+ is( $y, undef );
+ is( $x + 0, undef );
+ is( $y + 0, undef );
+ is( $db->{foo}, undef );
+
+ # These shenanigans work to get another hashref
+ # into the same data location as $db->{foo} was.
+ $db->{foo} = {};
+ delete $db->{foo};
+ $db->{foo} = {};
+ $db->{bar} = {};
+
+ is( $x, undef );
+ is( $y, undef );
+}
+
+SKIP: {
+ skip "What do we do with external references and txns?", 2;
+ my ($fh, $filename) = new_fh();
+ my $db = DBM::Deep->new(
+ file => $filename,
+ locking => 1,
+ autoflush => 1,
+ num_txns => 2,
+ );
+
+ $db->{foo} = { a => 'b' };
+ my $x = $db->{foo};
+
+ $db->begin_work;
+
+ $db->{foo} = { c => 'd' };
+ my $y = $db->{foo};
+
+ # XXX What should happen here with $x and $y?
+ is( $x, $y );
+ is( $x->{c}, 'd' );
+
+ $db->rollback;
+}
'0.981', '0.982', '0.983',
'0.99_01', '0.99_02', '0.99_03', '0.99_04',
'1.00', '1.000', '1.0000', '1.0001', '1.0002',
- '1.0003', '1.0004',
+ '1.0003', '1.0004', '1.0005',
);
foreach my $input_filename (
eval "use DBM::Deep::10002";
$db = DBM::Deep::10002->new( $output_filename );
}
- elsif ( $v =~ /^1\.000[34]/ ) {
+ elsif ( $v =~ /^1\.000[3-5]/ ) {
push @INC, 'lib';
eval "use DBM::Deep";
$db = DBM::Deep->new( $output_filename );
my %opts = (
man => 0,
help => 0,
- version => '1.0004',
+ version => '1.0005',
autobless => 1,
);
GetOptions( \%opts,
elsif ( $ver =~ /^1\.000?[0-2]?/) {
$ver = 2;
}
- elsif ( $ver =~ /^1\.000[34]/) {
+ elsif ( $ver =~ /^1\.000[3-5]/) {
$ver = 3;
}
else {