This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to DB_File 1.838 from CPAN.
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 15 May 2016 22:03:33 +0000 (18:03 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 15 May 2016 22:03:33 +0000 (18:03 -0400)
Porting/Maintainers.pl
cpan/DB_File/DB_File.pm
cpan/DB_File/DB_File.xs
cpan/DB_File/t/db-btree.t

index c118e0e..e6b63bd 100755 (executable)
@@ -330,7 +330,7 @@ use File::Glob qw(:case);
     },
 
     'DB_File' => {
-        'DISTRIBUTION' => 'PMQS/DB_File-1.835.tar.gz',
+        'DISTRIBUTION' => 'PMQS/DB_File-1.838.tar.gz',
         'FILES'        => q[cpan/DB_File],
         'EXCLUDED'     => [
             qr{^patches/},
index 9b1f957..8e40902 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Written by Paul Marquess (pmqs@cpan.org)
 #
-#     Copyright (c) 1995-2014 Paul Marquess. All rights reserved.
+#     Copyright (c) 1995-2016 Paul Marquess. All rights reserved.
 #     This program is free software; you can redistribute it and/or
 #     modify it under the same terms as Perl itself.
 
@@ -163,7 +163,7 @@ our ($db_version, $use_XSLoader, $splice_end_array_no_length, $splice_end_array,
 use Carp;
 
 
-$VERSION = "1.835" ;
+$VERSION = "1.838" ;
 $VERSION = eval $VERSION; # needed for dev releases
 
 {
@@ -1771,9 +1771,30 @@ R_RECNOSYNC is the only valid flag at present.
 
 =head1 DBM FILTERS
 
-A DBM Filter is a piece of code that is be used when you I<always>
-want to make the same transformation to all keys and/or values in a
-DBM database.
+A DBM Filter is a piece of code that is be used when you I<always> want to
+make the same transformation to all keys and/or values in a DBM database.
+An example is when you need to encode your data in UTF-8 before writing to
+the database and then decode the UTF-8 when reading from the database file.
+
+There are two ways to use a DBM Filter.
+
+=over 5
+
+=item 1.
+
+Using the low-level API defined below.
+
+=item 2.
+
+Using the L<DBM_Filter> module. 
+This module hides the complexity of the API defined below and comes
+with a number of "canned" filters that cover some of the common use-cases.
+
+=back
+
+Use of the L<DBM_Filter> module is recommended.
+
+=head2 DBM Filter Low-level API
 
 There are four methods associated with DBM Filters. All work identically,
 and each is used to install (or uninstall) a single DBM Filter. Each
@@ -2182,6 +2203,29 @@ can layer transparently over B<DB_File> to accomplish this feat.
 Check out the MLDBM module, available on CPAN in the directory
 F<modules/by-module/MLDBM>.
 
+=head2 What does "wide character in subroutine entry" mean?
+
+You will usually get this message if you are working with UTF-8 data and
+want to read/write it from/to a Berkeley DB database file.
+
+The easist way to deal with this issue is to use the pre-defined "utf8"
+B<DBM_Filter> (see L<DBM_Filter>) that was designed to deal with this
+situation.
+
+The example below shows what you need if I<both> the key and value are
+expected to be in UTF-8. 
+
+    use DB_File;
+    use DBM_Filter; 
+
+    my $db = tie %h, 'DB_File', '/tmp/try.db', O_CREAT|O_RDWR, 0666, $DB_BTREE; 
+    $db->Filter_Key_Push('utf8');
+    $db->Filter_Value_Push('utf8');
+
+    my $key = "\N{LATIN SMALL LETTER A WITH ACUTE}";
+    my $value = "\N{LATIN SMALL LETTER E WITH ACUTE}";
+    $h{ $key } = $value;
+
 =head2 What does "Invalid Argument" mean?
 
 You will get this error message when one of the parameters in the
@@ -2273,7 +2317,7 @@ archive in F<src/misc/db.1.85.tar.gz>.
 
 =head1 COPYRIGHT
 
-Copyright (c) 1995-2012 Paul Marquess. All rights reserved. This program
+Copyright (c) 1995-2016 Paul Marquess. All rights reserved. This program
 is free software; you can redistribute it and/or modify it under the
 same terms as Perl itself.
 
@@ -2300,7 +2344,7 @@ Berkeley DB authors or the author of DB_File. See L<"AUTHOR"> for details.
 =head1 SEE ALSO
 
 L<perl>, L<dbopen(3)>, L<hash(3)>, L<recno(3)>, L<btree(3)>,
-L<perldbmfilter>
+L<perldbmfilter>, L<DBM_Filter>
 
 =head1 AUTHOR
 
index 151ec31..f417b22 100644 (file)
@@ -6,7 +6,7 @@
 
  All comments/suggestions/problems are welcome
 
-     Copyright (c) 1995-2014 Paul Marquess. All rights reserved.
+     Copyright (c) 1995-2016 Paul Marquess. All rights reserved.
      This program is free software; you can redistribute it and/or
      modify it under the same terms as Perl itself.
 
@@ -270,7 +270,7 @@ typedef db_recno_t  recno_t;
 #if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 5
 #  define R_SETCURSOR  0x800000
 #else
-#  define R_SETCURSOR  (-100)
+#  define R_SETCURSOR  (DB_OPFLAGS_MASK)
 #endif
 
 #define R_RECNOSYNC     0
@@ -536,7 +536,6 @@ u_int               flags ;
     if (flagSet(flags, R_CURSOR)) {
        return ((db->cursor)->c_put)(db->cursor, &key, &value, DB_CURRENT);
     }
-
     if (flagSet(flags, R_SETCURSOR)) {
        if ((db->dbp)->put(db->dbp, NULL, &key, &value, 0) != 0)
                return -1 ;
@@ -1437,10 +1436,10 @@ SV *   sv ;
                    value = (int)SvIV(*svp) ;
 
                if (fixed) {
-                   status = dbp->set_re_pad(dbp, value) ;
+                   (void)dbp->set_re_pad(dbp, value) ;
                }
                else {
-                   status = dbp->set_re_delim(dbp, value) ;
+                   (void)dbp->set_re_delim(dbp, value) ;
                }
 
             }
@@ -1449,12 +1448,12 @@ SV *   sv ;
                svp = hv_fetch(action, "reclen", 6, FALSE);
               if (svp) {
                   u_int32_t len =  my_SvUV32(*svp) ;
-                   status = dbp->set_re_len(dbp, len) ;
+                   (void)dbp->set_re_len(dbp, len) ;
               }    
           }
          
            if (name != NULL) {
-               status = dbp->set_re_source(dbp, name) ;
+               (void)dbp->set_re_source(dbp, name) ;
                name = NULL ;
            }   
 
@@ -1467,7 +1466,7 @@ SV *   sv ;
                name = NULL ;
          
 
-           status = dbp->set_flags(dbp, (u_int32_t)DB_RENUMBER) ;
+           (void)dbp->set_flags(dbp, (u_int32_t)DB_RENUMBER) ;
          
                if (flags){
                    (void)dbp->set_flags(dbp, (u_int32_t)flags) ;
index fb89a40..4e2968e 100644 (file)
@@ -1261,33 +1261,6 @@ EOM
 
 }
 
-#{
-#   # R_SETCURSOR
-#   use strict ;
-#   my (%h, $db) ;
-#   unlink $Dfile;
-#
-#   ok(156, $db = tie(%h, 'DB_File', $Dfile, O_RDWR|O_CREAT, 0640, $DB_BTREE ) );
-#
-#   $h{abc} = 33 ;
-#   my $k = "newest" ;
-#   my $v = 44 ;
-#   my $status = $db->put($k, $v, R_SETCURSOR) ;
-#   print "status = [$status]\n" ;
-#   ok(157, $status == 0) ;
-#   $status = $db->del($k, R_CURSOR) ;
-#   print "status = [$status]\n" ;
-#   ok(158, $status == 0) ;
-#   $k = "newest" ;
-#   ok(159, $db->get($k, $v, R_CURSOR)) ;
-#
-#   ok(160, keys %h == 1) ;
-#   
-#   undef $db ;
-#   untie %h;
-#   unlink $Dfile;
-#}
-
 {
     # Bug ID 20001013.009
     #
@@ -1654,4 +1627,37 @@ ok(165,1);
     untie %h;
     unlink $Dfile;
 }
+
+#{
+#   # R_SETCURSOR
+#   use strict ;
+#   my (%h, $db) ;
+#   unlink $Dfile;
+#
+#   ok 198, $db = tie(%h, 'DB_File', $Dfile, O_RDWR|O_CREAT, 0640, $DB_BTREE ) ;
+#
+#   $h{abc} = 33 ;
+#   my $k = "newest" ;
+#   my $v = 44 ;
+#   my $status = $db->put($k, $v, R_SETCURSOR) ;
+#   print "status = [$status]\n" ;
+#   ok 199, $status == 0 ;
+#   $k = $v = '';
+#   $status = $db->get($k, $v, R_CURSOR) ;
+#   ok 200, $status == 0 ;
+#   ok 201, $k eq 'newest';
+#   ok 202, $v == 44;
+#   $status = $db->del($k, R_CURSOR) ;
+#   print "status = [$status]\n" ;
+#   ok(203, $status == 0) ;
+#   $k = "newest" ;
+#   ok(204, $db->get($k, $v, R_CURSOR)) ;
+#
+#   ok(205, keys %h == 1) ;
+#   
+#   undef $db ;
+#   untie %h;
+#   unlink $Dfile;
+#}
+
 exit ;