On Thu, Dec 02, 2004 at 04:07:13PM -0800, Jonathan Leffler wrote: > Dear Tim, > > I was just getting ready to ship DBD::Informix 2004.02 when I made the > mistake of testing it with Perl 5.6.1 and DBI 1.46. > I ran into problems with a DBD::Informix test that was expecting an error > code to be set in a $SIG{__WARN__} handler.
> my $msg; > $SIG{__WARN__} = sub { $msg = $_[0]; }; > $dbh = DBI->connect("dbi:Informix:$dbname", $user, $pass, { AutoCommit => 0, > PrintError => 1 }); > print "not ok 8\n" unless($msg && $msg =~ /-256:/); > > The comparison in the last-but-one line is failing - instead of the -256 > message number plus colon, the code is seeing '(no error string)', even > though when I subsequently print $DBI::errstr, the correct message is > visible. Odd. I thought that bug was fixed in DBI 1.43. See top line of: http://search.cpan.org/~timb/DBI/Changes#Changes_in_DBI_1.43_(svn_rev_377),_2nd_July_2004 It's related to the timing of when perl calls DESTROY (which changes sometimes between releases) and the way that dbh errors values then get copied up the the drh. Here's the relevant part of the DBI->connect method: unless ($dbh = $drh->$connect_meth($dsn, $user, $pass, $attr)) { $user = '' if !defined $user; $dsn = '' if !defined $dsn; # $drh->errstr isn't safe here because $dbh->DESTROY may not have # been called yet and so the dbh errstr would not have been copied # up to the drh errstr. Certainly true for connect_cached! my $errstr = $DBI::errstr; $errstr = '(no error string)' if !defined $errstr; my $msg = "$class connect('$dsn','$user',...) failed: $errstr"; DBI->trace_msg(" $msg\n"); # XXX HandleWarn unless ($attr->{HandleError} && $attr->{HandleError}->($msg, $drh, $dbh)) { Carp::croak($msg) if $attr->{RaiseError}; Carp::carp ($msg) if $attr->{PrintError}; } $! = 0; # for the daft people who do DBI->connect(...) || die "$!"; return $dbh; # normally undef, but HandleError could change it } The code used to use $drh->errstr but, as the comment says, that's not safe. Assuming you really are using 1.46 (please triple check) then you'll need to do some digging around that code to find out what's going on. Tim.