Tim Bunce wrote:
On Wed, Jul 27, 2005 at 10:21:10AM -0700, Dean Arnold wrote:

Will it work for
pure-Perl DBDs (seems like there'd be lots of driver-specific
context copying required...) ?


It can be made to work for pure-Perl DBDs.

Let's start with the docs for take_imp_data() (added in DBI 1.36):

---snip---

<snip/>


The key point is that $imp_data is a plain simple string.
It just happens to contain (typically) a chunk of binary data.
The only useful thing you can do with that data is pass it to
a connect call for the same driver:

  DBI->connect(..., { dbi_imp_data => $imp_data })

Already read that, which is what kinda got me concerned
in the 1st place. In TQD terms, you're "curse()"ing the underlying
connection object into a frozen scalar, then
thawing and "redeem()"ing the scalar back to the underlying
connection object in the borrowing thread.
But there could be a *lot* of context stuff, and the
take_imp_data() comments from DBI.xs don't give me a warm
fuzzy feeling either.

I spose for XS-based DBD's, assuming they've been carefully
crafted to not stray from those rules, its not a big deal (few or no
SV/AV/etc's to manage to recover context).

I think Stas mentioned he'd only tested with DBD::mysql; have
any other DBD's been tested with this ?


Pure perl drivers are free to return any chunk of data, as a string, so
long as it can be used to recover the connection information. So for a
pure perl driver using a socket, $imp_data could be the integer file
descriptor of the socket. Note that it can't (shouldn't) be a reference
to a filehandle object since references can't easily be passed between
threads.


That definitely bothers me (having written a number of PP drivers).
Not impossible, but certainly an added burden for DBD authors, and
certainly an opportunity for things to go awry in very strange ways.
And statement handles could be even worse...

And only serves to convince me that apt. threading, tho a bit on the beefy side,
is a better solution for my needs.

Thanks for the clarification; I may not like the answer, but at least
I'm less inclined to be shaking my head and mumbling to myself trying
to figure out how it works (I had concluded you were employing some
extra magic under Perl's covers that I might exploit).

- Dean

Reply via email to