perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <>
Subject BerkeleyDB solution
Date Tue, 10 Mar 2009 08:55:58 GMT

this is not a problem but a solution. I know some of you use the 
BerkeleyDB module to store data. Recently I have tried to use UTF8 keys 
and failed. When reading back keys I sometimes got character strings 
sometimes octet strings. I had used the following 2 filters to ensure 
the data in the database is octet strings and the data I get back are 
character strings:

  $db->filter_fetch_key(sub { $_=Encode::decode('utf8', $_) });
  $db->filter_store_key(sub { $_=Encode::encode('utf8', $_) });

The problem is BerkeleyDB doesn't reset the UTF8 bit when storing data 
to @_ variables as in c_get() or db_get(). One possible solution is

  $db->filter_fetch_key(sub {
    $_=Encode::decode('utf8', $_);

The other/better one is to fix it in BerkeleyDB.xs. This is what the 
attached patch does. I have sent it to the author, Paul Marquess. Here 
is his reply:

On Tue 10 Mar 2009, Paul Marquess wrote:
> Your patch looks fine and should be ok to include in my development
> copy without any changes.


Need professional mod_perl support?
Just hire me:

View raw message