Author: byterock
Date: Thu Jul 16 12:00:52 2009
New Revision: 13069
Modified:
dbd-oracle/branches/rs_array/dbdimp.c
dbd-oracle/branches/rs_array/dbdimp.h
dbd-oracle/branches/rs_array/oci8.c
Log:
working version
Modified: dbd-oracle/branches/rs_array/dbdimp.c
==============================================================================
--- dbd-oracle/branches/rs_array/dbdimp.c (original)
+++ dbd-oracle/branches/rs_array/dbdimp.c Thu Jul 16 12:00:52 2009
@@ -2956,6 +2956,7 @@
dTHR;
dTHX;
int row_count = 0;
+ int ext_fetch = 1;
int debug = DBIS->debug;
int outparams = (imp_sth->out_params_av) ?
AvFILL(imp_sth->out_params_av)+1 : 0;
D_imp_dbh_from_sth;
@@ -2993,86 +2994,121 @@
if (!phs->out_prepost_exec(sth, imp_sth, phs,
1))
return -2; /* out_prepost_exec already
called ora_error() */
}
- else
- if (SvTYPE(sv) == SVt_RV && SvTYPE(SvRV(sv)) ==
SVt_PVAV) {
- if (debug >= 2 || dbd_verbose >= 3 )
- PerlIO_printf(DBILOGFP,
- " with %s = [] (len %ld/%ld,
indp %d, otype %d, ptype %d)\n",
- phs->name,
- (long)phs->alen, (long)phs->maxlen, phs->indp,
- phs->ftype, (int)SvTYPE(sv));
- av_clear((AV*)SvRV(sv));
- }
- else
- /* Some checks for mutated storage since we pointed oracle at
it. */
- if (SvTYPE(sv) != phs->sv_type
- || (SvOK(sv) && !SvPOK(sv))
- /* SvROK==!SvPOK so cursor (SQLT_CUR) handle will call
dbd_rebind_ph */
- /* that suits us for now */
- || SvPVX(sv) != phs->progv
- || (SvPOK(sv) && SvCUR(sv) > UB2MAXVAL)
- ) {
- if (!dbd_rebind_ph(sth, imp_sth, phs))
- croak("Can't rebind placeholder %s",
phs->name);
- }
- else {
- /* String may have grown or shrunk
since it was bound */
- /* so tell Oracle about it's current
length */
- ub2 prev_alen = phs->alen;
- phs->alen = (SvOK(sv)) ? SvCUR(sv) +
phs->alen_incnull : 0+phs->alen_incnull;
+ else {
+ if (SvTYPE(sv) == SVt_RV && SvTYPE(SvRV(sv)) ==
SVt_PVAV) {
if (debug >= 2 || dbd_verbose >= 3 )
PerlIO_printf(DBILOGFP,
- " with %s = '%.*s' (len
%ld(%ld)/%ld, indp %d, otype %d, ptype %d)\n",
- phs->name,
(int)phs->alen,
- (phs->indp == -1) ? "" :
SvPVX(sv),
- (long)phs->alen,
(long)prev_alen, (long)phs->maxlen, phs->indp,
- phs->ftype, (int)SvTYPE(sv));
+ " with %s = [] (len
%ld/%ld, indp %d, otype %d, ptype %d)\n",
+ phs->name,
+ (long)phs->alen,
(long)phs->maxlen, phs->indp,
+ phs->ftype,
(int)SvTYPE(sv));
+
+ av_clear((AV*)SvRV(sv));
+ }
+ else {
+ /* Some checks for mutated storage since we pointed oracle at
it. */
+ if (SvTYPE(sv) != phs->sv_type
+ || (SvOK(sv) && !SvPOK(sv))
+ /* SvROK==!SvPOK so cursor (SQLT_CUR) handle will call
dbd_rebind_ph */
+ /* that suits us for now */
+ || SvPVX(sv) != phs->progv
+ || (SvPOK(sv) && SvCUR(sv) > UB2MAXVAL)
+ ) {
+ if (!dbd_rebind_ph(sth,
imp_sth, phs))
+ croak("Can't rebind
placeholder %s", phs->name);
+ }
+ else {
+ /* String may have grown or
shrunk since it was bound */
+ /* so tell Oracle about it's
current length */
+ ub2 prev_alen =
phs->alen;
+ phs->alen = (SvOK(sv))
? SvCUR(sv) + phs->alen_incnull : 0+phs->alen_incnull;
+ if (debug >= 2 ||
dbd_verbose >= 3 )
+
PerlIO_printf(DBILOGFP,
+ " with %s =
'%.*s' (len %ld(%ld)/%ld, indp %d, otype %d, ptype %d)\n",
+ phs->name,
(int)phs->alen,
+ (phs->indp ==
-1) ? "" : SvPVX(sv),
+
(long)phs->alen, (long)prev_alen, (long)phs->maxlen, phs->indp,
+ phs->ftype,
(int)SvTYPE(sv));
+ }
}
}
}
+ }
- if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && !is_select) {
- imp_sth->exe_mode=OCI_COMMIT_ON_SUCCESS;
- /* we don't AutoCommit on select so LOB locators work */
- } else if(imp_sth->exe_mode!=OCI_STMT_SCROLLABLE_READONLY){
+ if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && !is_select) {
+ imp_sth->exe_mode=OCI_COMMIT_ON_SUCCESS;
+ /* we don't AutoCommit on select so LOB locators work */
+ }
+ else if(imp_sth->exe_mode!=OCI_STMT_SCROLLABLE_READONLY){
+ imp_sth->exe_mode=OCI_DEFAULT;
+ }
- imp_sth->exe_mode=OCI_DEFAULT;
- }
+ if (debug >= 2 || dbd_verbose >= 3 )
+ PerlIO_printf(DBILOGFP,"Statement Execute Mode is %d
(%s)\n",imp_sth->exe_mode,oci_exe_mode(imp_sth->exe_mode));
- if (debug >= 2 || dbd_verbose >= 3 )
- PerlIO_printf(DBILOGFP,"Statement Execute Mode is %d
(%s)\n",imp_sth->exe_mode,oci_exe_mode(imp_sth->exe_mode));
- OCIStmtExecute_log_stat(imp_sth->svchp, imp_sth->stmhp,
imp_sth->errhp,
- (ub4)(is_select ? (
imp_sth->row_cache_off ? 0 : imp_sth->rs_array_size) : 1),
- 0, 0, 0,(ub4)imp_sth->exe_mode,status);
+ if (is_select) {
+
+ if ((imp_sth->exe_mode!=OCI_STMT_SCROLLABLE_READONLY) &&
(!imp_sth->row_cache_off)){
+ ext_fetch=imp_sth->rs_array_size;
+ }
+ else{
+ ext_fetch=0;
+ }
+ }
+ OCIStmtExecute_log_stat(imp_sth->svchp, imp_sth->stmhp, imp_sth->errhp,
+ (ub4)ext_fetch,
+ 0, 0, 0,(ub4)imp_sth->exe_mode,status);
- if (status != OCI_SUCCESS){
+ /* may be OCI_ERROR or OCI_SUCCESS_WITH_INFO etc */
+ /* but OCI_NO_DATA with a select means the exe got all the rows in 1
shot (a warning really according to oralce )
+ /* we record the error even for OCI_SUCCESS_WITH_INFO */
+
+
+ switch (status) {
+
+ case OCI_SUCCESS: /*normal case */
+ if (debug >= 2 || dbd_verbose >= 3 )
+ PerlIO_printf(DBILOGFP,"Statement Executed
Succesfully!!\n");
+ break;
+
+ case OCI_NO_DATA: /* selected all the rows at exe*/
+
+ if (imp_sth->row_cache_off && is_select){ /*row cache
was off and was is_select so is this an error? */
+ oci_error(sth, imp_sth->errhp, status,
ora_sql_error(imp_sth,"OCIStmtExecute"));
+ }
+ break;
+
+ case OCI_SUCCESS_WITH_INFO:/* something wrong but I still
worked */
- if ((status != OCI_NO_DATA) && (imp_sth->row_cache_off)
&& (is_select)) {
- /* may be OCI_ERROR or OCI_SUCCESS_WITH_INFO etc */
- /* but OCI_NO_DATA with a select means the exe got all the rows
in 1 shot (a warning really according to oralce )
- /* we record the error even for
OCI_SUCCESS_WITH_INFO */
+ if (imp_sth->ret_long || imp_sth->ret_lobs) {
+ if (!DBIcf_LongTruncOk) {
+ oci_error(sth, imp_sth->errhp, status,
ora_sql_error(imp_sth,"OCIStmtExecute"));
+ }
+ }
+ else {
oci_error(sth, imp_sth->errhp, status,
ora_sql_error(imp_sth,"OCIStmtExecute"));
- /* but only bail out here if not
OCI_SUCCESS_WITH_INFO */
- if (status != OCI_SUCCESS_WITH_INFO)
- return -2;
}
- }
-
-
- /* Can do this here as it does not do a server round trip */
+ break;
+ default: /* really something wrong */
- OCIAttrGet_stmhp_stat(imp_sth, &row_count,0,OCI_ATTR_ROW_COUNT,
status);
+ oci_error(sth, imp_sth->errhp, status,
ora_sql_error(imp_sth,"OCIStmtExecute"));
+ return -2;
+ break;
+ }
+ /* Can do this here as it does not do a server round trip */
+
+ OCIAttrGet_stmhp_stat(imp_sth, &row_count,0,OCI_ATTR_ROW_COUNT, status);
if (is_select) { /*only need this on a select*/
DBIc_ACTIVE_on(imp_sth);
DBIc_ROW_COUNT(imp_sth) = row_count;
- if (!imp_sth->row_cache_off){
+ if (!imp_sth->row_cache_off &&
(imp_sth->exe_mode!=OCI_STMT_SCROLLABLE_READONLY)){
/*reinit the rs_array as well if we have to
as we may have more than one exe on a prepare*/
imp_sth->rs_fetch_count = 1;
Modified: dbd-oracle/branches/rs_array/dbdimp.h
==============================================================================
--- dbd-oracle/branches/rs_array/dbdimp.h (original)
+++ dbd-oracle/branches/rs_array/dbdimp.h Thu Jul 16 12:00:52 2009
@@ -79,6 +79,7 @@
ub4 piece_size; /*used in callback to
set the size of the piece to get*/
int has_lobs; /*Statement has bound
LOBS */
int ret_lobs; /*Statement returns
LOBS */
+ bool ret_long; /* Statement returns a Long */
lob_refetch_t *lob_refetch;
int nested_cursor; /* cursors fetched from
SELECTs */
AV *bind_tuples; /* Bind tuples in array
execute, or NULL */
Modified: dbd-oracle/branches/rs_array/oci8.c
==============================================================================
--- dbd-oracle/branches/rs_array/oci8.c (original)
+++ dbd-oracle/branches/rs_array/oci8.c Thu Jul 16 12:00:52 2009
@@ -981,7 +981,7 @@
OCIAttrGet_stmhp_stat(imp_sth, &imp_sth->stmt_type, 0,
OCI_ATTR_STMT_TYPE, status);
if (DBIS->debug >= 3 || dbd_verbose >= 3 )
- PerlIO_printf(DBILOGFP, " dbd_st_prepare'd sql %s (pl%d,
auto_lob%d, check_sql%d)\n",
+ PerlIO_printf(DBILOGFP, " dbd_st_prepare'd sql %s (pl%d,
auto_lob%d, check_sql%d)\n",
oci_stmt_type_name(imp_sth->stmt_type),
oparse_lng, imp_sth->auto_lob, ora_check_sql);
@@ -3222,17 +3222,17 @@
fbh->ftype = 94; /* VAR form */
fbh->fetch_func = fetch_func_varfield;
++has_longs;
-
+ imp_sth->ret_long=1;
}
break;
case ORA_LONGRAW: /* LONG
RAW */
if (imp_sth->clbk_lob){ /*get by peice with
callback a slow*/
- fbh->clbk_lob = 1;
+ fbh->clbk_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*/
+ 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;
@@ -3244,7 +3244,7 @@
}
else if (imp_sth->piece_lob){ /*get by peice
with polling slowest*/
- fbh->piece_lob = 1;
+ 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*/
@@ -3262,6 +3262,7 @@
fbh->ftype = 95; /* VAR form */
fbh->fetch_func = fetch_func_varfield;
++has_longs;
+ imp_sth->ret_long=1;
}
break;
@@ -3567,13 +3568,20 @@
if (DBIS->debug >= 4 || dbd_verbose >= 4 )
PerlIO_printf(DBILOGFP," Scrolling
Fetch, postion before fetch=%d, Orientation = %s , Fetchoffset =%d\n",
-
imp_sth->fetch_position,oci_fetch_options(imp_sth->fetch_orient),imp_sth->fetch_offset);
+
imp_sth->fetch_position,oci_fetch_options(imp_sth->fetch_orient),imp_sth->fetch_offset);
+
OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp,1,
imp_sth->fetch_orient,imp_sth->fetch_offset, status);
- /*this will work without a round trip so might
as well open it up for all statments handles*/
- /* defualt and OCI_FETCH_NEXT are the same so
this avoids miscaluation on the next value*/
+ if (status == OCI_NO_DATA)
+ status = OCI_SUCCESS;
+
+
+ /*this will work without a round trip so might as well
open it up for all statments handles*/
+ /* defualt and OCI_FETCH_NEXT are the same so this
avoids miscaluation on the next value*/
OCIAttrGet_stmhp_stat(imp_sth,
&imp_sth->fetch_position, 0, OCI_ATTR_CURRENT_POSITION, status);
-
+ if (status == OCI_NO_DATA)
+ status = OCI_SUCCESS;
+
if (DBIS->debug >= 4 || dbd_verbose >= 4 )
PerlIO_printf(DBILOGFP," Scrolling
Fetch, postion after fetch=%d\n",imp_sth->fetch_position);
@@ -3684,7 +3692,8 @@
/* else fall through and let rc trigger failure below */
}
- if (rc == 0 || /* the normal case*/
+ if (rc == 0 || /* the normal case*/
+ rc == 35 || /* in case it is a scroll fetch?? */
(rc == 1406 &&
DBIc_has(imp_sth,DBIcf_LongTruncOk))/*Field Truncaded*/) {
if (fbh->fetch_func) {