Author: byterock
Date: Wed Jun 25 09:50:20 2008
New Revision: 11458
Modified:
dbd-oracle/branches/lob_piece/dbdimp.c
dbd-oracle/branches/lob_piece/oci8.c
Log:
working example
Modified: dbd-oracle/branches/lob_piece/dbdimp.c
==============================================================================
--- dbd-oracle/branches/lob_piece/dbdimp.c (original)
+++ dbd-oracle/branches/lob_piece/dbdimp.c Wed Jun 25 09:50:20 2008
@@ -307,7 +307,7 @@
Newz(42, fb_ary->arlen, (unsigned)size, ub2);
Newz(42, fb_ary->arcode, (unsigned)size, ub2);
fb_ary->bufl = bufl;
- fb_ary->cb_bufl = bufl;
+ /* fb_ary->cb_bufl = bufl;*/
return fb_ary;
}
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 09:50:20 2008
@@ -1764,6 +1764,11 @@
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];
ub1 piece = OCI_FIRST_PIECE;
@@ -1773,33 +1778,59 @@
sb2 indptr = 0;
ub2 rcode = 0;
sword status = OCI_NEED_DATA;
- fb_ary_t *fb_ary = fbh->fb_ary;
- ub1* row_data=&fb_ary->abuf[0]+(fb_ary->bufl*fbh->imp_sth->rs_array_idx);
- text buf[15000];
- ub4 buflen=5000;
+ /* 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 Binaray
lob with piecewise fetch row_data =%d\n",buflen);
- }
- PerlIO_printf(DBILOGFP, "status=%d\n",status);
-dbd_verbose=6;
+ /*if (DBIS->debug <= 4 || dbd_verbose <= 4) {
+ PerlIO_printf(DBILOGFP, " getting an Presistant
=%d\n",buflen);
+ }*/
+
while (status == OCI_NEED_DATA){
OCIStmtGetPieceInfo(fbh->imp_sth->stmhp,
fbh->imp_sth->errhp,
&hdlptr, &hdltype,
&in_out, &iter, &idx, &piece);
+
OCIStmtSetPieceInfo((dvoid *)hdlptr, (ub4)hdltype,
-
fbh->imp_sth->errhp, (dvoid *) &buf, &buflen, piece,
+
fbh->imp_sth->errhp, (dvoid *) fb_ary->abuf, &buflen, piece,
(dvoid *)&indptr, &rcode);
- sv_catpv(dest_sv, buf);
+
+
+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, "status2 =%d\n",status);
+PerlIO_printf(DBILOGFP, "status=%d\n",status);
+
+ if (status){
+
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);
+
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
);*/
+
+
+ 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;
}
@@ -1868,7 +1899,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 <= 3 || dbd_verbose <=3)
PerlIO_printf(DBILOGFP," fetch_cleanup_pres_lobs \n");
return;
@@ -2429,7 +2460,7 @@
fbh->define_mode = OCI_DYNAMIC_FETCH;
/* piecwise fetch*/
fbh->disize =
imp_sth->long_readlen; /*user set max value for the fetch*/
fbh->piece_size =
imp_sth->piece_size; /*the size for each piece*/
- /*fbh->fetch_cleanup =
fetch_cleanup_pres_lobs; /* clean up buffer before each fetch*/
+ fbh->fetch_cleanup =
fetch_cleanup_pres_lobs; /* clean up buffer before each fetch*/
if (!imp_sth->piece_size){ /*if not set
use max value*/
imp_sth->piece_size=imp_sth->long_readlen;
@@ -2529,7 +2560,7 @@
sb4 define_len = (ftype==94||ftype==95) ? fbh->disize+4 :
fbh->disize;
fb_ary_t *fb_ary;
- if (fbh->pers_lob){/*init the cb_abuf with this call*/
+ if (fbh->pers_lob || fbh->piece_lob ){/*init the cb_abuf with
this call*/
fbh->fb_ary =
fb_ary_cb_alloc(imp_sth->piece_size,define_len, imp_sth->rs_array_size);
} else {
@@ -2553,7 +2584,7 @@
&fbh->defnp,
imp_sth->errhp,
(ub4) i,
- (fbh->desc_h) ? (dvoid*)&fbh->desc_h : fbh->pers_lob ?
(dvoid *) 0: (dvoid*)fb_ary->abuf,
+ (fbh->desc_h) ? (dvoid*)&fbh->desc_h : fbh->pers_lob ?
(dvoid *) 0: fbh->piece_lob ? (dvoid *) 0:(dvoid*)fb_ary->abuf,
(fbh->desc_h) ? 0 : define_len,
(ub2)fbh->ftype,
fb_ary->aindp,
@@ -2562,7 +2593,7 @@
fbh->define_mode,
status);
- if ((fbh->pers_lob) || (fbh->piece_lob)){
+ if (fbh->pers_lob){
/* use a dynamic callback for persistent
binary and char lobs*/
OCIDefineDynamic_log_stat(fbh->defnp,imp_sth->errhp,(dvoid *) fbh,status);
@@ -2647,13 +2678,11 @@
"no statement executing (perhaps you need to call execute first)");
return Nullav;
}
- PerlIO_printf(DBILOGFP, " hew 1 \n");
for(i=0; i < num_fields; ++i) {
imp_fbh_t *fbh = &imp_sth->fbh[i];
if (fbh->fetch_cleanup) fbh->fetch_cleanup(sth, fbh);
}
- PerlIO_printf(DBILOGFP, " hew 2\n");
if (ora_fetchtest && DBIc_ROW_COUNT(imp_sth)>0) {
@@ -2685,7 +2714,6 @@
} else {
- PerlIO_printf(DBILOGFP, " hew 3\n");
if (imp_sth->rs_array_on) { /* if array fetch on,
fetch only if not in cache */
imp_sth->rs_array_idx++;
@@ -2700,15 +2728,12 @@
else
status=imp_sth->rs_array_status;
} else {
-
PerlIO_printf(DBILOGFP, " hew 4\n");
OCIStmtFetch_log_stat(imp_sth->stmhp,
imp_sth->errhp,1,(ub2)OCI_FETCH_NEXT, OCI_DEFAULT, status);
- PerlIO_printf(DBILOGFP, " hew 5\n");
imp_sth->rs_array_idx=0;
}
}
}
- PerlIO_printf(DBILOGFP, " hew 1 \n");
if (status != OCI_SUCCESS && status !=OCI_NEED_DATA) {
ora_fetchtest = 0;
@@ -2771,7 +2796,6 @@
(fbh->pers_lob && rc == 1406 &&
DBIc_has(imp_sth,DBIcf_LongTruncOk))/*or a trunckated record when using 10.2
Persistent Lob interface*/
) {
if (fbh->fetch_func) {
- PerlIO_printf(DBILOGFP, " fetch_func doit\n");
if (!fbh->fetch_func(sth, fbh, sv)){
++err; /* fetch_func already called
oci_error */