Fellow DBIers,

I've been having a need in my tests to be able to disconnect all current connections to a database—before I drop the database, for example. Now my code uses connect_cached(), so this used to be quite a PITA, because the DBI was keeping connections open!

But then I stumbled on the new installed_drivers() method and figured out how to do it:

    my %drhs = DBI->installed_drivers;
    $_->disconnect for grep { defined }
        values %{ $drhs{Pg}->{CachedKids} };

This works great! But I hadn't realized that installed_drivers() was added to the DBI only recently, so my fellow hackers suddenly started to get strange failures. Once we figured out the problem, everyone upgraded, but I'm left with this question:

Was there any way to get hold of all cached database handles from the DBI before the introduction of installed_drivers() in 1.49?

Oh, and on a side note: How come installed_drivers() isn't mentioned in DBI::Changes?

Thanks!

David

Reply via email to