[Rt-devel] DBIx::SB::Handle -- $PrevHandle question.

Jesse Vincent jesse at bestpractical.com
Wed Feb 21 16:54:50 EST 2007




On Wed, Feb 21, 2007 at 04:41:54PM -0500, Dmitri Tikhonov wrote:
> Here's my situation:
> 
>   1. Get handle ABC ($PrevHandle now points to ABC);
>   2. Get handle DEF ($PrevHandle now points to DEF);
>   3. ABC gets disconnected (ping times out or what-not -- haven't
>      researched exactly how it gets undefed yet).
>   4. Then this code: $ABC->dbh will return DEF handle because of
>      this:
> 
>       return($DBIHandle{$self} ||= $PrevHandle);
> 
> This behavior of SB::Handle is undocumented, surprising and I think it 
> is actually a bug.
> 
> Is that $PrevHandle still relied on in RT or is it a relic?

It's not something that can be removed, no. Patches to address the issue
you're running into would be welcome, though

> 
>   - Dmitri.
> 
> Jesse Vincent wrote:
> >
> >
> >On Wed, Feb 21, 2007 at 04:28:35PM -0500, Dmitri Tikhonov wrote:
> >>Dear RTers and DBIx::SBers,
> >>
> >>what is the purpose of $PrevHandle "magic" in
> >>DBIx::SearchBuilder::Handle?  Specifically, this code:
> >>
> >>  sub dbh {
> >>    my $self=shift;
> >>
> >>    #If we are setting the database handle, set it.
> >>    $DBIHandle{$self} = $PrevHandle = shift if (@_);
> >>
> >>    return($DBIHandle{$self} ||= $PrevHandle);
> >>  }
> >>
> >>puzzles me.  The conversion from $DBIHandle to %DBIHandle is based on
> >>patch from Audrey Tang [1] which was included along with $PrevHandle
> >>into the 0.61 -> 0.96 changeset [2].  However, I can't find the
> >>explanation for $PrevHandle in the Changes file or anywhere in the
> >>comments.  Could someone please tell me why it's there?
> >
> >I believe that this made SB able to handle a temporary dbh change if you
> >needed to open a new handle, work and then go back to what you were
> >doing.
> >
> >>Thank you,
> >>
> >>  - Dmitri.
> >>
> >>
> >>1. http://rt.cpan.org/Public/Bug/Display.html?id=4167
> >>2. 
> >>http://search.cpan.org/diff?from=DBIx-SearchBuilder-0.61&to=DBIx-SearchBuilder-0.96
> >>_______________________________________________
> >>List info: 
> >>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
> >>
> >
> 

-- 


More information about the Rt-devel mailing list