Author: byterock
Date: Tue Jul  1 10:01:36 2008
New Revision: 11473

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

Log:
-working version 

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 10:01:36 2008
@@ -1359,7 +1359,6 @@
        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);
 }
 
@@ -1773,13 +1772,13 @@
     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)
+               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)
+               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
 );
@@ -2478,18 +2477,11 @@
                 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);
-
-                       if (fbh->dbtype == 112){
+                               if (fbh->dbtype == 112){
                                                fbh->ftype = SQLT_CHR;
                                        } else {
-                                               fbh->ftype = SQLT_BIN; /*other 
Binary*/
+                                               fbh->ftype = SQLT_LVB; /*Binary 
form seems this is the only value where we cna get the length correctly*/
                                        }
-PerlIO_printf(DBILOGFP, " imp_sth->long_readlen=%d\n",long_readlen);
-
-
-PerlIO_printf(DBILOGFP, " fbh->dbsize 2 =%d\n",fbh->dbsize);
-
                           } else if (imp_sth->clbk_lob){ /*this only works on 
10.2 */
 
                                        fbh->clbk_lob      = 1;
@@ -2657,6 +2649,9 @@
                }
 
 
+               OCIAttrSet((dvoid *)fbh->defnp, (ub4)OCI_HTYPE_BIND, (dvoid 
*)&define_len,
+    (ub4)0, (ub4)OCI_ATTR_MAXDATA_SIZE, imp_sth->errhp);
+
                if (fbh->ftype == 108)  { /* Embedded object bind it 
differently*/
 
                                if (DBIS->debug >= 5 || dbd_verbose >= 5){
@@ -2848,7 +2843,7 @@
                }
 
                if (rc == 0 ||  /* the normal case*/
-                       (fbh->clbk_lob && rc == 1406 && 
DBIc_has(imp_sth,DBIcf_LongTruncOk))/*or a trunckated record when using 10.2 
Persistent Lob interface*/
+                       ( rc == 1406 && 
DBIc_has(imp_sth,DBIcf_LongTruncOk))/*or a trunckated record when using 10.2 
Persistent Lob interface*/
                ) {
                        if (fbh->fetch_func) {
 
@@ -2857,48 +2852,25 @@
                                }
 
                } else {
-               /* if (fbh->clbk_lob){
-                       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(sv, 
(char*)fb_ary->cb_abuf,(STRLEN)actual_bufl);
+                               int datalen = 
fb_ary->arlen[imp_sth->rs_array_idx];
+                               char *p = (char*)row_data;
 
-                                       } else {
-
-                                               sv_setpvn(sv, 
(char*)fb_ary->cb_abuf,(STRLEN)actual_bufl);
-                                               if 
(CSFORM_IMPLIES_UTF8(fbh->csform) ){
-                                               SvUTF8_on(sv);
-                                               }
-                                       }
-
-
-                               } 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)      */
+                               if (fbh->ftype == SQLT_LVB){
+                                       /* very special case for binary lobs 
that are directly fetched.
+                                  Seems I have to use SQLT_LVB to get the 
length all other will fail*/
+                                       datalen = *(ub4*)row_data;
+                                       sv_setpvn(sv, (char*)row_data+ 
sizeof(ub4), datalen);
+                               } else {
                                        if (ChopBlanks && fbh->dbtype == 96) {
-                                           while(datalen && p[datalen - 1]==' 
')
+                                   while(datalen && p[datalen - 1]==' ')
                                                --datalen;
                                        }
                                        sv_setpvn(sv, p, (STRLEN)datalen);
                                        if (CSFORM_IMPLIES_UTF8(fbh->csform) ){
                                        SvUTF8_on(sv);
                                        }
-                               /*}*/
+                               }
                    }
 
                } else if (rc == 1405) {        /* field is null - return undef 
*/

Reply via email to