DBD::Sybase and fork() in Perl 5.8.7
- From: ebrosch@xxxxxxxxx
- Date: 28 Mar 2006 12:48:44 -0800
I am trying to connect to one Sybase database in a parent process and
other Sybase database in a child process. I was able to do this under
Perl 5.6 but the same code no longer works under Perl 5.8.7. Here is a
sample program which replicates the problem:
===============================================================
#!/opt/perl/bin/perl -w
use DBI;
use DBD::Sybase;
$|=1;
unless ($dbh =
DBI->connect("dbi:Sybase:server=$ENV{DBSVR};database=$ENV{DBNAME};loginTimeout=10",
$ENV{DBLOG}, "XXXXX"))
{
print STDERR ("Failure connecting\n");
exit(1);
}
$sth = $dbh->prepare('select @@spid');
$sth->execute;
@row = $sth->fetchrow_array();
$sth->finish;
$sth = undef;
$dbh->disconnect || warn $dbh->errstr;
$dbh = undef;
printf ("PID %d SPID %d\n", $$, $row[0]);
$pid = fork();
if ($pid == 0)
{
unless ($dbh2 =
DBI->connect("dbi:Sybase:server=$ENV{DBSVR2};database=$ENV{DBNAME2};loginTimeout=10",
$ENV{DBLOG2}, "XXXXX"))
{
print STDERR ("Failure connecting\n");
exit(1);
}
$sth2 = $dbh2->prepare('select @@spid');
$sth2->execute;
@row2 = $sth2->fetchrow_array();
$sth2->finish;
$sth2 = undef;
$dbh2->disconnect || warn $dbh2->errstr;
printf ("Child PID %d SPID %d\n", $$, $row2[0]);
}
else
{
waitpid($pid, 0);
}
Running this code generates the following output:
PID 6454 SPID 315
OpenClient message: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER =
(151)
Message String: ct_cancel(): user api layer: external error: A
connection to the server must exist on the connection structure before
this routine can be called.
DBI
connect('server=MYSERVER;database=bubba1;loginTimeout=10','main1',...)
failed: OpenClient message: LAYER = (1) ORIGIN = (2) SEVERITY = (2)
NUMBER = (63)
Server MYSERVER, database
Message String: ct_connect(): user api layer: internal Client Library
error: Read from the server has timed out.
at ./test3.pl line 29
Failure connecting
===============================================================
Could someone help me figure out why the child process cannot connect?
Thanks for any and all help,
Eric
.
- Follow-Ups:
- Re: DBD::Sybase and fork() in Perl 5.8.7
- From: ebrosch
- Re: DBD::Sybase and fork() in Perl 5.8.7
- From: ebrosch
- Re: DBD::Sybase and fork() in Perl 5.8.7
- Prev by Date: Re: Transactions: DBI vs. SQL
- Next by Date: Re: DBD::Sybase and fork() in Perl 5.8.7
- Previous by thread: trouble with fresh ActiveState PPM install of DBD::Oracle
- Next by thread: Re: DBD::Sybase and fork() in Perl 5.8.7
- Index(es):
Relevant Pages
|