Hi,
The problem: database locks are left behind after the statement
handles of simple select statements are closed, e.g. $sth->finish;
and undef $sth; when I fetch BLOB fields from DB2 using AutoCommit=0.
Some hobby-analysis follows: I did some tracing in DBI and it after
the last call to fetch() it seems like the outer handle is never
destroyed (?)
<- fetch= ( undef ) [1 items] row1 at dbitest.pl line 20
>> DESTROY DISPATCH (DBI::st=HASH(0xb2a828) rc1/1 @1 g2 ima10004
pid#23683) at dbitest.pl line 15 via at dbitest.pl line 15
<> DESTROY(DBI::st=HASH(0xb2a828)) ignored for outer handle (inner
DBI::st=HASH(0x9a2008) has ref cnt 1)
>> DESTROY DISPATCH (DBI::st=HASH(0x9a2008) rc1/1 @1 g2 ima10004
pid#23683) at dbitest.pl line 15 via at dbitest.pl line 15
-> DESTROY for DBD::DB2::st (DBI::st=HASH(0x9a2008)~INNER) thr#77f010
.. since there exists an inner handle (guess). But then it will
never destroy the global handle later (guess)? I am looking at
the following code comment:
/* XXX might be better to move this down to after call_depth has been
* incremented and then also SvREFCNT_dec(mg->mg_obj) to force an immediate
* DESTROY of the inner handle if there are no other refs to it.
* That way the inner DESTROY is properly flagged as a nested call,
* and the outer DESTROY gets profiled more accurately, and callbacks work.
*/
if (trace_level >= 3) {
PerlIO_printf(DBILOGFP,
"%c <> DESTROY(%s) ignored for outer handle (inner %s has ref cnt
%ld)\n",
(PL_dirty?'!':' '), neatsvpv(h,0), neatsvpv(mg->mg_obj,0),
(long)SvREFCNT(SvRV(mg->mg_obj))
);
}
Then again, I have no idea if my quick analysis of the problem is
correct (I am not a perl developer, nor DBI/DBD developer), pardon
my ignorance. But it seems like that thing should be destroyed
later?
/K