Author: byterock
Date: Tue Jul  1 04:28:02 2008
New Revision: 11471

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

Log:
fetch function version of callback lob

Modified: dbd-oracle/branches/lob_piece/oci8.c
==============================================================================
--- dbd-oracle/branches/lob_piece/oci8.c        (original)
+++ dbd-oracle/branches/lob_piece/oci8.c        Tue Jul  1 04:28:02 2008
@@ -1359,7 +1359,7 @@
        dTHX;
     char name[64];
     sprintf(name, "field %d of %d", fbh->field_num, 
DBIc_NUM_FIELDS(fbh->imp_sth));
-
+PerlIO_printf(DBILOGFP,"fetch_lob\n");
     return fetch_lob(sth, fbh->imp_sth, (OCILobLocator*)fbh->desc_h, 
fbh->ftype, dest_sv, name);
 }
 
@@ -1762,6 +1762,40 @@
 }
 
 
+
+static int
+fetch_clbk_lob(SV *sth, imp_fbh_t *fbh,SV *dest_sv){
+
+       dTHX;
+       D_imp_sth(sth);
+       fb_ary_t *fb_ary = fbh->fb_ary;
+
+    ub4 actual_bufl=imp_sth->piece_size*(fb_ary->piece_count)+fb_ary->bufl;
+
+       if (fb_ary->piece_count==0){
+               if (DBIS->debug >= 6 || dbd_verbose <= 6)
+                       PerlIO_printf(DBILOGFP,"  Fetch persistent lob of %d 
(char/bytes) with callback in 1 piece of %d 
(Char/Bytes)\n",actual_bufl,fb_ary->bufl);
+
+               memcpy(fb_ary->cb_abuf,fb_ary->abuf,fb_ary->bufl );
+
+       } else {
+               if (DBIS->debug >= 6 || dbd_verbose <= 6)
+                       PerlIO_printf(DBILOGFP,"  Fetch persistent lob of %d 
(Char/Bytes) with callback in %d piece(s) of %d (Char/Bytes) and one piece of 
%d 
(Char/Bytes)\n",actual_bufl,fb_ary->piece_count,fbh->piece_size,fb_ary->bufl);
+
+               
memcpy(fb_ary->cb_abuf+imp_sth->piece_size*(fb_ary->piece_count),fb_ary->abuf,fb_ary->bufl
 );
+       }
+
+       if (fbh->ftype == SQLT_BIN){
+           *(fb_ary->cb_abuf+(actual_bufl))='\0'; /* add a null teminator*/
+           sv_setpvn(dest_sv, (char*)fb_ary->cb_abuf,(STRLEN)actual_bufl);
+       } else {
+               sv_setpvn(dest_sv, (char*)fb_ary->cb_abuf,(STRLEN)actual_bufl);
+               if (CSFORM_IMPLIES_UTF8(fbh->csform) ){
+                       SvUTF8_on(dest_sv);
+               }
+       }
+       return 1;
+}
 /* This is another way to get lobs as a alternate to callback */
 
 static int
@@ -2444,7 +2478,7 @@
                 if (imp_sth->pers_lob){
                                        fbh->pers_lob      = 1;
                                        fbh->disize        = 
fbh->disize+long_readlen; /*user set max value for the fetch*/
-                       PerlIO_printf(DBILOGFP, " fbh->dbsize 
1=%d\n",fbh->dbsize);
+                               PerlIO_printf(DBILOGFP, " fbh->dbsize 
1=%d\n",fbh->dbsize);
 
                        if (fbh->dbtype == 112){
                                                fbh->ftype = SQLT_CHR;
@@ -2473,6 +2507,8 @@
                                        fbh->ftype = SQLT_BIN; /*other Binary*/
 
                                }
+                               fbh->fetch_func = fetch_clbk_lob;
+
                                } else if (imp_sth->piece_lob){
                                        fbh->piece_lob      = 1;
                                        fbh->define_mode   = OCI_DYNAMIC_FETCH; 
/* piecwise fetch*/
@@ -2821,7 +2857,7 @@
                                }
 
                } else {
-                if (fbh->clbk_lob){
+               /* if (fbh->clbk_lob){
                        ub4 
actual_bufl=imp_sth->piece_size*(fb_ary->piece_count)+fb_ary->bufl;
                     if (fb_ary->piece_count==0){
 
@@ -2838,7 +2874,7 @@
                                }
 
                                        if (fbh->ftype == SQLT_BIN){
-                                       *(fb_ary->cb_abuf+(actual_bufl))='\0'; 
/* add a null teminator*/
+                                       *(fb_ary->cb_abuf+(actual_bufl))='\0'; 
/* add a null teminator
                                        sv_setpvn(sv, 
(char*)fb_ary->cb_abuf,(STRLEN)actual_bufl);
 
                                        } else {
@@ -2850,7 +2886,7 @@
                                        }
 
 
-                               } else {
+                               } else {*/
                                        int datalen = 
fb_ary->arlen[imp_sth->rs_array_idx];
                                    char *p = (char*)row_data;
                                        /* if ChopBlanks check for Oracle CHAR 
type (blank padded)      */
@@ -2862,7 +2898,7 @@
                                        if (CSFORM_IMPLIES_UTF8(fbh->csform) ){
                                        SvUTF8_on(sv);
                                        }
-                               }
+                               /*}*/
                    }
 
                } else if (rc == 1405) {        /* field is null - return undef 
*/

Reply via email to