my ($self) = @_;
my $dbc = $self->dbc;
$self->dbc(undef);
my $sql = $self->sql;
$self->sql(undef);
# Re-bless into DBI::st so that superclass destroy method is called if
# it exists (it does not exist in all DBI versions).
bless( $self, 'DBI::st' );
# The count for the number of kids is decremented only after this
# function is complete. Disconnect if there is 1 kid (this one)
# remaining.
if ( $dbc
&& $dbc->disconnect_when_inactive()
&& $dbc->connected
&& ( $dbc->db_handle->{Kids} == 1 ) ) {
if ( $dbc->disconnect_if_idle() ) {
warn("Problem disconnect $self around sql = $sql\n");
}
}
}