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

Dmitri Tikhonov dtikhonov at vonage.com
Wed Feb 21 16:41:54 EST 2007


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?

   - 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