);
}
+sub supports {
+ my $self = shift;
+ return $self->_engine->supports( @_ );
+}
+
#XXX Migrate this to the engine, where it really belongs and go through some
# API - stop poking in the innards of someone else..
{
These are the transactional functions. L</TRANSACTIONS> for more information.
+=item * supports( $option )
+
+This returns a boolean depending on if this instance of DBM::Dep supports
+that feature. C<$option> can be one of:
+
+=over 4
+
+=item * transactions
+
+=back
+
=back
=head2 Hashes
sub cache { $_[0]{cache} ||= {} }
sub clear_cache { %{$_[0]->cache} = () }
+=head2 supports( $option )
+
+This returns a boolean depending on if this instance of DBM::Dep supports
+that feature. C<$option> can be one of:
+
+=over 4
+
+=item * transactions
+
+=back
+
+=cut
+
+sub supports { die "supports must be implemented in a child class" }
+
=head2 ACCESSORS
The following are readonly attributes.
return 1;
}
-sub begin_work {
- my $self = shift;
- my ($obj) = @_;
-}
+sub begin_work { die "Transactions are not supported by thie engine" }
+sub rollback { die "Transactions are not supported by thie engine" }
+sub commit { die "Transactions are not supported by thie engine" }
-sub rollback {
- my $self = shift;
- my ($obj) = @_;
-}
+sub supports {
+ shift;
+ my ($feature) = @_;
-sub commit {
- my $self = shift;
- my ($obj) = @_;
+ return if $feature eq 'transactions';
+ return;
}
-
1;
__END__
sub chains_loc { $_[0]{chains_loc} }
sub set_chains_loc { $_[0]{chains_loc} = $_[1] }
+sub supports {
+ shift;
+ my ($feature) = @_;
+
+ return 1 if $feature eq 'transactions';
+ return;
+}
+
=head2 _dump_file()
This method takes no arguments. It's used to print out a textual representation
use_ok( 'DBM::Deep' );
-if ( $ENV{NO_TEST_TRANSACTIONS} ) {
- done_testing;
- exit;
-}
-
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
);
while ( my $dbm_maker = $dbm_factory->() ) {
my $db1 = $dbm_maker->();
+ next unless $db1->supports( 'transactions' );
+
my $db2 = $dbm_maker->();
$db1->{x} = 'y';
use_ok( 'DBM::Deep' );
-if ( $ENV{NO_TEST_TRANSACTIONS} ) {
- done_testing;
- exit;
-}
-
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
);
while ( my $dbm_maker = $dbm_factory->() ) {
my $db1 = $dbm_maker->();
+ next unless $db1->supports( 'transactions' );
my $db2 = $dbm_maker->();
$db1->[0] = 'y';
use_ok( 'DBM::Deep' );
-if ( $ENV{NO_TEST_TRANSACTIONS} ) {
- done_testing;
- exit;
-}
-
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
num_txns => 16,
);
-
while ( my $dbm_maker = $dbm_factory->() ) {
my $db1 = $dbm_maker->();
+ next unless $db1->supports( 'transactions' );
my $db2 = $dbm_maker->();
my $db3 = $dbm_maker->();
use_ok( 'DBM::Deep' );
-if ( $ENV{NO_TEST_TRANSACTIONS} ) {
- done_testing;
- exit;
-}
-
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
);
while ( my $dbm_maker = $dbm_factory->() ) {
my $db1 = $dbm_maker->();
+ next unless $db1->supports('transactions');
my $db2 = $dbm_maker->();
$db1->{x} = { xy => { foo => 'y' } };
# reindexing at 17 keys vs. attempting to hit the second-level reindex which
# can occur as early as 18 keys and as late as 4097 (256*16+1) keys.
-if ( $ENV{NO_TEST_TRANSACTIONS} ) {
- done_testing;
- exit;
-}
-
{
my $dbm_factory = new_dbm(
locking => 1,
);
while ( my $dbm_maker = $dbm_factory->() ) {
my $db1 = $dbm_maker->();
+ next unless $db1->supports( 'transactions' );
my $db2 = $dbm_maker->();
$db1->{x} = 'y';
);
while ( my $dbm_maker = $dbm_factory->() ) {
my $db1 = $dbm_maker->();
+ next unless $db1->supports( 'transactions' );
my $db2 = $dbm_maker->();
$db1->{x} = 'y';
my $max_txns = 255;
-if ( $ENV{NO_TEST_TRANSACTIONS} ) {
- done_testing;
- exit;
-}
-
my $dbm_factory = new_dbm(
num_txns => $max_txns,
);
while ( my $dbm_maker = $dbm_factory->() ) {
- my @dbs = grep { $_ } map {
- eval { $dbm_maker->() }
- } 1 .. $max_txns;
+ my @dbs = ( $dbm_maker->() );
+ next unless $dbs[0]->supports('transactions');
+ push @dbs, grep { $_ } map {
+ eval { $dbm_maker->() }
+ } 2 .. $max_txns;
cmp_ok( scalar(@dbs), '==', $max_txns, "We could open enough DB handles" );
use_ok( 'DBM::Deep' );
-if ( $ENV{NO_TEST_TRANSACTIONS} ) {
- done_testing;
- exit;
-}
-
my $dbm_factory = new_dbm(
locking => 1,
autoflush => 1,
);
while ( my $dbm_maker = $dbm_factory->() ) {
my $db1 = $dbm_maker->();
+ next unless $db1->supports( 'transactions' );
my $db2 = $dbm_maker->();
$db1->{foo} = 5;