r58675 - in /branches/upstream/libdbm-deep-perl/current: Build.PL Changes META.yml README lib/DBM/Deep.pm lib/DBM/Deep.pod lib/DBM/Deep/Engine.pm lib/DBM/Deep/Engine/DBI.pm lib/DBM/Deep/Engine/File.pm lib/DBM/Deep/Null.pm t/39_singletons.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Mon May 31 05:03:45 UTC 2010


Author: ansgar-guest
Date: Mon May 31 05:03:33 2010
New Revision: 58675

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=58675
Log:
[svn-upgrade] Integrating new upstream version, libdbm-deep-perl (1.0024)

Modified:
    branches/upstream/libdbm-deep-perl/current/Build.PL
    branches/upstream/libdbm-deep-perl/current/Changes
    branches/upstream/libdbm-deep-perl/current/META.yml
    branches/upstream/libdbm-deep-perl/current/README
    branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pm
    branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pod
    branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine.pm
    branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/DBI.pm
    branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/File.pm
    branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Null.pm
    branches/upstream/libdbm-deep-perl/current/t/39_singletons.t

Modified: branches/upstream/libdbm-deep-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/Build.PL?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/Build.PL (original)
+++ branches/upstream/libdbm-deep-perl/current/Build.PL Mon May 31 05:03:33 2010
@@ -6,13 +6,6 @@
 my $build = Module::Build->subclass(
     class => "Module::Build::Custom",
     code => '
-        sub prepare_metadata {
-            my $node = shift->SUPER::prepare_metadata(@_);
-            my $ver = $node->{version};
-            $_->{version} = $ver for values %{$node->{provides}};
-            $node;
-        }
-
         sub ACTION_test {
             my $self = shift;
             if ( $self->notes(\'TEST_MYSQL_DSN\') ) {
@@ -40,7 +33,6 @@
         'File::Path'      => '0.01',
         'File::Temp'      => '0.01',
         'Pod::Usage'      => '1.3',
-        'Test::More'      => '0.88',
         'Test::Deep'      => '0.095',
         'Test::Warn'      => '0.08',
         'Test::More'      => '0.88', # done_testing
@@ -69,6 +61,7 @@
             },
         },
     },
+    meta_add => { no_index => { directory => [ 'utils' ] } },
 );
 
 if ( $build->y_n( "Run the long-running tests", 'n' ) ) {

Modified: branches/upstream/libdbm-deep-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/Changes?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/Changes (original)
+++ branches/upstream/libdbm-deep-perl/current/Changes Mon May 31 05:03:33 2010
@@ -1,4 +1,16 @@
 Revision history for DBM::Deep (ordered by revision number).
+
+1.0024 May 30 14:25:00 2010 PDT
+    (This version is compatible with 1.0023)
+    - Stale references (objects blessed into DBM::Deep::Null), which
+      have always supposed to act like undef, now compare equal to
+      undef, "" and 0. $stale_ref eq "" used to return false, even
+      though "$stale_ref" was the empty string.
+    - If you assign a stale reference to a database location,
+      DBM::Deep now warns and assigns undef, instead of dying with
+      obscure error messages.
+    - Using a stale reference as a hash or array ref now causes an
+      error with a more helpful message.
 
 1.0023 May 9 14:33:00 2010 PDT
     (This version is compatible with 1.0022)

Modified: branches/upstream/libdbm-deep-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/META.yml?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/META.yml (original)
+++ branches/upstream/libdbm-deep-perl/current/META.yml Mon May 31 05:03:33 2010
@@ -18,85 +18,63 @@
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
   version: 1.4
 name: DBM-Deep
+no_index:
+  directory:
+    - utils
 provides:
   DBM::Deep:
     file: lib/DBM/Deep.pm
-    version: 1.0023
+    version: 1.0024
   DBM::Deep::Array:
     file: lib/DBM/Deep/Array.pm
-    version: 1.0023
   DBM::Deep::Engine:
     file: lib/DBM/Deep/Engine.pm
-    version: 1.0023
   DBM::Deep::Engine::DBI:
     file: lib/DBM/Deep/Engine/DBI.pm
-    version: 1.0023
   DBM::Deep::Engine::File:
     file: lib/DBM/Deep/Engine/File.pm
-    version: 1.0023
   DBM::Deep::Hash:
     file: lib/DBM/Deep/Hash.pm
-    version: 1.0023
   DBM::Deep::Iterator:
     file: lib/DBM/Deep/Iterator.pm
-    version: 1.0023
   DBM::Deep::Iterator::DBI:
     file: lib/DBM/Deep/Iterator/DBI.pm
-    version: 1.0023
   DBM::Deep::Iterator::File:
     file: lib/DBM/Deep/Iterator/File.pm
-    version: 1.0023
   DBM::Deep::Iterator::File::BucketList:
     file: lib/DBM/Deep/Iterator/File/BucketList.pm
-    version: 1.0023
   DBM::Deep::Iterator::File::Index:
     file: lib/DBM/Deep/Iterator/File/Index.pm
-    version: 1.0023
   DBM::Deep::Null:
     file: lib/DBM/Deep/Null.pm
-    version: 1.0023
   DBM::Deep::Sector:
     file: lib/DBM/Deep/Sector.pm
-    version: 1.0023
   DBM::Deep::Sector::DBI:
     file: lib/DBM/Deep/Sector/DBI.pm
-    version: 1.0023
   DBM::Deep::Sector::DBI::Reference:
     file: lib/DBM/Deep/Sector/DBI/Reference.pm
-    version: 1.0023
   DBM::Deep::Sector::DBI::Scalar:
     file: lib/DBM/Deep/Sector/DBI/Scalar.pm
-    version: 1.0023
   DBM::Deep::Sector::File:
     file: lib/DBM/Deep/Sector/File.pm
-    version: 1.0023
   DBM::Deep::Sector::File::BucketList:
     file: lib/DBM/Deep/Sector/File/BucketList.pm
-    version: 1.0023
   DBM::Deep::Sector::File::Data:
     file: lib/DBM/Deep/Sector/File/Data.pm
-    version: 1.0023
   DBM::Deep::Sector::File::Index:
     file: lib/DBM/Deep/Sector/File/Index.pm
-    version: 1.0023
   DBM::Deep::Sector::File::Null:
     file: lib/DBM/Deep/Sector/File/Null.pm
-    version: 1.0023
   DBM::Deep::Sector::File::Reference:
     file: lib/DBM/Deep/Sector/File/Reference.pm
-    version: 1.0023
   DBM::Deep::Sector::File::Scalar:
     file: lib/DBM/Deep/Sector/File/Scalar.pm
-    version: 1.0023
   DBM::Deep::Storage:
     file: lib/DBM/Deep/Storage.pm
-    version: 1.0023
   DBM::Deep::Storage::DBI:
     file: lib/DBM/Deep/Storage/DBI.pm
-    version: 1.0023
   DBM::Deep::Storage::File:
     file: lib/DBM/Deep/Storage/File.pm
-    version: 1.0023
 requires:
   Digest::MD5: 1.00
   Fcntl: 0.01
@@ -104,4 +82,4 @@
   perl: 5.006_000
 resources:
   license: http://dev.perl.org/licenses/
-version: 1.0023
+version: 1.0024

Modified: branches/upstream/libdbm-deep-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/README?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/README (original)
+++ branches/upstream/libdbm-deep-perl/current/README Mon May 31 05:03:33 2010
@@ -171,7 +171,7 @@
     tie() function. The object returned from tie() can be used to call
     methods, such as lock() and unlock(). (That object can be retrieved from
     the tied variable at any time using tied() - please see perltie for more
-    info.
+    info.)
 
       my %hash;
       my $db = tie %hash, "DBM::Deep", "foo.db";
@@ -350,7 +350,7 @@
     interface to manipulate all aspects of DBM::Deep databases. Each type of
     object (hash or array) has its own methods, but both types share the
     following common methods: `put()', `get()', `exists()', `delete()' and
-    `clear()'. `fetch()' and `store(' are aliases to `put()' and `get()',
+    `clear()'. `fetch()' and `store()' are aliases to `put()' and `get()',
     respectively.
 
     * new() / clone()
@@ -972,6 +972,11 @@
       $db->lock_exclusive;
       my %hash = %{ $db->{some_hash} };
       $db->unlock;
+
+    As of version 1.0024, if you assign a stale reference to a location in
+    the database, DBM::Deep will warn, if you have uninitialized warnings
+    enabled, and treat the stale reference as `undef'. An attempt to use a
+    stale reference as an array or hash reference will cause an error.
 
   Large Arrays
     Beware of using `shift()', `unshift()' or `splice()' with large arrays.

Modified: branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pm?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pm (original)
+++ branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pm Mon May 31 05:03:33 2010
@@ -6,7 +6,7 @@
 use warnings FATAL => 'all';
 no warnings 'recursion';
 
-our $VERSION = q(1.0023);
+our $VERSION = q(1.0024);
 
 use Scalar::Util ();
 
@@ -607,5 +607,25 @@
 
 sub _dump_file {shift->_get_self->_engine->_dump_file;}
 
+sub _warnif {
+ # There is, unfortunately, no way to avoid this hack. warnings.pm does not
+ # allow us to specify exactly the call frame we want. So, for now, we just
+ # look at the bitmask ourselves.
+ my $level;
+ {
+  my($pack, $file, $line, $bitmask) = (caller $level++)[0..2,9];
+  redo if $pack =~ /^DBM::Deep(?:::|\z)/;
+  if(  vec $bitmask, $warnings'Offsets{$_[0]}, 1,
+    || vec $bitmask, $warnings'Offsets{all}, 1,
+    ) {
+     my $msg = $_[1] =~ /\n\z/ ? $_[1] : "$_[1] at $file line $line.\n";
+     die $msg
+      if  vec $bitmask, $warnings'Offsets{$_[0]}+1, 1,
+       || vec $bitmask, $warnings'Offsets{all}+1, 1;
+     warn $msg;
+  }
+ }
+}
+
 1;
 __END__

Modified: branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pod?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pod (original)
+++ branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep.pod Mon May 31 05:03:33 2010
@@ -202,7 +202,7 @@
 Alternately, you can create a DBM::Deep handle by using Perl's built-in
 tie() function. The object returned from tie() can be used to call methods,
 such as lock() and unlock(). (That object can be retrieved from the tied
-variable at any time using tied() - please see L<perltie> for more info.
+variable at any time using tied() - please see L<perltie> for more info.)
 
   my %hash;
   my $db = tie %hash, "DBM::Deep", "foo.db";
@@ -403,7 +403,7 @@
 to manipulate all aspects of DBM::Deep databases. Each type of object (hash or
 array) has its own methods, but both types share the following common methods:
 C<put()>, C<get()>, C<exists()>, C<delete()> and C<clear()>. C<fetch()> and
-C<store(> are aliases to C<put()> and C<get()>, respectively.
+C<store()> are aliases to C<put()> and C<get()>, respectively.
 
 =over
 
@@ -1084,6 +1084,11 @@
   $db->lock_exclusive;
   my %hash = %{ $db->{some_hash} };
   $db->unlock;
+
+As of version 1.0024, if you assign a stale reference to a location
+in the database, DBM::Deep will warn, if you have uninitialized warnings
+enabled, and treat the stale reference as C<undef>. An attempt to use a
+stale reference as an array or hash reference will cause an error.
 
 =head2 Large Arrays
 

Modified: branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine.pm?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine.pm (original)
+++ branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine.pm Mon May 31 05:03:33 2010
@@ -79,14 +79,14 @@
 =head1 TRANSACTIONS
 
 Transactions in DBM::Deep are implemented using a variant of MVCC. This attempts
-to keep the amount of actual work done against the file low while stil providing
+to keep the amount of actual work done against the file low while still providing
 Atomicity, Consistency, and Isolation. Durability, unfortunately, cannot be done
 with only one file.
 
 =head2 STALENESS
 
 If another process uses a transaction slot and writes stuff to it, then
-terminates, the data that process wrote it still within the file. In order to
+terminates, the data that process wrote is still within the file. In order to
 address this, there is also a transaction staleness counter associated within
 every write.  Each time a transaction is started, that process increments that
 transaction's staleness counter. If, when it reads a value, the staleness

Modified: branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/DBI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/DBI.pm?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/DBI.pm (original)
+++ branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/DBI.pm Mon May 31 05:03:33 2010
@@ -216,7 +216,9 @@
         or die "Cannot load sector at '@{[$obj->_base_offset]}'\n";;
 
     my ($type, $class);
-    if ( $r eq 'ARRAY' || $r eq 'HASH' ) {
+    if (
+     $r eq 'ARRAY' || $r eq 'HASH' and ref $value ne 'DBM::Deep::Null'
+    ) {
         my $tmpvar;
         if ( $r eq 'ARRAY' ) {
             $tmpvar = tied @$value;
@@ -261,6 +263,13 @@
             DBM::Deep->_throw_error( "Cannot store something that is tied." );
         }
 
+        if ( ref $value eq 'DBM::Deep::Null' ) {
+            DBM::Deep::_warnif(
+             'uninitialized', 'Assignment of stale reference'
+            );
+            $value = undef;
+        }
+
         $class = 'DBM::Deep::Sector::DBI::Scalar';
         $type  = 'S';
     }

Modified: branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/File.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/File.pm?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/File.pm (original)
+++ branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Engine/File.pm Mon May 31 05:03:33 2010
@@ -298,6 +298,13 @@
     if ( !defined $value ) {
         $class = 'DBM::Deep::Sector::File::Null';
     }
+    elsif ( ref $value eq 'DBM::Deep::Null' ) {
+        DBM::Deep::_warnif(
+             'uninitialized', 'Assignment of stale reference'
+        );
+        $class = 'DBM::Deep::Sector::File::Null';
+        $value = undef;
+    }
     elsif ( $r eq 'ARRAY' || $r eq 'HASH' ) {
         my $tmpvar;
         if ( $r eq 'ARRAY' ) {
@@ -590,7 +597,7 @@
 =head2 get_txn_staleness_counter( $trans_id )
 
 This will return the staleness counter for the given transaction ID. Please see
-L</TRANSACTION STALENESS> for more information.
+L<DBM::Deep::Engine/STALENESS> for more information.
 
 =cut
 
@@ -612,7 +619,7 @@
 =head2 inc_txn_staleness_counter( $trans_id )
 
 This will increment the staleness counter for the given transaction ID. Please see
-L</TRANSACTION STALENESS> for more information.
+L<DBM::Deep::Engine/STALENESS> for more information.
 
 =cut
 

Modified: branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Null.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Null.pm?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Null.pm (original)
+++ branches/upstream/libdbm-deep-perl/current/lib/DBM/Deep/Null.pm Mon May 31 05:03:33 2010
@@ -26,6 +26,20 @@
     'bool'   => sub { undef },
     '""'     => sub { undef },
     '0+'     => sub { 0 },
+   ('cmp'    => 
+    '<=>'    => sub {
+                  return 0 if !defined $_[1] || !length $_[1];
+                  return $_[2] ? 1 : -1;
+                }
+   )[0,2,1,2], # same sub for both ops
+    '%{}'    => sub {
+                  require Carp;
+                  Carp::croak("Can't use a stale reference as a HASH");
+                },
+    '@{}'    => sub {
+                  require Carp;
+                  Carp::croak("Can't use a stale reference as an ARRAY");
+                },
     fallback => 1,
     nomethod => 'AUTOLOAD';
 

Modified: branches/upstream/libdbm-deep-perl/current/t/39_singletons.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbm-deep-perl/current/t/39_singletons.t?rev=58675&op=diff
==============================================================================
--- branches/upstream/libdbm-deep-perl/current/t/39_singletons.t (original)
+++ branches/upstream/libdbm-deep-perl/current/t/39_singletons.t Mon May 31 05:03:33 2010
@@ -4,6 +4,10 @@
 use Test::More;
 use Test::Deep;
 use t::common qw( new_dbm );
+
+sub is_undef {
+ ok(!defined $_[0] || ref $_[0] eq 'DBM::Deep::Null', $_[1])
+}
 
 use_ok( 'DBM::Deep' );
 
@@ -26,11 +30,11 @@
         is( $x, $y, "The references are the same" );
 
         delete $db->{foo};
-        is( $x, undef, "After deleting the DB location, external references are also undef (\$x)" );
-        is( $y, undef, "After deleting the DB location, external references are also undef (\$y)" );
+        is_undef( $x, "After deleting the DB location, external references are also undef (\$x)" );
+        is_undef( $y, "After deleting the DB location, external references are also undef (\$y)" );
         is( eval { $x + 0 }, undef, "DBM::Deep::Null can be added to." );
         is( eval { $y + 0 }, undef, "DBM::Deep::Null can be added to." );
-        is( $db->{foo}, undef, "The {foo} location is also undef." );
+        is_undef( $db->{foo}, "The {foo} location is also undef." );
 
         # These shenanigans work to get another hashref
         # into the same data location as $db->{foo} was.
@@ -39,9 +43,53 @@
         $db->{foo} = {};
         $db->{bar} = {};
 
-        is( $x, undef, "After re-assigning to {foo}, external references to old values are still undef (\$x)" );
-        is( $y, undef, "After re-assigning to {foo}, external references to old values are still undef (\$y)" );
+        is_undef( $x, "After re-assigning to {foo}, external references to old values are still undef (\$x)" );
+        is_undef( $y, "After re-assigning to {foo}, external references to old values are still undef (\$y)" );
+
+        my($w,$line);
+        my $file = __FILE__;
+        local $SIG{__WARN__} = sub { $w = $_[0] };
+        eval {
+            $line = __LINE__;   $db->{stext} = $x;
+        };
+        is $@, "Assignment of stale reference at $file line $line.\n",
+            'assigning a stale reference to the DB dies w/FATAL warnings';
+        {
+            no warnings FATAL => "all";
+            use warnings 'uninitialized'; # non-FATAL
+            $db->{stext} = $x;     $line = __LINE__;
+            is $w, "Assignment of stale reference at $file line $line.\n",
+              'assigning a stale reference back to the DB warns';
+        }
+        {
+            no warnings 'uninitialized';
+            $w = undef;
+            $db->{stext} = $x;
+            is $w, undef,
+              'stale ref assignment warnings can be suppressed';
+        }
+
+	eval {                   $line = __LINE__+1;
+          () = $x->{stit};
+        };
+        like $@,
+          qr/^Can't use a stale reference as a HASH at \Q$file\E line(?x:
+             ) $line\.?\n\z/,
+          'Using a stale reference as a hash dies';
+	eval {                   $line = __LINE__+1;
+          () = $x->[28];
+        };
+        like $@,
+          qr/^Can't use a stale reference as an ARRAY at $file line (?x:
+             )$line\.?\n\z/,
+          'Using a stale reference as an array dies';
     }
+}
+
+{
+ my $null = bless {}, 'DBM::Deep::Null';
+ cmp_ok $null, 'eq', undef, 'DBM::Deep::Null compares equal to undef';
+ cmp_ok $null, '==', undef, 'DBM::Deep::Null compares ==ual to undef';
 }
 
 SKIP: {




More information about the Pkg-perl-cvs-commits mailing list