On Wed, Oct 04, 2006 at 11:53:48AM -0700, Henri Asseily wrote:
> I have an issue with proper usage of swap_inner_handle:
> 
> Say I have a dbh with an active sth.
> I create a new dbh (new_dbh) and swap its inner handle with dbh.
> 
> Now is sth a child of dbh or new_dbh? i.e., is sth linked to the  
> inner dbh, or not at all?

It remains linked with the original inner dbh which has been swapped
into new_dbh.

> Then I create a new sth (new_sth) and swap its inner handle with sth.

Is the new sth created from dbh or new_dbh?

> What happens?

The sth will be a child of the (inner) dbh you used to create it.

[It's clear that the lack of a terminology/nomenclature makes it harder
to think about and discuss what's happening.]

Since you ask the question I assume you may have a problem.
Looking at the code I can see one potential issue...

Handles include a reference to their parent's _outer_ handle.
The code doesn't do anything about that but should in two cases:
1. If the parents of the handles being swapped differ, and the
   allow_reparent parameter is true.
2. Any existing child handles of the two handles being swapped
   should have their parent handle references updated.

I'll assume the second one is the cause of the problem I'm assuming you have.
As far as I can tell from a quick look, that would affect:
 - How the Statement attribute gets copied from sth to parent dbh.
 - How the 'last used handle' is updated by DESTROY

Are my assumptions correct?

Tim.

Reply via email to