Re: Operations on statement handles when database handle is disconnected

Michael Peppler <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
On May 15, 2011, at 2:08 PM, Jonathan Leffler wrote:

> Tested using Perl 5.13.4 and DBI 1.616 now - but I originally spotted the
> problem in 2003 when the versions were a lot older...
> 
> Consider:
> 
> # Test that statement handles from disconnected connections fail!
> 
> use strict;
> use warnings;
> use DBI;
> 
> my $table = "dbd_tester";
> my $dbh = DBI->connect('dbi:NullP:immaterial', '', '', {RaiseError=>1});
> #connect_to_test_database({RaiseError => 1});
> my $sth = $dbh->prepare(qq{INSERT INTO $table VALUES(?)});
> $dbh->disconnect;
> $sth->execute(1);
> print "** Failed to FAIL!\n";
> 
> 
> The print statement is executed, despite the fact that errors are supposed
> to be raised.
> I get the same result using DBD::Informix instead of NullP.
> 

DBD::Sybase does not print the "failed to FAIL" string:

[mpeppler@gw mpeppler]$ perl /tmp/t.pl 
DBI::db=HASH(0x880eb40)->disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at /tmp/t.pl line 9.
DBD::Sybase::st execute failed: ct_param() failed! at /tmp/t.pl line 10.
DBD::Sybase::st execute failed: ct_param() failed! at /tmp/t.pl line 10.


However, it can't really be said to fail gracefully :-)

Michael
--
Michael Peppler
Sybase on Linux FAQ: http://www.peppler.org/FAQ/linux.html

"A successful [software] tool is one that was used to do something undreamed of by its author." -- S. C. Johnson
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.