On Tue, Sep 05, 2006 at 02:10:24PM +0100, Martin J. Evans wrote:
> > 
> > The DBIs default behaviour is the official behaviour.
> 
> That is fair enough. I wasn't really suggesting it was changed, it was more of
> a pointing out the inconvenience in case it led to a better way for me to get
> the rows affected...
>  
> > I take your point about the return value. I remember weighing up both
> > alternatives before settling on 'tuples executed' - but I can't now
> > remember why! I probably also didn't consider bulk updates as a likely
> > use case.
> > 
> > How about adding total rows affected as an extra return value in list
> > context?:
> > 
> >   ($tuples_executed, $rows_affected) = $sth->execute_array(...)
> 
> and it did. Yes, this would be ideal and second guessing you I even looked at
> the code to implement it but was slightly flumaxed by the possible definition
> changes to "Dynamically create the DBI Standard Interface"

I'm not sure what you mean.

> and the
> problem that it can only be calculated if ArrayTupleStatus is specified and
> that is optional now. Any pointers on these welcome and I'll attempt a patch.

Here's a draft patch... (since it was trivial to do while I was
thinking about it):

@@ -1921,10 +1921,12 @@
        # start with empty status array
        ($tuple_status) ? @$tuple_status = () : $tuple_status = [];
 
+       my $rc_total = 0;
        my ($err_count, %errstr_cache);
        while ( my $tuple = &$fetch_tuple_sub() ) {
            if ( my $rc = $sth->execute(@$tuple) ) {
                push @$tuple_status, $rc;
+               $rc_total += $rc;
            }
            else {
                $err_count++;
@@ -1935,7 +1937,9 @@
         my $tuples = @$tuple_status;
         return $sth->set_err(1, "executing $tuples generated $err_count 
errors")
             if $err_count;
-       return scalar(@$tuple_status) || "0E0";
+       $tuples ||= "0E0";
+       return $tuples unless wantarray;
+       return ($tuples, $rc_total);
     }
 
Could you check it, add any polish needed, plus some docs (noting
Ronald's clarification) and, ideally, some tests?

If you don't have commit access to the repository yet then send me your
auth.perl.org (or bitcard.org) username and I'll give you access so you
can commit it yourself.

Thanks Martin!

Tim. 

Reply via email to