On Mon, Sep 18, 2006 at 09:22:28AM +0100, Martin J. Evans wrote:
> Tim,
>
> I see you've "tweaked" the pod changes I made for the new execute_array
> in array context so it now says -1 is returned as the rows affected if
> the driver can't return the rows affected.
>
> I think the change to DBI's execute_for_fetch for drivers not
> implementing execute_for_fetch contains something like:
>
> if ( my $rc = $sth->execute(@$tuple) ) {
> push @$tuple_status, $rc;
> $rc_total += $rc;
> }
>
> and later:
>
> return ($tuples, $rc_total);
>
> so in fact, the returned value for drivers which don't implement
> execute_for_fetch and also cannot return the rows affected on a per row
> basis would normally be -1 * tuples_executed which is not always -1.
Funnily enough that thought flittered across my mind at least twice
in the last few weeks but I never nailed it down. So thanks for catching it.
> Does this require a pod change (to say it returns -1 * tuples_executed
> or perhaps just a negative number) or a execute_for_fetch in DBI change
> (so it returns -1 if ANY of the $rc's is -1)? I'm guessing the latter
> because it seems more logical and it is possible if a driver can return
> the per rows affected for some executes and not others you might get
> negative and positive values adding up to any number and leading to
> confusion.
I agree that returning -1 if any are -1 is the most logical.
Anyone needing the fine detail can get it via ArrayTupleStatus.
Perhaps the logic would look like this:
$rc_total = ($rc >= 0 && $rc_total >= 0) ? $rc_total + $rc : -1;
> I'm happy to make whichever change after guidance.
Great. Thanks Martin.
Tim.