On Thu, Jul 04, 2002 at 02:40:03PM +0200, Gerald Richter - ecos gmbh wrote: > > > > > The ability to share handles, is one of the reason to use > > > threads, isn't it? > > > > It would certainly be nice - but very hard to get right and safe. > > > > Tim, just a question, do you know if the C-Library of Orcale is threadsafe,
Yes, if initialised with the OCI_THREADED option (as per an earlier email). > so that when DBI would be able to share handles (in the long term), this is > usefull when using Orcale. I guess it is so, just would like to get a > confirmation, before I put any thoughs or work into makeing DBI able to > share handles. The basic goal is to have just one database connection, which > is shared by all threads. (At least to be able to do so) A reasonable way to do that for DBD::Oracle (which may apply in principle to others) is to not try to share a DBI handle but rather have a way to get/set the underlying C pointer values. One thread would connect as normal then do $shared_scalar = $dbh->{ora_oci_pointer_thingy}; and another thread could do $dbh = DBI->connect(..., ora_oci_pointer_thingy => $shared_scalar); in which case the DBD::Oracle connect wouldn't actually call OCI functions to make a connection, it would just plug in the pointer value[*] it's been passed. This concept is very similar to calling dup() on a filehandle. Tim. [*] ora_oci_pointer_thingy would probably need to be a string containing several integer pointer values separated by some character like a colon.