Perl coredump when using ora_dbh_share to connect to Oracle DB's
[email protected] (Jens Rehsack)
| Newsgroups | perl.dbi.users |
|---|---|
| Message-ID | <[email protected]> |
Hi all, I get a core dump when using attached script to connect to an Oracle DB. Anyone here having a hint what's going wrong? I need this (probably) to get Log::Log4perl::Appender::DBI run fine in a multithreaded environment. Best regards and thanks in advance, Jens
orathreads.pl
(application/octet-stream, 1.2 KB)
#!/usr/pkg/bin/perl
use strict;
use warnings;
use 5.010;
use threads;
use threads::shared;
use DBI;
my $dsn = 'DBI:Oracle:host=localhost;port=1527;sid=XXX';
my $user = 'username';
my $passwd = 'passwd';
our $orashr : shared = '';
our @results : shared;
my $dbh : shared = DBI->connect( $dsn, $user, $passwd, { PrintError => 1, ora_dbh_share => \$orashr } )
or die "DBI connect error: $DBI::errstr";
sub query_db()
{
my $sth = $dbh->prepare( "SELECT * FROM log WHERE run = (SELECT MAX(run) FROM migration.log) ORDER BY id ASC" );
say "prepare succeeds for thread " . threads->tid();
if( $sth->execute() )
{
say "execute succeeds for thread " . threads->tid();
while( my $row = $sth->fetch_arrayref() )
{
push( @results, $row );
}
}
else
{
say "execute failed for thread " . threads->tid();
}
$sth->finish();
return 0;
}
threads->new( \&query_db );
threads->new( \&query_db );
threads->new( \&query_db );
while ( threads->list(threads::running) >= 1 )
{
foreach my $thr ( threads->list(threads::joinable) )
{
$thr->join()
}
threads->yield();
}
orathreads.trace
(application/octet-stream, 2.5 KB) - not displayed