develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #117953] SDBM_File/GDBM_File errors

Thread Previous
From:
James E Keenan via RT
Date:
May 11, 2013 00:00
Subject:
[perl #117953] SDBM_File/GDBM_File errors
Message ID:
rt-3.6.HEAD-6955-1368230443-1041.117953-15-0@perl.org
On Fri May 10 13:22:59 2013, cowboyatheart@gmail.com wrote:
> This is a bug report for perl from cowboyatheart@gmail.com,
> generated with the help of perlbug 1.39 running under perl 5.14.2.
> 
> 
> -----------------------------------------------------------------
> [Please describe your issue here]
> 
> GDBM_File, and SDBM_File both end early when using each to iterate
> over a
> tied hash and deleting keys.
> 
> Test script:
> 
> use strict;
> use warnings;
> use Fcntl;
> use SDBM_File;
> use GDBM_File;
> use DB_File;
> 
> # plain old hash
> {
> my %hash;
> 
> # add 100 keys
> my $x = 1;
> while ($x <= 100) {
> $hash{$x} = $x;
> ++$x;
> }
> 
> print "plain old hash has " . scalar(keys %hash) . " keys\n";
> 
> # iterate/delete
> my $cnt = 0;
> while (my ($key,$value) = each %hash) {
> $cnt++;
> delete $hash{$key};
> }
> print "deleted $cnt keys in plain old hash\n";
> }
> # sdbm
> {
> my %hash;
> tie(%hash, 'SDBM_File', 'error.sdbm', O_RDWR|O_CREAT, 0666) or die $!;
> 
> # add 100 keys
> my $x = 1;
> while ($x <= 100) {
> $hash{$x} = $x;
> ++$x;
> }
> 
> print "sdbm has " . scalar(keys %hash) . " keys\n";
> 
> # iterate/delete
> my $cnt = 0;
> while (my ($key,$value) = each %hash) {
> $cnt++;
> delete $hash{$key};
> }
> print "deleted $cnt keys in sdbm\n";
> }
> # gdbm
> {
> my %hash;
> tie(%hash, 'GDBM_File', 'error.gdbm', O_RDWR|O_CREAT, 0666) or die $!;
> 
> # add 100 keys
> my $x = 1;
> while ($x <= 100) {
> $hash{$x} = $x;
> ++$x;
> }
> print "gdbm has " . scalar(keys %hash) . " keys\n";
> 
> # iterate/delete
> my $cnt = 0;
> while (my ($key,$value) = each %hash) {
> $cnt++;
> delete $hash{$key};
> }
> print "deleted $cnt keys in gdbm\n";
> 
> }
> # bdb
> {
> my %hash;
> tie(%hash, 'DB_File', 'error.bdb', O_RDWR|O_CREAT, 0666) or die $!;
> 
> # add 100 keys
> my $x = 1;
> while ($x <= 100) {
> $hash{$x} = $x;
> ++$x;
> }
> 
> print "bdb has " . scalar(keys %hash) . " keys\n";
> 
> # iterate/delete
> my $cnt = 0;
> while (my ($key,$value) = each %hash) {
> $cnt++;
> delete $hash{$key};
> }
> print "deleted $cnt keys in bdb\n";
> }
> 
> 
> 
> Output:
> 
> plain old hash has 100 keys
> deleted 100 keys in plain old hash
> sdbm has 100 keys
> deleted 50 keys in sdbm
> gdbm has 100 keys
> deleted 1 keys in gdbm
> bdb has 100 keys
> deleted 100 keys in bdb
> 
> 
> 


Can anyone make a determination as to whether this is the same bug as RT
#74984?



---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=117953

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About