On Wed, Jun 22, 2005 at 01:38:05PM -0400, Sam Tregar wrote:
> Here's my first pass at an ActiveHandles attribute.
Thanks Sam.
> With this patch this code prints all live handles:
>
> foreach my $handle (@{$dbh->{ActiveHandles}}) {
> next unless defined $handle;
> print $handle, "\n";
> }
>
> I'd like to take the next step and add a DBI->ActiveHandles call to do
> it without a $dbh. Alternately we could just document the global
> ($DBI::active_handles) which offers the same functionality.
Let's get this patch over a few hurdles first... :)
> Question: is "active" the right word here? Looking at the other
> "active" attributes I think maybe not. Perhaps "LiveHandles"?
I'd rather go with ChildHandles as per the outline in my previous email.
Your patch uses a global $DBI::active_handles which will grow
without bound. The $dbh->{ActiveHandles} will return _all_ handles,
not only those that are the child of the $dbh.
Using weaken($parent->{ChildHandles}{$h} = $h) avoids the need
for a global, $dbh->{ChildHandles} will only return children of that
$dbh, and $drh->{ChildHandles} can be used to find all the connections
for a particular driver handle.
There should be no need for any DBI.xs code to support ChildHandles
as it lives in the attribute cache as a simple hash ref. It should
also 'just work' for DBI::PurePerl.
I'd be grateful if you could rework the patch along those lines.
Tim.