Stephen, can you give some insight into how normal usage of this DBI 
subclass might lead to infinite loops via DBI callbacks? I find it 
surprising that subclasses have to setup this sort of defense for 
themselves against their parents calling them.


sub prepare {
     my($self,$statement,$attr) = @_;
     my $caller = (caller(1))[3] || '';
     my $caller2 = (caller(2))[3] || '';
     return $self->SUPER::prepare($statement,$attr)
         if $caller eq 'DBD::_::db::prepare_cached' # avoid infinite loop 
on cal\
lback from DBI
             or $caller2 eq 'DBD::Oracle::db::ping'  # don't cache db 
ping state\
ment -- otherwise it always
                 # returns true even if the connection died
                 or $statement !~ /^SELECT\b/i; # only cache SELECT 
statements
     my $st = $self->SUPER::prepare_cached($statement,$attr,1);
     return undef unless $st;
     $st->{private_last_use} = time();
     $st->{private_prepare_count}++;
     return $st;
}

Reply via email to