Author: timbo
Date: Tue Dec 13 14:20:27 2005
New Revision: 2309

Modified:
   dbi/trunk/Changes
   dbi/trunk/Driver.xst
Log:
Fixed selectrow_array to return empty list on error.


Modified: dbi/trunk/Changes
==============================================================================
--- dbi/trunk/Changes   (original)
+++ dbi/trunk/Changes   Tue Dec 13 14:20:27 2005
@@ -8,6 +8,7 @@ DBI::Changes - List of significant chang
 
   Fixed Makefile.PL options for gcc bug introduced in 1.49.
   Fixed handle magic order to keep DBD::Oracle happy.
+  Fixed selectrow_array to return empty list on error.
 
   Changed dbi_profile_merge() to be able to recurse and merge
     sub-trees of profile data.

Modified: dbi/trunk/Driver.xst
==============================================================================
--- dbi/trunk/Driver.xst        (original)
+++ dbi/trunk/Driver.xst        Tue Dec 13 14:20:27 2005
@@ -146,6 +146,7 @@ selectrow_arrayref(...)
     ALIAS:
        selectrow_array = 1
     PREINIT:
+    int is_selectrow_array = (ix == 1);
     imp_sth_t *imp_sth;
     SV *sth;
     AV *row_av;
@@ -156,20 +157,21 @@ selectrow_arrayref(...)
     else {
        /* --- prepare --- */
        sth = dbixst_bounce_method("prepare", 3);
-       if (!SvROK(sth))
-           XSRETURN_UNDEF;
+       if (!SvROK(sth)) {
+           if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
+       }
     }
     imp_sth = (imp_sth_t*)(DBIh_COM(sth));
     /* --- bind_param --- */
     if (items > 3) {   /* need to bind params before execute */
        if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) {
-           XSRETURN_UNDEF;
+           if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
        }
     }
     /* --- execute --- */
     DBIc_ROW_COUNT(imp_sth) = 0;
     if ( dbd_st_execute(sth, imp_sth) <= -2 ) {        /* -2 == error */
-        XSRETURN_UNDEF;
+       if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
     }
     /* --- fetchrow_arrayref --- */
     row_av = dbd_st_fetch(sth, imp_sth);
@@ -177,7 +179,7 @@ selectrow_arrayref(...)
        if (GIMME == G_SCALAR)
            PUSHs(&PL_sv_undef);
     }
-    else if (ix == 1) { /* selectrow_array */
+    else if (is_selectrow_array) {
        int i;
        int num_fields = AvFILL(row_av)+1;
        if (GIMME == G_SCALAR)

Reply via email to