Author: byterock
Date: Wed Jun 25 10:56:30 2008
New Revision: 11459
Modified:
dbd-oracle/branches/lob_piece/oci8.c
Log:
new cleaned up version
Modified: dbd-oracle/branches/lob_piece/oci8.c
==============================================================================
--- dbd-oracle/branches/lob_piece/oci8.c (original)
+++ dbd-oracle/branches/lob_piece/oci8.c Wed Jun 25 10:56:30 2008
@@ -620,8 +620,8 @@
*rcpp = fb_ary->arcode;
- if (dbd_verbose <= 4) {
- PerlIO_printf(DBILOGFP, " presist_lob_fetch_cbk\n");
+ if (dbd_verbose >= 5) {
+ PerlIO_printf(DBILOGFP, " In presist_lob_fetch_cbk\n");
}
if ( *piecep ==OCI_NEXT_PIECE ){/*more than one piece*/
@@ -1759,18 +1759,16 @@
}
-/*static int This is another way to do the callback using set and get piece not
-used right now.*/
-fetch_get_piece(SV *sth, imp_fbh_t *fbh,SV *dest_sv){
+/* This is another way to get lobs as a alternate to callback */
+static int
+fetch_get_piece(SV *sth, imp_fbh_t *fbh,SV *dest_sv)
+{
dTHX;
D_imp_sth(sth);
fb_ary_t *fb_ary = fbh->fb_ary;
ub4 buflen = fb_ary->bufl;
- ub1* row_data = fb_ary->abuf;
- ub4 actual_bufl=0;
- ub4 alen = fbh->disize;
- ub1 buf2[1];
+ ub4 actual_bufl = 0;
ub1 piece = OCI_FIRST_PIECE;
void *hdlptr = (dvoid *) 0;
ub4 hdltype = OCI_HTYPE_DEFINE, iter = 0, idx = 0;
@@ -1779,60 +1777,60 @@
ub2 rcode = 0;
sword status = OCI_NEED_DATA;
- /* ub1*
row_data=&fb_ary->abuf[0]+(fb_ary->bufl*fbh->imp_sth->rs_array_idx);*/
- text buf[10000000];
-
-
- /*if (DBIS->debug <= 4 || dbd_verbose <= 4) {
- PerlIO_printf(DBILOGFP, " getting an Presistant
=%d\n",buflen);
- }*/
+ if (DBIS->debug >= 4 || dbd_verbose >= 4) {
+ PerlIO_printf(DBILOGFP, "in fetch_get_piece \n");
+ }
while (status == OCI_NEED_DATA){
- OCIStmtGetPieceInfo(fbh->imp_sth->stmhp,
+ /*OCIStmtGetPieceInfo(fbh->imp_sth->stmhp,
fbh->imp_sth->errhp,
&hdlptr, &hdltype,
&in_out, &iter, &idx, &piece);
+*/
+ OCIStmtGetPieceInfo_log_stat(fbh->imp_sth->stmhp,
+
fbh->imp_sth->errhp,
+
&hdlptr,
+
&hdltype,
+
&in_out,
+ &iter,
+ &idx,
+ &piece,
+
status);
+
+
+ OCIStmtSetPieceInfo_log_stat((dvoid *)hdlptr,
+
fbh->imp_sth->errhp,
+ (dvoid
*)fb_ary->abuf,
+
&buflen,
+ piece,
+ (dvoid
*)&indptr,
+
&rcode,status);
- OCIStmtSetPieceInfo((dvoid *)hdlptr, (ub4)hdltype,
-
fbh->imp_sth->errhp, (dvoid *) fb_ary->abuf, &buflen, piece,
-
(dvoid *)&indptr, &rcode);
-
-
-
-PerlIO_printf(DBILOGFP, "fb_ary->abuf=%s\n",fb_ary->abuf);
- /* sv_catpv(dest_sv, );*/
- status = OCIStmtFetch(fbh->imp_sth->stmhp,fbh->imp_sth->errhp,
(ub4) 1,
- (ub2)
OCI_FETCH_NEXT, (ub4) OCI_DEFAULT);
-
-PerlIO_printf(DBILOGFP, "status=%d\n",status);
+
OCIStmtFetch_log_stat(fbh->imp_sth->stmhp,fbh->imp_sth->errhp,1,(ub2)OCI_FETCH_NEXT,OCI_DEFAULT,status);
- if (status){
-
memcpy(fb_ary->cb_abuf+fb_ary->piece_count*imp_sth->piece_size,fb_ary->abuf,buflen
);
+ if (status){/* There is more than one piece*/
+
memcpy(fb_ary->cb_abuf+fb_ary->piece_count*imp_sth->piece_size,fb_ary->abuf,buflen
);
fb_ary->piece_count++;/*used to tell me how many pieces
I have, Might be able to use aindp for this?*/
- PerlIO_printf(DBILOGFP,
"fb_ary->piece_count=%d\n",fb_ary->piece_count);
- } else {
-PerlIO_printf(DBILOGFP, " 2
fb_ary->piece_count*imp_sth->piece_size=%d\n",fb_ary->piece_count*imp_sth->piece_size);
+ } else { /*Only one piece or the last part of a piece*/
memcpy(fb_ary->cb_abuf+fb_ary->piece_count*imp_sth->piece_size,fb_ary->abuf,buflen
);
-
-
}
-PerlIO_printf(DBILOGFP, "buflen=%d\n",buflen);
}
- actual_bufl=imp_sth->piece_size*(fb_ary->piece_count)+buflen;
-/* memcpy(fb_ary->cb_abuf+fb_ary->piece_count*buflen,fb_ary->abuf,buflen
);*/
-
- PerlIO_printf(DBILOGFP, "actual_bufl=%d\n",actual_bufl);
-
- /*
memcpy(fb_ary->cb_abuf+imp_sth->piece_size*(fb_ary->piece_count),fb_ary->abuf,fb_ary->bufl
);*/
+ actual_bufl=imp_sth->piece_size*(fb_ary->piece_count)+buflen;
+ 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);
+ }
+ }
- sv_setpvn(dest_sv, fb_ary->cb_abuf, (STRLEN)actual_bufl);
- PerlIO_printf(DBILOGFP, "fb_ary->piece_count
=%d\n",fb_ary->piece_count);
- dbd_verbose=0;
-return 1;
+ return 1;
}
@@ -1899,7 +1897,7 @@
fb_ary->cb_bufl=fbh->disize; /*reset this back to the max size for the
fetch*/
memset( fb_ary->cb_abuf, '\0', fbh->disize ); /*clean out the call back
buffer*/
- if (DBIS->debug <= 3 || dbd_verbose <=3)
+ if (DBIS->debug >= 5 || dbd_verbose >=5)
PerlIO_printf(DBILOGFP," fetch_cleanup_pres_lobs \n");
return;
@@ -2790,8 +2788,6 @@
/* else fall through and let rc trigger failure below */
}
- PerlIO_printf(DBILOGFP, " rc= %d\n", rc);
-
if (rc == 0 || /* the normal case*/
(fbh->pers_lob && rc == 1406 &&
DBIc_has(imp_sth,DBIcf_LongTruncOk))/*or a trunckated record when using 10.2
Persistent Lob interface*/
) {