Author: byterock
Date: Tue Jun 24 11:33:22 2008
New Revision: 11454
Modified:
dbd-oracle/branches/lob_piece/dbdimp.h
dbd-oracle/branches/lob_piece/oci8.c
Log:
first shot at it not really working but close
Modified: dbd-oracle/branches/lob_piece/dbdimp.h
==============================================================================
--- dbd-oracle/branches/lob_piece/dbdimp.h (original)
+++ dbd-oracle/branches/lob_piece/dbdimp.h Tue Jun 24 11:33:22 2008
@@ -72,6 +72,7 @@
ub2 stmt_type; /* OCIAttrGet
OCI_ATTR_STMT_TYPE */
U16 auto_lob; /* use auto lobs*/
int pers_lob; /*use dblink for lobs only
for 10g Release 2. or later*/
+ int piece_lob; /*use piece fetch for lobs*/
ub4 piece_size; /*used in callback to set
the size of the piece to get*/
int has_lobs; /* Statement has bound LOBS*/
@@ -184,7 +185,7 @@
char *bless; /* for Oracle::OCI style handle data */
void *special; /* hook for special purposes (LOBs etc)
*/
int pers_lob; /*for persistant lobs 10g Release
2. or later*/
-
+ int piece_lob; /*use piecewise fetch for lobs*/
/* Our storage space for the field data as it's fetched */
sword ftype; /* external datatype we wish to get */
fb_ary_t *fb_ary ; /* field buffer array */
Modified: dbd-oracle/branches/lob_piece/oci8.c
==============================================================================
--- dbd-oracle/branches/lob_piece/oci8.c (original)
+++ dbd-oracle/branches/lob_piece/oci8.c Tue Jun 24 11:33:22 2008
@@ -322,6 +322,7 @@
sword status = 0;
IV ora_piece_size = 0; /*used only for persistent lobs with 10g Release
2. or later*/
IV ora_pers_lob = 0; /*used only for persistent lobs with 10g Release
2. or later*/
+ IV ora_piece_lob = 0;
ub4 oparse_lng = 1; /* auto v6 or v7 as suits db connected
to */
int ora_check_sql = 1; /* to force a describe to check SQL */
IV ora_placeholders = 1; /* find and handle placeholders */
@@ -360,10 +361,12 @@
DBD_ATTRIB_GET_IV( attribs, "ora_placeholders", 16, svp,
ora_placeholders);
DBD_ATTRIB_GET_IV( attribs, "ora_auto_lob", 12, svp,
ora_auto_lob);
DBD_ATTRIB_GET_IV( attribs, "ora_pers_lob", 12, svp,
ora_pers_lob);
- DBD_ATTRIB_GET_IV( attribs, "ora_piece_size", 14, svp,
ora_piece_size);
+ DBD_ATTRIB_GET_IV( attribs, "ora_piece_lob", 13, svp,
ora_piece_lob);
+ DBD_ATTRIB_GET_IV( attribs, "ora_piece_size", 14, svp,
ora_piece_size);
imp_sth->auto_lob = (ora_auto_lob) ? 1 : 0;
imp_sth->pers_lob = (ora_pers_lob) ? 1 : 0;
+ imp_sth->piece_lob = (ora_piece_lob) ? 1 : 0;
imp_sth->piece_size = (ora_piece_size) ? ora_piece_size : 0;
/* ora_check_sql only works for selects owing to Oracle
behaviour */
DBD_ATTRIB_GET_IV( attribs, "ora_check_sql", 13, svp,
ora_check_sql);
@@ -616,6 +619,10 @@
*indpp = (dvoid *) fb_ary->aindp;
*rcpp = fb_ary->arcode;
+
+ if (dbd_verbose <= 4) {
+ PerlIO_printf(DBILOGFP, " presist_lob_fetch_cbk\n");
+ }
if ( *piecep ==OCI_NEXT_PIECE ){/*more than one piece*/
memcpy(fb_ary->cb_abuf+fb_ary->piece_count*fb_ary->bufl,fb_ary->abuf,fb_ary->bufl
);
@@ -1753,8 +1760,8 @@
/*static int This is another way to do the callback using set and get piece not
-used right now.
-fetch_presis_binary(SV *sth, imp_fbh_t *fbh,SV *dest_sv){
+used right now.*/
+fetch_get_piece(SV *sth, imp_fbh_t *fbh,SV *dest_sv){
dTHX;
ub4 alen = fbh->disize;
@@ -1768,31 +1775,36 @@
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;
- if (DBIS->debug <= 4) {
- PerlIO_printf(DBILOGFP, " getting an Presistant Binaray
lob with picewise fetch row_data =%d\n",row_data);
+
+ 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;
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 *) &row_data, &alen, piece,
+
fbh->imp_sth->errhp, (dvoid *) &buf, &buflen, piece,
(dvoid *)&indptr, &rcode);
- sv_catpv(dest_sv, row_data);
+
+ sv_catpv(dest_sv, buf);
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);
+ PerlIO_printf(DBILOGFP, "status2 =%d\n",status);
}
+ dbd_verbose=0;
return 1;
}
-*/
+
int
empty_oci_object(fbh_obj_t *obj){
dTHX;
@@ -2412,6 +2424,22 @@
fbh->ftype = SQLT_BIN; /*other Binary*/
}
+ } else if (imp_sth->piece_lob){
+ fbh->piece_lob = 1;
+ 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*/
+
+ if (!imp_sth->piece_size){ /*if not set
use max value*/
+
imp_sth->piece_size=imp_sth->long_readlen;
+ }
+ if (fbh->dbtype == 112){
+ fbh->ftype = SQLT_CHR;
+ } else {
+ fbh->ftype = SQLT_BIN; /*other
Binary*/
+ }
+ fbh->fetch_func = fetch_get_piece;
} else {
fbh->disize = fbh->dbsize *10 ; /* XXX!
*/
@@ -2534,7 +2562,7 @@
fbh->define_mode,
status);
- if (fbh->pers_lob) {
+ if ((fbh->pers_lob) || (fbh->piece_lob)){
/* use a dynamic callback for persistent
binary and char lobs*/
OCIDefineDynamic_log_stat(fbh->defnp,imp_sth->errhp,(dvoid *) fbh,status);
@@ -2609,6 +2637,7 @@
int i;
AV *av;
+
/* Check that execute() was executed sucessfully. This also implies
*/
/* that dbd_describe() executed sucessfuly so the memory buffers */
/* are allocated and bound.
*/
@@ -2618,11 +2647,13 @@
"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) {
@@ -2653,6 +2684,9 @@
PerlIO_printf(DBILOGFP," Scrolling Fetch,
postion after fetch=%d\n",imp_sth->fetch_position);
} 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++;
if
(imp_sth->rs_array_num_rows<=imp_sth->rs_array_idx &&
imp_sth->rs_array_status==OCI_SUCCESS) {
@@ -2666,11 +2700,15 @@
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;
@@ -2727,11 +2765,13 @@
/* 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*/
) {
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 */