Has anyone updated a (pure Perl) driver to be thread safe ? I'm in the midst of
trying to get DBD::Teradata safe, it seems simple enough
(just add DBD::Teradata::CLONE()), but
I'm not certain what the ramifications are. 
If (as the POD indicates) handles cannot be shared between threads,
then I don't need to be concerned about driver global values ?
E.g., DBD::Teradata maintains an internal hash of all the
connections currently open (so it can disconnect_all)...will this
hash get destroyed for each new thread, or does CLONE need to
do more housekeeping ? 

I.e., is:

package DBD::Teradata;

use vars qw($VERSION $err $errstr $state $drh %connections);

$VERSION = '2.2.5';
$drh = undef;
%connections = ();
$err = 0;
$errstr = '';
$state = '00000';


safe, or does %connections need to be moved to the 
DBD::Teradata::drh package ?

And there's also an init() method that
establishes various low-level operating parameters the first time
a connection is created...will the init get re-invoked for each
thread as a result of DBI reloading the driver ? If not, will the global
variables it assigns be regenerated in the new thread ? Ie,

package DBD::Teradata::impl;

my $inited = 0;
my $platform = 0;
#
#    called the first time we connect
#
sub init {
    return 1 if $inited;    # already inited
...
    $platform = detect_our_platform();
....
    $inited = 1;
    return 1;
}

And if I subsclass DBI (eg, DBIx::Chart), do I need to perform any
add'l magic ?

And (slightly OT), are Perl threads SMP capable (ie, multiple threads of hte same 
process
can actually run concurrently) ? (Probably inherits whatever the platform thread 
library
provides ? I know eg, Solaris has 2 threading libs, one for true SMP support).

TIA,
Dean Arnold
Presicient Corp.
www.presicient.com

Reply via email to