Re: [svn:dbi] r13920 - dbi/trunk/lib/DBD

Jens Rehsack <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
On 04/27/10 21:13, Tim Bunce wrote:
> On Fri, Apr 23, 2010 at 05:57:29AM -0700, [email protected] wrote:
>> +use Config;
>> +
>> +our $threadid = 0;       # holds private thread id of driver
>>
>> +    $this->STORE (p_threadid =>  $threadid);
>>
>> +sub CLONE
>> +{
>> +    $Config{usethreads}&&  $INC{"threads.pm"} and
>> +	$threadid = threads->tid ();
>> +    } # CLONE
>> +
>>
>> +    my $ownerid = $dbh->FETCH ("p_threadid");
>> +    $ownerid == $DBD::File::dr::threadid or
>> +	croak "database handle is owned by thread $ownerid and this is $DBD::File::dr::threadid"
>
> The DBI method dispatch code already checks thread ownership of handles
> (see DBIc_THR_USER in DBI.xs) so is this really needed?

You're right. I didn't check this before and I didn't check whether this 
feature is in DBI::PurePerl (grepping for 'thread' in lib/DBI/PurePerl.pm 
didn't find anything, but I didn't review the code). I also miss a test 
which proves that it works.

For this release, the patch which takes the p_thread stuff out of DBD::File 
is attached. After it, some action seems required ...

Jens
DBD-File-p_thread-out.patch (text/plain, 1.3 KB)
Index: lib/DBD/File.pm
===================================================================
--- lib/DBD/File.pm	(revision 13932)
+++ lib/DBD/File.pm	(working copy)
@@ -123,10 +123,7 @@
 package DBD::File::dr;
 
 use strict;
-use Config;
 
-our $threadid = 0;       # holds private thread id of driver
-
 $DBD::File::dr::imp_data_size = 0;
 
 sub connect ($$;$$$)
@@ -175,7 +172,6 @@
 	    };
 	}
     $this->STORE (Active     => 1);
-    $this->STORE (p_threadid => $threadid);
     return set_versions ($this);
     } # connect
 
@@ -231,12 +227,6 @@
 {
     } # disconnect_all
 
-sub CLONE
-{
-    $Config{usethreads} && $INC{"threads.pm"} and
-	$threadid = threads->tid ();
-    } # CLONE
-
 sub DESTROY
 {
     undef;
@@ -260,10 +250,6 @@
 {
     my ($dbh, $statement, @attribs) = @_;
 
-    my $ownerid = $dbh->FETCH ("p_threadid");
-    $ownerid == $DBD::File::dr::threadid or
-	croak "database handle is owned by thread $ownerid and this is $DBD::File::dr::threadid";
-
     # create a 'blank' sth
     my $sth = DBI::_new_sth ($dbh, {Statement => $statement});
 
@@ -298,7 +284,6 @@
 	    $sth->STORE ("f_stmt", $stmt);
 	    $sth->STORE ("f_params", []);
 	    $sth->STORE ("NUM_OF_PARAMS", scalar ($stmt->params ()));
-	    $sth->STORE ("p_threadid", $DBD::File::dr::threadid);
 	    }
 	}
     return $sth;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.