Consider the code:

#!/bin/perl -w
#
# Does DBI mishandle disconnected handles?

use strict;
use DBI;

my $dbh = DBI->connect('dbi:Informix:stores', '', '', {RaiseError=>1});

my $st1 = $dbh->prepare(qq{SELECT * FROM SysTables});

$dbh->disconnect;

# Shouldn't DBI error here?
$st1->execute();

# Shouldn't DBI error here?
my $st2 = $dbh->prepare(qq{SELECT * FROM SysTables});

print "Oops - I don't think you should have seen this!\n";
exit 1;


I've tried various incarnations of the test.  Using DBD::Sponge,
insufficient information is passed in.  Using DBD::NullP, the command exits
with the "I don't think you should have seen this" message.  I'm not sure
that either is conclusive of anything, though NullP should, I think, have
raised an error because the database handle was disconnected.

Using DBD::Informix as above, I get the "I don't think you should have seen
this" message, but I think that the attempt to use $st1 should have been
headed off long before it got to calling DBD::Informix code because the
relevant database handle was disconnected, so there should be nothing that
can be done with it (either the $dbh or $st1).  I was using DBI 1.53-1.56 on
various machines with Perl 5.8.8 - various variants.

I would expect that any use of a statement handle such as $st1 should fail
after the parent $dbh has been disconnected.

Is the reason it doesn't something to do with caching - of connections or
statements?

How can you turn off caching when unwanted?  Shouldn't 'cache off' be the
default - if you want cached stuff, you have to ask for it?

--
Jonathan Leffler <[EMAIL PROTECTED]>  #include <disclaimer.h>
Guardian of DBD::Informix - v2007.0226 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."

Reply via email to