On 11/7/05, Aaron Turner <[EMAIL PROTECTED]> wrote:

> On Nov 7, 2005, at 8:57 PM, Jonathan Leffler wrote:
> > On 11/6/05, Aaron Turner <[EMAIL PROTECTED]> wrote:
> >
> > When I run my code, I see the
> >> $dbh hash change inside of the child process and the parent hash stay
> >> the same. Aren't I avoiding using the same handle by doing a $dbh =
> >> undef in the child and then calling connect again?
> >
> >
> > The undef probably does the damage - the connect again would be
> > correct.
> >
> > If the 'undef' causes the child process to disconnect, then it
> > closes the
> > connection and the server is none the wiser that it was only one of
> > two
> > processes that closed the connection.
>
> Uh, that makes no sense (at least to me). Setting the parent's $dbh
> handle to undef or replacing it with another should both cause the
> client to process to disconnect under normal circumstances since it
> will go out of scope and Perl will call DESTROY on the object at that
> time. However, by setting $dbh->{InactiveDestroy} = 1 on the parent
> inside the child, should avoid implicitly calling DESTROY (and
> thereby avoid the disconnect) when the $dbh goes out of scope for any
> reason.


I'm hypothesizing. I could be wrong. I don't even recall which driver you
are using.

If you were using DBD::Informix, I'd be right - it hasn't been updated to
recognize InactiveDestroy and the child disconnect would terminate the
parent's connection - unless DBI itself manages things correctly. (Actually,
in the current version, if the child tried to access the DBMS via a handle
created in the parent, it would get a rude message - to the effect that
you're not allowed to try that. But that's independent of the
InactiveDestroy attribute, which is not recognized.)

In other words this:
>
> $dbh->{InactiveDestroy} = 1;
> $dbh = undef;
> $dbh = DBI->connect(...);
>
> should be equivalent to:
>
> $dbh->{InactiveDestroy} = 1;
> $dbh= DBI->connect(...);
>

Probably - if the driver supports the concept.

Or am I missing something?


Probably not.

I don't have anything more useful to offer on this subject at the moment.
It is unlikely I'll respond again.

--
Jonathan Leffler <[EMAIL PROTECTED]> #include <disclaimer.h>
Guardian of DBD::Informix - v2005.02 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."

Reply via email to