On Mon, Jan 26, 2004 at 01:18:19PM +0000, Tim Bunce wrote:
> Thanks, applied.
> 
> Tim.
> 
> On Mon, Jan 26, 2004 at 10:18:03AM -0000, Avis, Ed wrote:
> > This patch to DBI-1.40 fixes an error
> > 
> > Can't use an undefined value as an ARRAY reference at DBI.pm line 1735
> > 
> > when using execute_array() with zero values for a bind parameter.  It
> > includes some new test cases, but not all of the new tests failed
> > before.
> > 
> > diff -ru DBI-1.40/DBI.pm DBI-1.40-new/DBI.pm
> > --- DBI-1.40/DBI.pm 2004-01-08 14:03:57.000000000 +0000
> > +++ DBI-1.40-new/DBI.pm     2004-01-26 10:15:46.000000000 +0000
> > @@ -1719,7 +1719,7 @@
> >  
> >      sub execute_for_fetch {
> >     my ($sth, $fetch_tuple_sub, $tuple_status) = @_;
> > -   @$tuple_status = () if $tuple_status; # reset the status array
> > +   @$tuple_status = (); # reset the status array

Actualy I did this instead, as it seems more correct:

@@ -1720,5 +1721,6 @@
     sub execute_for_fetch {
        my ($sth, $fetch_tuple_sub, $tuple_status) = @_;
-       @$tuple_status = () if $tuple_status; # reset the status array
+       # start with empty status array
+       ($tuple_status) ? @$tuple_status = () : $tuple_status = undef;

I also spotted that the docs don't match the code so I changed the docs:

-The number of tuples executed is returned, regardless of the success
-or failure of those executions. Use tuple_status to check.
+The number of tuples executed is returned I<only if> there were no errors.
+If there were any errors then C<undef> is returned and the @tuple_status
+array can be used to discover which tuples failed and with what errors.

Thanks.

Tim.

Reply via email to