Author: byterock
Date: Thu Jul  9 07:50:54 2009
New Revision: 13023

Modified:
   dbd-oracle/branches/rs_array/oci8.c

Log:
really working

Modified: dbd-oracle/branches/rs_array/oci8.c
==============================================================================
--- dbd-oracle/branches/rs_array/oci8.c (original)
+++ dbd-oracle/branches/rs_array/oci8.c Thu Jul  9 07:50:54 2009
@@ -2290,9 +2290,11 @@
        D_imp_dbh_from_sth;
        D_imp_drh_from_dbh;
        int num_errors  = 0;
-       ub4 cache_mem   = 0;
-       sb4 cache_rows  = 10000;/* set high so memory is the limit */
+       ub4 prefetch_mem        = 0; /*Oracle prefetch memory buffer*/
+       ub4 prefetch_rows       = 0; /*Oracle prefetch Row Buffer*/
+       sb4 cache_rows          = 0;/* set high so memory is the limit */
        sword status;
+       sb4 test_cache_rows = 0;
 
        /* reworked this is little so the user can set up his own cache
          basically if rowcachesize or prefetch_mem is set it uses those values
@@ -2310,42 +2312,75 @@
        }
 
 
-       if (imp_sth->is_child  || imp_sth->ret_lobs){ /*ref cursors and sp only 
one row is allowed*/
+/*     if (imp_sth->is_child  || imp_sth->ret_lobs){ /*ref cursors and sp only 
one row is allowed
 
               cache_rows  =1;
-                  cache_mem  =0;
+                  prefetch_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;
-
-       } else if (imp_sth->cache_rows >= 0) {  /* set cache size by row count  
*/
-
-               /* imp_sth->est_width needs to be set */
-               cache_mem  = 0;                  /* so memory isn't the limit */
+PerlIO_printf(DBILOGFP,"HERE a\n");
+       /*user set values *
+                cache_rows     =imp_dbh->RowCacheSize;
+                prefetch_mem   =imp_sth->prefetch_memory;
+
+       } else if (imp_sth->cache_rows >= 0) {  /* set cache size by row count  
+       
+       
+PerlIO_printf(DBILOGFP,"HERE b\n");
+               /* imp_sth->est_width needs to be set 
+               prefetch_mem  = 0;                       /* so memory isn't the 
limit 
 
                cache_rows = 
calc_cache_rows(imp_sth->cache_rows,(int)num_fields, imp_sth->est_width, 
has_longs);
 
                if (max_cache_rows && cache_rows > (signed long) max_cache_rows)
                        cache_rows = max_cache_rows;
 
-               imp_sth->cache_rows = cache_rows;       /* record updated value 
*/
+               imp_sth->cache_rows = cache_rows;       /* record updated value 
 
        }
        else {                          /* set cache size by memory     */
-                                               /* not sure if we ever reach 
this*/
-               cache_mem  = -imp_sth->cache_rows; /* cache_mem always +ve here 
*/
+                                               /* not sure if we ever reach 
this
+               prefetch_mem  = -imp_sth->cache_rows; /* cache_mem always +ve 
here 
                if (max_cache_rows &&  cache_rows > (signed long) 
max_cache_rows) {
                        cache_rows = max_cache_rows;
-                       imp_sth->cache_rows = cache_rows;       /* record 
updated value only if max_cache_rows */
+                       imp_sth->cache_rows = cache_rows;       /* record 
updated value only if max_cache_rows 
                }
 
        }
 
-
+*/
+    if (imp_dbh->RowCacheSize){
+         cache_rows=imp_dbh->RowCacheSize;
+       }
+    
+    prefetch_rows      =imp_sth->prefetch_rows;
+       prefetch_mem    =imp_sth->prefetch_memory;
+       
+       
+       if (!cache_rows) { /*start with this value if not set then set default*/
+               
+               cache_rows=calc_cache_rows(imp_sth->cache_rows,(int)num_fields, 
imp_sth->est_width, has_longs);
+                       
+               PerlIO_printf(DBILOGFP,"cache_rows=%d\n",cache_rows);
+               
PerlIO_printf(DBILOGFP,"imp_sth->cache_rows=%d\n",imp_sth->cache_rows);
+               
+               if(!prefetch_rows){
+                         prefetch_rows=cache_rows;
+               }
+       }
+       else if (imp_dbh->RowCacheSize < 0) {/* for compaibility with DBI doc 
negitive value here means use the value as memory*/
+               PerlIO_printf(DBILOGFP,"2\n");
+               prefetch_mem    =-imp_dbh->RowCacheSize; /* cache_mem always 
+ve here */
+               prefetch_rows   =0;
+               cache_rows=calc_cache_rows(imp_sth->cache_rows,(int)num_fields, 
imp_sth->est_width, has_longs);
+                       /*Sill use local cache but it is calulated nothing in 
the doc for this so I will use it like this*/
+       }
+               
+       
+    PerlIO_printf(DBILOGFP,"cache_rows=%d 
prefetch_rows=%d,prefetch_mem=%d\n",cache_rows,prefetch_rows,prefetch_mem);
+    
        OCIAttrSet_log_stat(imp_sth->stmhp, OCI_HTYPE_STMT,
-                                               &cache_mem,  sizeof(cache_mem), 
OCI_ATTR_PREFETCH_MEMORY,
+                                               &prefetch_mem,  
sizeof(prefetch_mem), OCI_ATTR_PREFETCH_MEMORY,
                                                imp_sth->errhp, status);
 
        if (status != OCI_SUCCESS) {
@@ -2355,7 +2390,7 @@
        }
 
        OCIAttrSet_log_stat(imp_sth->stmhp, OCI_HTYPE_STMT,
-                                       &cache_rows, sizeof(cache_rows), 
OCI_ATTR_PREFETCH_ROWS,
+                                       &prefetch_rows, sizeof(prefetch_rows), 
OCI_ATTR_PREFETCH_ROWS,
                                imp_sth->errhp, status);
 
        if (status != OCI_SUCCESS) {
@@ -2363,14 +2398,28 @@
                ++num_errors;
        }
 
-/*     if (imp_sth->rs_array_on && cache_rows>0)*/
-               imp_sth->rs_array_size=cache_rows;/*>128?128:cache_rows;        
/* restrict to 128 for now */
+    imp_sth->rs_array_size=cache_rows;
+    
+    if (max_cache_rows){
+               imp_sth->rs_array_size=max_cache_rows;
+       } 
+       else{
+         
+       }
+       /*imp_sth->cache_rows=prefetch_rows;*/
+
+/*     if (imp_sth->rs_array_on && cache_rows>0)
+               imp_sth->rs_array_size=cache_rows;*>128?128:cache_rows; /* 
restrict to 128 for now   
+           imp_sth->rs_array_size=cache_rows;
+               imp_sth->cache_rows=cache_rows;*/
 
        if (DBIS->debug >= 3 || dbd_verbose >= 3 )
                PerlIO_printf(DBILOGFP,
-                       "       row cache OCI_ATTR_PREFETCH_ROWS %lu, 
OCI_ATTR_PREFETCH_MEMORY %lu cache_rows=%d\n",
-                       (unsigned long) (cache_rows), (unsigned long) 
(cache_mem),cache_rows);
+                       "       row cache OCI_ATTR_PREFETCH_ROWS %lu, 
OCI_ATTR_PREFETCH_MEMORY %lu cache_rows=%d\n max_cache_rows=%d",
+                       (unsigned long) (cache_rows), (unsigned long) 
(prefetch_mem),cache_rows,max_cache_rows);
+
 
+   
        return num_errors;
 }
 
@@ -3014,10 +3063,13 @@
        }/* end define of filed struct[i] fbh*/
 
        imp_sth->est_width = est_width;
-
-       sth_set_row_cache(h, imp_sth,
-                       (nested_cursors) ? imp_dbh->max_nested_cursors / 
nested_cursors : 0,
+sth_set_row_cache(h, imp_sth,
+                       (imp_dbh->max_nested_cursors) ? 0 :nested_cursors ,
                        (int)num_fields, has_longs );
+                       
+       /*sth_set_row_cache(h, imp_sth,
+                       (nested_cursors) ? imp_dbh->max_nested_cursors / 
nested_cursors : 0,
+                       (int)num_fields, has_longs );*/
        /* Initialise cache counters */
        imp_sth->in_cache  = 0;
        imp_sth->eod_errno = 0;

Reply via email to