robkinyon / dbm-deep Goto Github PK
View Code? Open in Web Editor NEWDBM::Deep Perl module
Home Page: http://search.cpan.org/dist/DBM-Deep/
DBM::Deep Perl module
Home Page: http://search.cpan.org/dist/DBM-Deep/
According to https://metacpan.org/dist/DBM-Deep latest version is 2.0016 and here is got repo of the module however there are no here updates since 2017
When storing a number (e.g. 42) in DBM::Deep, it is retrieved as a string (e.g. "42"). This is generally not a problem unless you generate JSON and pass that onto Javascript which trips on this.
Example code:
use DBM::Deep;
use Devel::Peek;
my $v = 3.14;
my $db = DBM::Deep->new( "foo.db" );
$db->{s} = $v;
my $n_scalar = $v;
my $n_db = $db->{s};
my $n_db_add = $db->{s} + 0.0;
print "=====> Value:\n";
print Dump $n_scalar;
print "=====> Value run through db:\n";
print Dump $n_db;
print "=====> Value after conversion to number again:\n";
print Dump $n_db_add;
resulting in the following output:
SV = NV(0x7faed302d810) at 0x7faed302d828
REFCNT = 1
FLAGS = (NOK,pNOK)
NV = 3.14
=====> Value run through db:
SV = PVNV(0x7faed30034f0) at 0x7faed302d840
REFCNT = 1
FLAGS = (POK,pPOK)
IV = 0
NV = 0
PV = 0x7faed2d5d110 "3.14"\0
CUR = 4
LEN = 10
=====> Value after conversion to number again:
SV = NV(0x7faed302d858) at 0x7faed302d870
REFCNT = 1
FLAGS = (NOK,pNOK)
NV = 3.14
The crucial bit is the NOK in the FLAGS section (IOK for integers, etc.).
At the top of https://github.com/robkinyon/dbm-deep/ it reads:
DBM::Deep Perl module
http://search.cpan.org/~rkinyon/DBM-Deep-1.0014/
Changing the link to this should fix that issue going forward:
http://search.cpan.org/dist/DBM-Deep/
If you specify a num_txns
that's different from what's in the DBM file, then you should get a warning. Also, if you call begin_work()
and num_txns
is zero, then it should specifically tell you that.
q.v. http://stackoverflow.com/questions/5126182/dbmdeep-problems-with-transactions for more information.
For some reason I cannot push to github right now. (Something about a TLS version problem. Looks as though I need a system upgrade.)
In any case, I have released DBM-Deep-2.0015.tar.gz (necessary for compatibility with perl 5.28) without pushing the changes to github.
This ticket is a reminder mostly for myself. But if someone wants to beat me to it, I have the patches. Just e-mail me at my sprout cpan address.
When trying to step through multi-level hashes I get "Can't call method "get_next_key" on an undefined value at /usr/share/perl5/DBM/Deep/Engine.pm" whenever I use "next_key".
I've built a Fedora 18 VM on ESXi to just double check that it IS a Raspberry Pi thing (as Pidora is based on F18), and it turns out - it's not....
Build is Fedora 18, 32-bit, from Live CD. I've installed XFCE and the necessary perl modules, plus I've compiled in the Audio:Scan module (which needed little more than make, gcc and zlib-devel).
Running exactly the same test script, as soon as I try to walk through the hash table I hit the problem (see below for output).
So this would seem to be unrelated to the fact I'm running on the Raspberry Pi, but something to do with Fedora 18? Anyway, thought you might want to know as I guess it's much easier for you to troubleshoot as I'm sure you can spin up an F18 locally pretty quickly.
[jon@localhost CaravanCoding]$ uname -a
Linux localhost.localdomain 3.9.6-200.fc18.i686 #1 SMP Thu Jun 13 19:29:40 UTC 2013 i686 i686 i386 GNU/Linux
[jon@localhost CaravanCoding]$ perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for i386-linux-thread-multi
[jon@localhost CaravanCoding]$ perl -d musictest.pl
Loading DB routines from perl5db.pl version 1.37
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
defined(%hash) is deprecated at CecilMods/Music.pm line 1097.
at CecilMods/Music.pm line 1097.
require CecilMods/Music.pm called at musictest.pl line 11
main::BEGIN() called at CecilMods/Music.pm line 1097
eval {...} called at CecilMods/Music.pm line 1097
(Maybe you should just omit the defined()?)
at CecilMods/Music.pm line 1097.
require CecilMods/Music.pm called at musictest.pl line 11
main::BEGIN() called at CecilMods/Music.pm line 1097
eval {...} called at CecilMods/Music.pm line 1097
defined(%hash) is deprecated at CecilMods/Music.pm line 1188.
at CecilMods/Music.pm line 1188.
require CecilMods/Music.pm called at musictest.pl line 11
main::BEGIN() called at CecilMods/Music.pm line 1188
eval {...} called at CecilMods/Music.pm line 1188
(Maybe you should just omit the defined()?)
at CecilMods/Music.pm line 1188.
require CecilMods/Music.pm called at musictest.pl line 11
main::BEGIN() called at CecilMods/Music.pm line 1188
eval {...} called at CecilMods/Music.pm line 1188
CecilMods::Music is successfully loaded!
at CecilMods/Music.pm line 24.
require CecilMods/Music.pm called at musictest.pl line 11
main::BEGIN() called at CecilMods/Music.pm line 0
eval {...} called at CecilMods/Music.pm line 0
main::(musictest.pl:13): my $loop = Glib::MainLoop->new();
DB<1> c
CecilMods::Music DB unusable - reinitialising...
at CecilMods/Music.pm line 84.
Music::initialise('Music=HASH(0x9b1f1a0)') called at CecilMods/Music.pm line 72
Music::new('Music') called at musictest.pl line 15
Music object created
Data dumper says '.
$VAR1 = bless( {
'_QL_TRACKS' => [],
'_FF_NODE' => undef,
'_CURRENT_TRACK' => undef,
'_MDB' => bless( {
'TRACKTABLE' => bless( {}, 'DBM::Deep::Hash' ),
'ALBUMTABLE' => bless( {}, 'DBM::Deep::Hash' ),
'ARTALBTABLE' => bless( {}, 'DBM::Deep::Hash' ),
'ARTTRKTABLE' => bless( {}, 'DBM::Deep::Hash' ),
'SAVESTATE' => bless( {}, 'DBM::Deep::Hash' )
}, 'DBM::Deep::Hash' ),
'_PLAYLIST_MAXLEN' => 100,
'_DBFILE' => 'CecilMusicDB.db',
'_FILEREAD_POS' => 0,
'_PLAYLIST' => undef,
'_CURRENT_LENGTH' => undef,
'_FILEREAD_ACT' => 0,
'_FILEREAD_TOT' => 0,
'_PLAYER' => bless( {}, 'GStreamer::Pipeline' ),
'_CURRENT_POS' => undef,
'_QL_ARTISTS' => [],
'_FILEREAD_SUC' => 0,
'_MEDIA_DIR' => '/home/jon/Music/',
'_PLAYLIST_CHANGED' => 0,
'_STATE' => 'READY'
}, 'Music' );
Running FindFile Test
Supported media is: '.mp3','.m4a','.m4p','.mp4'
New Album : Dirt Disc: 1/1 - Alice In Chains
New Artist Found: Alice In Chains
New Album : Nothing Safe: Best Of The Box Disc: 1/1 - Alice In Chains
New Album : Rock In A Hard Place Disc: 1/1 - Aerosmith
New Artist Found: Aerosmith
New Album : Night In The Ruts Disc: 1/1 - Aerosmith
New Album : Permanent Vacation Disc: 1/1 - Aerosmith
New Album : Draw The Line Disc: 1/1 - Aerosmith
MUSIC MOD: Alice In Chains: DBM::Deep::Hash=HASH(0xb754850) retrieved. (this is the first_key - which points to a hash of albums by that Artist)
Can't call method "get_next_key" on an undefined value at /usr/share/perl5/vendor_perl/DBM/Deep/Engine.pm line 258.
at /usr/share/perl5/vendor_perl/DBM/Deep/Engine.pm line 258.
DBM::Deep::Engine::get_next_key('DBM::Deep::Engine::File=HASH(0xa4ea3c0)', 'DBM::Deep::Hash=HASH(0xb754520)', 'Alice In Chains') called at /usr/share/perl5/vendor_perl/DBM/Deep/Hash.pm line 97
DBM::Deep::Hash::NEXTKEY('DBM::Deep::Hash=HASH(0xa652b58)', 'Alice In Chains') called at /usr/share/perl5/vendor_perl/DBM/Deep/Hash.pm line 107
DBM::Deep::Hash::next_key('DBM::Deep::Hash=HASH(0xa652b58)', 'Alice In Chains') called at CecilMods/Music.pm line 637
Music::generate_ql_artists('Music=HASH(0x9b1f1a0)') called at CecilMods/Music.pm line 859
Music::scanmediadir('Music=HASH(0x9b1f1a0)') called at musictest.pl line 22
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> q
[jon@localhost CaravanCoding]$
eg ...
Can't locate t/common.pm in @INC (you may need to install the t::common module)
(@INC contains: /home/david/cpantesting/perl-5.26.0/.cpan/build/DBM-Deep-2.0013-
0/blib/lib /home/david/cpantesting/perl-5.26.0/.cpan/build/DBM-Deep-2.0013-0/bli
b/arch /home/david/cpantesting/perl-5.26.0/.cpan/build/DBM-Deep-2.0013-0/_build/
lib /home/david/cpantesting/perl-5.26.0/lib/site_perl/5.26.0/x86_64-linux-thread
-multi /home/david/cpantesting/perl-5.26.0/lib/site_perl/5.26.0 /home/david/cpan
testing/perl-5.26.0/lib/5.26.0/x86_64-linux-thread-multi /home/david/cpantesting
/perl-5.26.0/lib/5.26.0) at t/01_basic.t line 6.
BEGIN failed--compilation aborted at t/01_basic.t line 6.
t/01_basic.t ....................
Dubious, test returned 2 (wstat 512, 0x200)
The solution is to use lib 't'; use common;
.
I have discovered a memory leak in the latest version when trying to use a tied hash. After simplifying the code, I see the same behavior with a simple key/value store, and this behavior is seen with the OO interface or a tied hash.
It should be easy to replicate. For reference, I posted this question on StackOverflow and someone commented that they could also replicate this issue. I could provide more information if needed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.