Author: byterock
Date: Sun Mar 16 16:14:03 2008
New Revision: 10929

Modified:
   dbd-oracle/branches/scroll/Oracle.pm
   dbd-oracle/branches/scroll/Oracle.xs
   dbd-oracle/branches/scroll/dbdimp.c
   dbd-oracle/branches/scroll/dbdimp.h
   dbd-oracle/branches/scroll/oci8.c
   dbd-oracle/branches/scroll/ocitrace.h

Log:
changes for first part of scrolling cursor patch

Not this version needs 'stub fetch_scroll' patch to Dbi to work 

Modified: dbd-oracle/branches/scroll/Oracle.pm
==============================================================================
--- dbd-oracle/branches/scroll/Oracle.pm        (original)
+++ dbd-oracle/branches/scroll/Oracle.pm        Sun Mar 16 16:14:03 2008
@@ -855,6 +855,13 @@
 
 {   package DBD::Oracle::st; # ====== STATEMENT ======
 
+   sub fetch_scroll {
+       my $sth = shift;
+       my ($attr) = @_;
+
+        my $row = ora_fetch_scroll($sth,$attr);
+        return @$row;;
+   }
 
    sub bind_param_inout_array {
        my $sth = shift;
@@ -873,8 +880,7 @@
           
         $$hash_of_arrays{$p_id} = $value_array;
        return ora_bind_param_inout_array($sth, $p_id, $value_array,$maxlen, 
$attr);
-       1;
-       
+
     }
     
     

Modified: dbd-oracle/branches/scroll/Oracle.xs
==============================================================================
--- dbd-oracle/branches/scroll/Oracle.xs        (original)
+++ dbd-oracle/branches/scroll/Oracle.xs        Sun Mar 16 16:14:03 2008
@@ -32,7 +32,7 @@
     SQLCS_IMPLICIT = SQLCS_IMPLICIT
     SQLCS_NCHAR    = SQLCS_NCHAR
     SQLT_INT     = SQLT_INT
-    SQLT_FLT     = SQLT_FLT    
+    SQLT_FLT     = SQLT_FLT
     CODE:
     if (!ix) {
        if (!name) name = GvNAME(CvGV(cv));
@@ -77,6 +77,28 @@
 
 MODULE = DBD::Oracle    PACKAGE = DBD::Oracle::st
 
+
+void
+ora_fetch_scroll(sth,attribs)
+    SV *       sth
+    SV *       attribs
+    PREINIT:
+    CODE:
+    {
+    D_imp_sth(sth);
+    AV *av;
+    SV **svp;
+    int fetch_orient = OCI_FETCH_NEXT;
+    sb4 fetch_offset = 0;
+    DBD_ATTRIB_GET_IV(  attribs, "fetch_orient",12, svp, fetch_orient);
+    DBD_ATTRIB_GET_IV(  attribs, "fetch_offset",12, svp, fetch_offset);
+    imp_sth->fetch_orient=fetch_orient;
+    imp_sth->fetch_offset=fetch_offset;
+    PerlIO_printf(DBILOGFP, "    ora_fetch_scroll attribs  fetch_orient=%d and 
fetch_offset=%d\n", fetch_orient,fetch_offset);
+    av = dbd_st_fetch(sth,imp_sth);
+    ST(0) = (av) ? sv_2mortal(newRV((SV *)av)) : &PL_sv_undef;
+}
+
 void
 ora_bind_param_inout_array(sth, param, av_ref, maxlen, attribs)
     SV *       sth
@@ -110,7 +132,7 @@
     ST(0) = dbd_bind_ph(sth, imp_sth, param,av_value, sql_type, attribs, TRUE, 
maxlen)
                ? &sv_yes : &sv_no;
 }
-    
+
 void
 ora_fetch(sth)
     SV *       sth
@@ -227,7 +249,7 @@
         oci_error(dbh, imp_dbh->errhp, status, "OCILobCharSetForm");
        ST(0) = &sv_undef;
         return;
-    }    
+    }
 #ifdef OCI_ATTR_CHARSET_ID
     /* Effectively only used so AL32UTF8 works properly */
     OCILobCharSetId_log_stat( imp_dbh->envhp, imp_dbh->errhp, locator, &csid, 
status );
@@ -429,6 +451,6 @@
        dbd_init_oci(DBIS) ;
        dbd_init_oci_drh(imp_drh) ;
 
-    
 
-       
+
+

Modified: dbd-oracle/branches/scroll/dbdimp.c
==============================================================================
--- dbd-oracle/branches/scroll/dbdimp.c (original)
+++ dbd-oracle/branches/scroll/dbdimp.c Sun Mar 16 16:14:03 2008
@@ -2870,6 +2870,7 @@
        PerlIO_printf(DBILOGFP, "    dbd_st_execute %s (out%d, lob%d)...\n",
            oci_stmt_type_name(imp_sth->stmt_type), outparams, 
imp_sth->has_lobs);
 
+
     /* Don't attempt execute for nested cursor. It would be meaningless,
        and Oracle code has been seen to core dump */
     if (imp_sth->nested_cursor) {
@@ -2933,14 +2934,13 @@
                        }
        }
 
-       OCIStmtExecute_log_stat(imp_sth->svchp, imp_sth->stmhp, imp_sth->errhp,
+               OCIStmtExecute_log_stat(imp_sth->svchp, imp_sth->stmhp, 
imp_sth->errhp,
                        (ub4)(is_select ? 0 : 1),
                        0, 0, 0,
                        /* we don't AutoCommit on select so LOB locators work */
                        (ub4)((DBIc_has(imp_dbh,DBIcf_AutoCommit) && !is_select)
-                               ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT),
+                               ? OCI_COMMIT_ON_SUCCESS : 
OCI_STMT_SCROLLABLE_READONLY),
                        status);
-
                if (status != OCI_SUCCESS) { /* may be OCI_ERROR or 
OCI_SUCCESS_WITH_INFO etc */
        /* we record the error even for OCI_SUCCESS_WITH_INFO */
                        oci_error(sth, imp_sth->errhp, status, 
ora_sql_error(imp_sth,"OCIStmtExecute"));
@@ -3417,7 +3417,7 @@
        return 1;
 
     OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp, 0,
-               OCI_FETCH_NEXT, OCI_DEFAULT, status);
+       OCI_FETCH_NEXT,0,  status);
     if (status != OCI_SUCCESS && status != OCI_SUCCESS_WITH_INFO) {
        oci_error(sth, imp_sth->errhp, status, "Finish OCIStmtFetch");
        return 0;

Modified: dbd-oracle/branches/scroll/dbdimp.h
==============================================================================
--- dbd-oracle/branches/scroll/dbdimp.h (original)
+++ dbd-oracle/branches/scroll/dbdimp.h Sun Mar 16 16:14:03 2008
@@ -55,21 +55,21 @@
 typedef struct lob_refetch_st lob_refetch_t; /* Define sth implementor data 
structure */
 
 
-
+/*statement structure */
 struct imp_sth_st {
 
     dbih_stc_t com;            /* MUST be first element in structure   */
 
     void *(*get_oci_handle) _((imp_sth_t *imp_sth, int handle_type, int 
flags));
-    OCIEnv                      *envhp;        /* copy of dbh pointer  */
-    OCIError            *errhp;        /* copy of dbh pointer  */
-    OCIServer           *srvhp;        /* copy of dbh pointer  */
-    OCISvcCtx           *svchp;        /* copy of dbh pointer  */
-    OCIStmt                 *stmhp;    /* oci statement  handle */
-    OCIDescribe         *dschp;    /* oci describe handle */
-       ub2             stmt_type;      /* OCIAttrGet OCI_ATTR_STMT_TYPE        
*/
-    U16                        auto_lob;
-    int                has_lobs;  /* Statement has boud LOBS*/
+    OCIEnv                     *envhp; /* copy of dbh pointer  */
+    OCIError           *errhp; /* copy of dbh pointer  */
+    OCIServer          *srvhp; /* copy of dbh pointer  */
+    OCISvcCtx          *svchp; /* copy of dbh pointer  */
+    OCIStmt                    *stmhp; /* oci statement  handle */
+    OCIDescribe        *dschp; /* oci describe handle */
+       ub2                     stmt_type;      /* OCIAttrGet 
OCI_ATTR_STMT_TYPE        */
+    U16                                auto_lob;       /* use auto lobs*/
+    int                        has_lobs;   /* Statement has bound LOBS*/
 
     lob_refetch_t *lob_refetch;
     int                nested_cursor; /* cursors fetched from SELECTs */
@@ -98,7 +98,9 @@
     int        est_width;    /* est'd avg row width on-the-wire        */
     /* (In/)Out Parameter Details */
     bool               has_inout_params;
-
+    /* fetch scrooling values */
+    int                fetch_orient;
+    int                        fetch_offset;
 };
 #define IMP_STH_EXECUTING      0x0001
 

Modified: dbd-oracle/branches/scroll/oci8.c
==============================================================================
--- dbd-oracle/branches/scroll/oci8.c   (original)
+++ dbd-oracle/branches/scroll/oci8.c   Sun Mar 16 16:14:03 2008
@@ -334,13 +334,13 @@
 
     DBIc_IMPSET_on(imp_sth);
 
-    if (ora_check_sql) {
+ /*   if (ora_check_sql) {
        if (!dbd_describe(sth, imp_sth))
            return 0;
     }
     else {
       /* set initial cache size by memory */
-      /* [I'm not now sure why this is here - from a patch sometime ago - Tim] 
*/
+      /* [I'm not now sure why this is here - from a patch sometime ago - Tim]
       ub4 cache_mem;
       IV cache_mem_iv;
       D_imp_dbh_from_sth ;
@@ -359,7 +359,7 @@
         return 0;
       }
     }
-
+*/
     return 1;
 }
 
@@ -2336,6 +2336,21 @@
     return (num_errors>0) ? 0 : 1;
 }
 
+/*AV *
+ora_fetch_scroll(SV *sth, imp_sth_t *imp_sth,SV *attribs){
+       dTHX;
+    D_imp_dbh_from_sth;
+    AV *av;
+    SV **svp;
+    int fetch_orient = OCI_FETCH_NEXT;
+    sb4 fetch_offset = 0;
+    DBD_ATTRIB_GET_IV(  attribs, "fetch_orient",12, svp, fetch_orient);
+    DBD_ATTRIB_GET_IV(  attribs, "fetch_offset",12, svp, fetch_offset);
+    av = dbd_st_fetch(sth,imp_sth);
+    PerlIO_printf(DBILOGFP, "    ora_fetch_scroll attribs  fetch_orient=%d and 
fetch_offset=%d\n", fetch_orient,fetch_offset);
+    return (-1) ? Nullav : av;
+}
+*/
 
 AV *
 dbd_st_fetch(SV *sth, imp_sth_t *imp_sth){
@@ -2371,8 +2386,16 @@
        if (DBIS->debug >= 3){
                PerlIO_printf(DBILOGFP, "    dbd_st_fetch %d fields...\n", 
DBIc_NUM_FIELDS(imp_sth));
            }
+        if (imp_sth->fetch_orient) {
+                       PerlIO_printf(DBILOGFP, "    dbd_st_fetch 
imp_sth->fetch_orient = %d,imp_sth->fetch_offset= 
%d...\n",imp_sth->fetch_orient,imp_sth->fetch_offset);
 
-               OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp,1, 
(ub2)OCI_FETCH_NEXT, OCI_DEFAULT, status);
+                       OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp,1, 
imp_sth->fetch_orient,imp_sth->fetch_offset, status);
+                                       PerlIO_printf(DBILOGFP, " 
OCI_FETCH_LAST=%d  status = %d,..\n",OCI_FETCH_LAST,status);
+
+               } else {
+                       OCIStmtFetch_log_stat(imp_sth->stmhp, imp_sth->errhp,1, 
(ub2)OCI_FETCH_NEXT, 0, status);
+
+               }
 
     }
 
@@ -2969,10 +2992,9 @@
                return oci_error(sth, errhp, status, "OCIAttrGet OCI_ATTR_ROWID 
/LOB refetch");
 
 
-
-    OCIStmtExecute_log_stat(imp_sth->svchp, lr->stmthp, errhp,
+               OCIStmtExecute_log_stat(imp_sth->svchp, lr->stmthp, errhp,
                1, 0, NULL, NULL, OCI_DEFAULT, status); /* execute and fetch */
-    if (status != OCI_SUCCESS)
+       if (status != OCI_SUCCESS)
        return oci_error(sth, errhp, status,
                ora_sql_error(imp_sth,"OCIStmtExecute/LOB refetch"));
 

Modified: dbd-oracle/branches/scroll/ocitrace.h
==============================================================================
--- dbd-oracle/branches/scroll/ocitrace.h       (original)
+++ dbd-oracle/branches/scroll/ocitrace.h       Sun Mar 16 16:14:03 2008
@@ -440,18 +440,18 @@
          ul_t((ro)),(void*)(si),(void*)(so),ul_t((md)),                \
          oci_status_name(stat)),stat : stat
 #if !defined(USE_ORA_OCI_STMNT_FETCH)
- #define OCIStmtFetch_log_stat(sh,eh,nr,or,md,stat)                     \
-         stat=OCIStmtFetch2(sh,eh,nr,or,0,md);                                \
+ #define OCIStmtFetch_log_stat(sh,eh,nr,or,os,stat)                     \
+         stat=OCIStmtFetch2(sh,eh,nr,or,os,OCI_DEFAULT);                       
         \
          (DBD_OCI_TRACEON) ? PerlIO_printf(DBD_OCI_TRACEFP,                    
    \
            "%sStmtFetch(%p,%p,%lu,%u,%lu)=%s\n",                               
 \
-           OciTp, (void*)sh,(void*)eh,ul_t(nr),(ub2)or,ul_t(md),               
 \
+           OciTp, (void*)sh,(void*)eh,ul_t(nr),(ub2)or,(ub2)os,                
\
            oci_status_name(stat)),stat : stat
 #else
-#define OCIStmtFetch_log_stat(sh,eh,nr,or,md,stat)                     \
-        stat=OCIStmtFetch(sh,eh,nr,or,md);                                \
+#define OCIStmtFetch_log_stat(sh,eh,nr,or,os,stat)                     \
+        stat=OCIStmtFetch(sh,eh,nr,or,OCI_DEFAULT);                            
    \
         (DBD_OCI_TRACEON) ? PerlIO_printf(DBD_OCI_TRACEFP,                     
   \
-          "%sStmtFetch(%p,%p,%lu,%u,%lu)=%s\n",                                
\
-          OciTp, (void*)sh,(void*)eh,ul_t(nr),(ub2)or,ul_t(md),                
\
+          "%sStmtFetch(%p,%p,%lu,%lu)=%s\n",                                \
+          OciTp, (void*)sh,(void*)eh,ul_t(nr),(ub2)or,                \
           oci_status_name(stat)),stat : stat
 #endif
 

Reply via email to