On Fri, May 23, 2014 at 08:37:31AM +0100, Nicholas Clark wrote: > On Thu, May 22, 2014 at 10:49:39AM +0100, Tim Bunce wrote: > > > > The handle data structure includes the PerlInterpreter* of the thread > > that created it https://github.com/perl5-dbi/dbi/blob/master/DBIXS.h#L95 > > > > and the DBI's method dispatcher ensures that DBI methods are only called > > in the same thread that created them, i.e. > > > > https://github.com/perl5-dbi/dbi/blob/master/DBI.xs#L3300 > > > > So, for methods that are passed a handle and already declare and set a > > local imp_xxh pointer (e.g., D_imp_sth(sth);) I wonder if it would be > > worth defining a macros to get the thread pointer from the handle. > > Something like dTHX_from_imp_xxh(imp_xxh); > > I don't think that this will work > > #define D_imp_sth(h) D_impdata(imp_sth, imp_sth_t, h) > #define D_impdata(name,type,h) type *name = (type*)(DBIh_COM(h) > > #ifdef IN_DBI_XS /* get Handle Common Data Structure */ > #define DBIh_COM(h) (dbih_getcom2(aTHX_ h, 0)) > #else > #define DBIh_COM(h) (DBIS->getcom(h)) > #define neatsvpv(sv,len) (DBIS->neat_svpv(sv,len)) > #endif > > You need a copy of my_perl (that aTHX_) to get the to data structure that > contains my_perl (if I follow the macros correctly)
Yes, the key part is that within a driver (DBIS->getcom(h)) is used but DBIS is defined as (*dbi_get_state(aTHX)). Ho hum. Thanks. Tim.
