Re: subclassing the DBI and the clone method

"Martin J. Evans" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
Martin J. Evans wrote:
> Erik Aronesty wrote:
>> Does clone just return the current handle?
> 
> Does not seem so.
> 
>> Many handles are multi-process safe and can be reused in that way.
>> Possibly that's the default.
> 
> Not in DBD::Oracle and Oracle Client library unfortunately.
> 
> I think I've nearly sussed it now. I've implemented clone in
> DBIx::Log4perl by simply copying the private_DBIx__Log4perl hash ref
> from the old connection handle to the new one returned by clone and only
> have a few issues (internal to DBIx::Log4perl) with closures used in
> other packages.
> 
> Still interested in other input from anyone else who has done this
> (knows about this).
> 
> Martin

It appears I was wrong - I have not sussed this at all.
The private_DBIx_Log4perl key inserted into the original dbh appears to
have some magic that means when it is copied to a new dbh returned from
clone and then changed it is affecting the original dbh.

Has anyone handled clone properly in a DBIx module? What did you do?

Martin
-- 
Martin J. Evans
Easysoft Limited
http://www.easysoft.com


>> On Tue, Jan 19, 2010 at 4:31 PM, Martin J. Evans
>> <[email protected]> wrote:
>>> Erik Aronesty wrote:
>>>> On Tue, Jan 19, 2010 at 4:04 PM, Martin J. Evans
>>>> <[email protected]> wrote:
>>>>> Hi,
>>>>>
>>>>> Is there anything special a subclassed DBI module (DBIx::Log4perl in
>>>>> this case) needs to do for the clone method?
>>>>>
>>>>> The DBI docs currently say "The clone method duplicates the $dbh
>>>>> connection by connecting with the same parameters ($dsn, $user,
>>>>> $password) as originally used." but I don't see any call to connect when
>>>>> clone is called.
>>>> Presumably the "clone" method gives the driver an opportunity to
>>>> duplicate an already-connected connection in a more efficient way than
>>>> simply reconnecting from "scratch".
>>>>
>>>>
>>> It would appear so. I've added a "mock" clone method to DBIx::Log4perl
>>> and obviously it is called but I never see a second call to connect so
>>> either I am misunderstanding things here and/or the docs are a
>>> simplification.
>>>
>>> Martin
>>>
>>
> 
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.