wrote:
> wrote:
> > Perl 5.8.0
> > Newest DBD::AnyData and AnyData just downloaded from CPAN.
> > When export a test database to xml, the script hangs and seems
> > it's in a dead loop.
> >
> > ********My Code start*************
> > use strict;
> > use warnings;
> > use DBI;
> >
> > my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):');
> > my ($table, $format, $file, $flags) = (
> > 'test', 'XML', 'cars.csv', { col_names => 'make,model,year' }
> > );
> > $dbh->do("CREATE TABLE test (id TEXT,phrase TEXT)");
> > $dbh->do("INSERT INTO test VALUES (1,'foonadfjlsdj')");
> > $dbh->do("INSERT INTO test VALUES (2,'bar')");
> > $dbh->func( $table, $format, $file, 'ad_export'); #hangs here
> > ********My Code end*************
> >
> > By doing more investigation, I found where it hangs,
> >
> > In package AnyData (note not the DBD::AnyData), line 639, in sub
> > adConvert, there is a line
> > " @cols = @{ shift @{ $source_data } };"
> > When I execute step by step there, the program hangs at that line.
>
> I've run strace on this program. It appears to be opening two handles
> onto the file cars.csv, and trying to obtain a exclusive lock on each of
> those handles, leading to a self-deadlock. The very last instruction
> executed is a flock, so I don't think you've identified the correct line
> for the freezing point.
I've found the problem in AnyData/Format/XML.pm, around line 876:
#$self->{twig}->print;
#z if ( ( $storage and $file and !($file eq $storage->{file_name}) )
#z or ( $storage and $file and !$storage->{fh} )
if ( ( $storage and $file )
) {
$storage->{file_name} = $file;
close $storage->{fh} if $storage->{fh}; ### Just added by Me
$storage->{fh} = $storage->open_local_file($file,'o');
}
$storage->{fh} already holds a locked filehandle, so trying to obtain
a new filehandle and lock it (which open_local_file does) deadlocks.
I initially tried just to undef $storage->{fh}, but that didn't work.
Apparently, this handle is held somewhere besides just in $storage, so
I had to go with close rather than undef.
I must say that this adventure didn't make me terribly eager to use AnyData
in my own programs.
Xho
--
--------------------
http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB