[svn:dbd-oracle] r14662 - dbd-oracle/branches/exe_array

[email protected] Fri, 28 Jan 2011 12:29:45 -0800 (PST)
Newsgroups perl.dbd.oracle.changes
Message-ID <[email protected]>
Author: byterock
Date: Fri Jan 28 12:29:43 2011
New Revision: 14662

Modified:
   dbd-oracle/branches/exe_array/Oracle.pm
   dbd-oracle/branches/exe_array/Oracle.xs
   dbd-oracle/branches/exe_array/dbdimp.c
   dbd-oracle/branches/exe_array/dbdimp.h

Log:
Working according t what DBI does 

Modified: dbd-oracle/branches/exe_array/Oracle.pm
==============================================================================
--- dbd-oracle/branches/exe_array/Oracle.pm	(original)
+++ dbd-oracle/branches/exe_array/Oracle.pm	Fri Jan 28 12:29:43 2011
@@ -1012,6 +1012,7 @@
     sub execute_for_fetch {
        my ($sth, $fetch_tuple_sub, $tuple_status) = @_;
        my $row_count = 0;
+       my $err_count = 0;
        my $tuple_count="0E0";
        my $tuple_batch_status;
        my $dbh = $sth->{Database};
@@ -1030,21 +1031,33 @@
            my $res = ora_execute_array($sth,
                                            \@tuple_batch,
                                            scalar(@tuple_batch),
-                                           $tuple_batch_status);
-           if(defined($res) && defined($row_count)) {
+                                           $tuple_batch_status,
+                                           $err_count );
+           if(defined($res)) { #no error
                 $row_count += $res;
            } else {
                 $row_count = undef;
            }
+           
            $tuple_count+=@$tuple_batch_status;
            push @$tuple_status, @$tuple_batch_status
-           if defined($tuple_status);
+           	if defined($tuple_status);
+           	
+           
        }
+       #error check here
+       return $sth->set_err($DBI::stderr, "executing $tuple_count generated $err_count errors")
+       	   if $err_count;
+                   
        if (!wantarray) {
 	   return undef if !defined $row_count;
    	   return $tuple_count;
        }
-       return (defined $row_count ? $tuple_count : undef, $row_count);
+
+       return (defined $row_count ? $tuple_count : undef, $tuple_count-$err_count);
+            
+       
+       
     }
 
     sub private_attribute_info {

Modified: dbd-oracle/branches/exe_array/Oracle.xs
==============================================================================
--- dbd-oracle/branches/exe_array/Oracle.xs	(original)
+++ dbd-oracle/branches/exe_array/Oracle.xs	Fri Jan 28 12:29:43 2011
@@ -157,10 +157,10 @@
 	D_imp_sth(sth);
 	SV *av_value;
 	if (!SvROK(av_ref) || SvTYPE(SvRV(av_ref)) != SVt_PVAV)
-	croak("bind_param_inout_array needs a reference to a array value");
+	 	 croak("bind_param_inout_array needs a reference to a array value");
 	av_value = av_ref;
 	if (SvREADONLY(av_value))
-	croak("Modification of a read-only value attempted");
+		croak("Modification of a read-only value attempted");
 	if (attribs) {
 		if (SvNIOK(attribs)) {
 			sql_type = SvIV(attribs);
@@ -199,7 +199,7 @@
 	XSRETURN_IV(DBIc_NUM_FIELDS(imp_sth));
 	}
 	if (debug >= 2)
-	PerlIO_printf(DBILOGFP, "	-> ora_fetch\n");
+		PerlIO_printf(DBILOGFP, "	-> ora_fetch\n");
 	av = dbd_st_fetch(sth, imp_sth);
 	if (av) {
 	int num_fields = AvFILL(av)+1;
@@ -216,16 +216,17 @@
 		PerlIO_printf(DBILOGFP, "	<- () [0 items]\n");
 	}
 	if (debug >= 2 && SvTRUE(DBIc_ERR(imp_sth)))
-	PerlIO_printf(DBILOGFP, "	!! ERROR: %s %s",
-		neatsvpv(DBIc_ERR(imp_sth),0), neatsvpv(DBIc_ERRSTR(imp_sth),0));
+		PerlIO_printf(DBILOGFP, "	!! ERROR: %s %s",
+			neatsvpv(DBIc_ERR(imp_sth),0), neatsvpv(DBIc_ERRSTR(imp_sth),0));
 
 void
-ora_execute_array(sth, tuples, exe_count, tuples_status, cols=&PL_sv_undef)
-	SV *		sth
-	SV *		tuples
-	IV		 exe_count
-	SV *		tuples_status
-	SV *		cols
+ora_execute_array(sth, tuples, exe_count, tuples_status, err_count, cols=&PL_sv_undef)
+	SV *	sth
+	SV *	tuples
+	IV		exe_count
+	SV *	tuples_status
+	SV *	cols
+	SV *	err_count
 	PREINIT:
 	D_imp_sth(sth);
 	int retval;
@@ -235,7 +236,7 @@
 	if (DBIc_ROW_COUNT(imp_sth) > 0) /* reset for re-execute */
 		DBIc_ROW_COUNT(imp_sth) = 0;
 	retval = ora_st_execute_array(sth, imp_sth, tuples, tuples_status,
-								  cols, (ub4)exe_count);
+								  cols, (ub4)exe_count,err_count);
 	/* XXX Handle return value ... like DBI::execute_array(). */
 	/* remember that dbd_st_execute must return <= -2 for error */
 	if (retval == 0)			/* ok with no rows affected	 */
@@ -354,7 +355,7 @@
 	ST(0) = &PL_sv_undef;
 	}
 	else {
-	ST(0) = &PL_sv_yes;
+		ST(0) = &PL_sv_yes;
 	}
 
 void

Modified: dbd-oracle/branches/exe_array/dbdimp.c
==============================================================================
--- dbd-oracle/branches/exe_array/dbdimp.c	(original)
+++ dbd-oracle/branches/exe_array/dbdimp.c	Fri Jan 28 12:29:43 2011
@@ -3541,13 +3541,14 @@
 }
 
  int
-ora_st_execute_array(sth, imp_sth, tuples, tuples_status, columns, exe_count)
+ora_st_execute_array(sth, imp_sth, tuples, tuples_status, columns, exe_count, err_count)
 	SV *sth;
 	imp_sth_t *imp_sth;
 	SV *tuples;
 	SV *tuples_status;
 	SV *columns;
 	ub4 exe_count;
+	SV *err_count;
 {
 	dTHX;
 	dTHR;
@@ -3769,7 +3770,7 @@
 		SV *err_svs[2];
 		/*AV *err_av;*/
 		sb4 err_code;
-
+	    sv_setiv(err_count,num_errs);
 		err_svs[0] = newSViv((IV)0);
 		err_svs[1] = newSVpvn("", 0);
 		OCIHandleAlloc_ok(imp_sth->envhp, &row_errhp, OCI_HTYPE_ERROR, status);
@@ -3808,6 +3809,7 @@
 		return -2;
 	} else {
 		ub4 row_count = 0;
+
 		OCIAttrGet_stmhp_stat(imp_sth, &row_count, 0, OCI_ATTR_ROW_COUNT, status);
 		return row_count;
 	}

Modified: dbd-oracle/branches/exe_array/dbdimp.h
==============================================================================
--- dbd-oracle/branches/exe_array/dbdimp.h	(original)
+++ dbd-oracle/branches/exe_array/dbdimp.h	Fri Jan 28 12:29:43 2011
@@ -342,7 +342,7 @@
 int dbd_rebind_ph_nty _((SV *sth, imp_sth_t *imp_sth, phs_t *phs));
 
 int ora_st_execute_array _((SV *sth, imp_sth_t *imp_sth, SV *tuples,
-							SV *tuples_status, SV *columns, ub4 exe_count));
+							SV *tuples_status, SV *columns, ub4 exe_count, SV *err_count));
 
 
 SV * ora_create_xml _((SV *dbh, char *source));