Tim Bunce <[EMAIL PROTECTED]> writes:

> On Sat, Apr 17, 2004 at 06:34:15PM +0530, Jason E. Stewart wrote:
> > Hey All,
> > 
> > Using DBI 1.41 and DBD::Pg 1.32 with mod_perl 1.29.0.2 and I get a
> > strange situation.
> > 
> > When I'm using a DB handle that ends in an error condtion, the next
> > time my mod_perl script calls connect_cached() if I check $DBI::err it
> > is still set to the last error that happend - not any error that
> > happened during the connect_cached() call - this leads to my connect
> > script thinking it got an error during the connect call, which isn't
> > true. 
> > 
> > Do I need to be manually cleaning up DBI somehow? Or is this a bug?
> 
> Umm, on second thoughts, please post a (small self-contained) script
> that demonstrates the problem. Thanks.

Thanks Tim,

Here's the script:

  #!/usr/bin/perl
  
  use DBI;
  use strict;

  my $username = 'test';
  my $password = 'test';
  my $dsn = 'dbi:Pg:dbname=genex2';
  
  my $dbh = DBI->connect_cached($dsn,$username,$password)
    or die("Couldn't connect to DSN: $dsn");
  
  my $ref = $dbh->selectall_arrayref('SELECT * FROM nonesuch');
  print STDERR "After first select DBI::err = [$DBI::err], DBI::errstr = 
[$DBI::errstr]\n";
  
  # now connect again
  $dbh = DBI->connect_cached($dsn,$username,$password);
  
  print STDERR "After reconnect DBI::err = [$DBI::err], DBI::errstr = 
[$DBI::errstr]\n";

produces the following:

  DBD::Pg::db selectall_arrayref failed: ERROR:  relation "nonesuch" does not exist at 
/tmp/connect.pl line 13.
  After first select DBI::err = [7], DBI::errstr = [ERROR:  relation "nonesuch" does 
not exist], 
  After reconnect DBI::err = [7], DBI::errstr = [ERROR:  relation "nonesuch" does not 
exist], 

Cheers,
jas.

Reply via email to