On Mon, Feb 16, 2004 at 03:46:28PM -0600, Jay Hannah wrote:
> I would *love* to set another flag/whatever so DBI would bark at us
> whenever $dbh's were garbage collected. Then we'd explicitly know to
> slap ourselves for writing sloppy code... With the warning gone I fear
> we won't know we're being slobs, especially under mod_perl...?

Can I ask exactly what you are worried about?  The only concern I can
think of is that you will keep connections alive longer than necessary.
For example, in

    {
        my $dbh = DBI->connect(...);
        # do stuff with $dbh
        really_expensive_function();
    }

your $dbh won't be disconnected until after the
really_expensive_function, and the warning will give you a clue about
it.

This really doesn't seem like a common case to me.  Normally, the time
when you would call disconnect is exactly the time when all the
references are about to go away.  In this case, the disconnect
in the destructor works perfectly and saves keeping track of the $dbh
lifetime yourself.  Or am I missing some common usage pattern?

So while I agree the warning could be helpful, I am skeptical that it
does enough good to warrant keeping it.  I guess it cold be an option,
though.

Incidentally, you already don't get the warning during global
destruction, so it isn't that reliable.

Andrew

Reply via email to