On Tue, Jul 27, 2004 at 02:13:03AM +0200, Jochen Wiedmann wrote:
> Henri Asseily wrote:
> 
> >I'm trying to do the following, and was wondering where I should look 
> >to get a good handle on what's going on:
> >
> >I have an $sth that's pointing to a dead server.
> >I have a new $sth2 that's pointing to a good server.
> >
> >upon the user doing $sth->execute, I want to be able to get $sth 
> >pointing to $sth2, effectively making $sth valid again.
> >
> >I understand that $sth is a tied hash. Can it be cleanly untied and 
> >retied to what $sth2 is tied to? Would that do what I'm looking to do?
> >I have no problem coding up some C, as long as I can be pointed at the 
> >relevant code in dbi.

I've long had a plan to provide such methods. You'll see it mentioned in
http://search.cpan.org/src/TIMB/DBI-1.43/ToDo
as $h->swap_internal_handle($other_h) or $sth->become($sth2)

It's probably fairly trivial if you're familiar with perl internals
enough to know to use mg_find(SvRV(h),'P') and why you'd need to.
You'll also need DBIc_MY_H(imp_xxh).

I'd happily accept a patch (that includes tests).

> I think your problem can be solved much simpler:
> 
> - Write a pure Perl DBD driver, roughly comparable to DBD::Proxy.
> - Your Perl DBD drivers classes (dbh, sth) would use references to the 
> actual handles internally.
> - Whenever required, update the internal handles.
> 
> It's quite possible, that a similar solution already exists, for example 
> DBD::Multiplex or however it is called.

DBD::Multiplex ought to be a good place to do this, but it's mid-rewrite
so I can't recommend working on the available source.

Tim.

Reply via email to