Author: byterock
Date: Fri Jul 18 11:49:16 2008
New Revision: 11541

Modified:
   dbd-oracle/trunk/Changes
   dbd-oracle/trunk/dbdimp.c
   dbd-oracle/trunk/dbdimp.h
   dbd-oracle/trunk/oci8.c

Log:
one more change that is linked with the last fix. Seems ref-cursor and SPs 
cannot buffer over the #of records in the cursor. Since the OCI does not know 
the # of records in a cursor it will did. I set it up so it will always be 1. 

Modified: dbd-oracle/trunk/Changes
==============================================================================
--- dbd-oracle/trunk/Changes    (original)
+++ dbd-oracle/trunk/Changes    Fri Jul 18 11:49:16 2008
@@ -1,5 +1,5 @@
 =head1 Changes in DBD-Oracle 1.22(svn rev xxxx)  2008 
-  Fix for bug reported on SPs with Lobs reported by Martin Evans, Fix by J 
Scoles
+  Fix for bugs on SPs with Lobs reported by Martin Evans, Fix by J Scoles
   Changed the way Ping works rather than using prepare and execute it now 
makes a single round trip call to DB by John Scoles
   Fix for rt.cpan.org Ticket #=37501 fail HP-UX Itanium 11.31 makefile also 
added the OS and version to the output of the Makefile.PL for easier debugging. 
from John Scoles and Rich Roemer 
   Added a number of internal functions for decoding OCI debug values from John 
Scoles

Modified: dbd-oracle/trunk/dbdimp.c
==============================================================================
--- dbd-oracle/trunk/dbdimp.c   (original)
+++ dbd-oracle/trunk/dbdimp.c   Fri Jul 18 11:49:16 2008
@@ -2392,7 +2392,8 @@
        imp_sth_csr->clbk_lob   = imp_sth->clbk_lob;
        imp_sth_csr->piece_size = imp_sth->piece_size;
        imp_sth_csr->piece_lob  = imp_sth->piece_lob;
-
+       imp_sth_csr->is_child   = 1; /*no prefetching on a cursor or sp*/
+       
        
        /* assign statement handle from placeholder descriptor  */
        imp_sth_csr->stmhp = (OCIStmt*)phs->desc_h;
@@ -3002,12 +3003,12 @@
 
 
                if (status != OCI_SUCCESS) { /* may be OCI_ERROR or 
OCI_SUCCESS_WITH_INFO etc */
-       /* we record the error even for OCI_SUCCESS_WITH_INFO */
+                       /* we record the error even for OCI_SUCCESS_WITH_INFO */
                        oci_error(sth, imp_sth->errhp, status, 
ora_sql_error(imp_sth,"OCIStmtExecute"));
-       /* but only bail out here if not OCI_SUCCESS_WITH_INFO */
-               if (status != OCI_SUCCESS_WITH_INFO)
-                   return -2;
-    }
+                       /* but only bail out here if not OCI_SUCCESS_WITH_INFO 
*/
+                       if (status != OCI_SUCCESS_WITH_INFO)
+                           return -2;
+       }
 
     if (is_select) {
                DBIc_ACTIVE_on(imp_sth);
@@ -3030,40 +3031,40 @@
 
     if (is_select && !imp_sth->done_desc) {
        /* describe and allocate storage for results (if any needed)    */
-       if (!dbd_describe(sth, imp_sth))
-           return -2; /* dbd_describe already called oci_error()       */
-    }
+               if (!dbd_describe(sth, imp_sth))
+                   return -2; /* dbd_describe already called oci_error()       
*/
+       }
 
-    if (imp_sth->has_lobs && imp_sth->stmt_type != OCI_STMT_SELECT) {
+       if (imp_sth->has_lobs && imp_sth->stmt_type != OCI_STMT_SELECT) {
                if (!post_execute_lobs(sth, imp_sth, row_count))
                    return -2; /* post_insert_lobs already called oci_error()   
*/
-       }
+       }
 
-    if (outparams) {   /* check validity of bound output SV's  */
+       if (outparams) {        /* check validity of bound output SV's  */
                int i = outparams;
                while(--i >= 0) {
-                   /* phs->alen has been updated by Oracle to hold the length 
of the result */
-                   phs_t *phs = 
(phs_t*)(void*)SvPVX(AvARRAY(imp_sth->out_params_av)[i]);
-                   SV *sv = phs->sv;
-                   if (debug >= 2 || dbd_verbose >= 2) {
+                       /* phs->alen has been updated by Oracle to hold the 
length of the result */
+                       phs_t *phs = 
(phs_t*)(void*)SvPVX(AvARRAY(imp_sth->out_params_av)[i]);
+                       SV *sv = phs->sv;
+                       if (debug >= 2 || dbd_verbose >= 2) {
                                PerlIO_printf(DBILOGFP,
-                               "dbd_st_execute(): Analyzing inout parameter 
'%s of type=%d'\n",
-                               phs->name,phs->ftype);
-                   }
-                   if( phs->ftype == ORA_VARCHAR2_TABLE ){
+                                       "dbd_st_execute(): Analyzing inout 
parameter '%s of type=%d'\n",
+                                       phs->name,phs->ftype);
+                       }
+                       if( phs->ftype == ORA_VARCHAR2_TABLE ){
                                
dbd_phs_ora_varchar2_table_fixup_after_execute(phs);
                                continue;
-                   }
-                   if( phs->ftype == ORA_NUMBER_TABLE ){
+                       }
+                       if( phs->ftype == ORA_NUMBER_TABLE ){
                                
dbd_phs_ora_number_table_fixup_after_execute(phs);
                                continue;
-                   }
+                       }
 
-                   if (phs->out_prepost_exec) {
+                       if (phs->out_prepost_exec) {
                                if (!phs->out_prepost_exec(sth, imp_sth, phs, 
0))
                                    return -2; /* out_prepost_exec already 
called ora_error()   */
-                   }
-                   else {
+                        }
+                         else {
                            if (SvTYPE(sv) == SVt_RV && SvTYPE(SvRV(sv)) == 
SVt_PVAV) {
                                        AV *av = (AV*)SvRV(sv);
                                        I32 avlen = AvFILL(av);
@@ -3075,7 +3076,7 @@
                                }
                        }
                }
-    }
+       }
 
     return row_count;  /* row count (0 will be returned as "0E0")      */
 }

Modified: dbd-oracle/trunk/dbdimp.h
==============================================================================
--- dbd-oracle/trunk/dbdimp.h   (original)
+++ dbd-oracle/trunk/dbdimp.h   Fri Jul 18 11:49:16 2008
@@ -69,6 +69,7 @@
     OCISvcCtx          *svchp; /* copy of dbh pointer  */
     OCIStmt                    *stmhp; /* oci statement  handle */
     OCIDescribe        *dschp; /* oci describe handle */
+    int             is_child;  /* if this is child from a ref cursor or SP*/
        ub2                     stmt_type;      /* OCIAttrGet 
OCI_ATTR_STMT_TYPE        */
     U16                                auto_lob;       /* use auto lobs*/
     int                                pers_lob;   /*use dblink for lobs only 
for 10g Release 2. or later*/
@@ -194,6 +195,7 @@
     /* if this is an embedded object we use this */
     fbh_obj_t   *obj;
 
+
  };
 
  /* Placeholder structure */

Modified: dbd-oracle/trunk/oci8.c
==============================================================================
--- dbd-oracle/trunk/oci8.c     (original)
+++ dbd-oracle/trunk/oci8.c     Fri Jul 18 11:49:16 2008
@@ -2220,7 +2220,12 @@
     else if (SvOK(imp_drh->ora_cache))   imp_sth->cache_rows = 
SvIV(imp_drh->ora_cache);
 
 
-       if (imp_dbh->RowCacheSize || imp_sth->prefetch_memory){
+    if (imp_sth->is_child){ /*ref cursors and sp only one row is allowed*/
+    
+       cache_rows  =1;
+          cache_mem  =0;
+          
+       } else if (imp_dbh->RowCacheSize || imp_sth->prefetch_memory){
        /*user set values */
                 cache_rows  =imp_dbh->RowCacheSize;
             cache_mem   =imp_sth->prefetch_memory;
@@ -3059,7 +3064,7 @@
                        if (imp_sth->rs_array_on) {     /* if array fetch on, 
fetch only if not in cache */
                                imp_sth->rs_array_idx++;
                                if 
(imp_sth->rs_array_num_rows<=imp_sth->rs_array_idx && 
imp_sth->rs_array_status==OCI_SUCCESS) {
-                                       
OCIStmtFetch_log_stat(imp_sth->stmhp,imp_sth->errhp,imp_sth->rs_array_size,(ub2)OCI_FETCH_NEXT,OCI_DEFAULT,status);
+                               
OCIStmtFetch_log_stat(imp_sth->stmhp,imp_sth->errhp,imp_sth->rs_array_size,(ub2)OCI_FETCH_NEXT,OCI_DEFAULT,status);
                                        imp_sth->rs_array_status=status;
                                        OCIAttrGet_stmhp_stat(imp_sth, 
&imp_sth->rs_array_num_rows,0,OCI_ATTR_ROWS_FETCHED, status);
                                        imp_sth->rs_array_idx=0;

Reply via email to