},
'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/},
#
# 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.
use Carp;
-$VERSION = "1.835" ;
+$VERSION = "1.838" ;
$VERSION = eval $VERSION; # needed for dev releases
{
=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
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
=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.
=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
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.
#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
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 ;
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) ;
}
}
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 ;
}
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) ;
}
-#{
-# # 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
#
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 ;