Author: byterock
Date: Fri Jul 18 10:08:29 2008
New Revision: 11539

Modified:
   dbd-oracle/trunk/Changes
   dbd-oracle/trunk/dbdimp.c
   dbd-oracle/trunk/oci8.c

Log:
 Fix for bug reported on SPs with Lobs reported by Martin Evans, Fix by J Scoles


Modified: dbd-oracle/trunk/Changes
==============================================================================
--- dbd-oracle/trunk/Changes    (original)
+++ dbd-oracle/trunk/Changes    Fri Jul 18 10:08:29 2008
@@ -1,4 +1,5 @@
 =head1 Changes in DBD-Oracle 1.22(svn rev xxxx)  2008 
+  Fix for bug reported on SPs with Lobs reported by Martin Evans, Fix by J 
Scoles
   Changed the way Ping works rather than using prepare and execute it now 
makes a single round trip call to DB by John Scoles
   Fix for rt.cpan.org Ticket #=37501 fail HP-UX Itanium 11.31 makefile also 
added the OS and version to the output of the Makefile.PL for easier debugging. 
from John Scoles and Rich Roemer 
   Added a number of internal functions for decoding OCI debug values from John 
Scoles

Modified: dbd-oracle/trunk/dbdimp.c
==============================================================================
--- dbd-oracle/trunk/dbdimp.c   (original)
+++ dbd-oracle/trunk/dbdimp.c   Fri Jul 18 10:08:29 2008
@@ -2285,7 +2285,7 @@
     sword status;
 
     if (DBIS->debug >= 3 || dbd_verbose >=3)
-       PerlIO_printf(DBILOGFP, "    pp_rebind_ph_rset_in: BEGIN\n    calling 
OCIBindByName(stmhp=%p, bndhp=%p, errhp=%p, name=%s, csrstmhp=%p, ftype=%d)\n", 
imp_sth->stmhp, phs->bndhp, imp_sth->errhp, phs->name, imp_sth_csr->stmhp, 
phs->ftype);
+               PerlIO_printf(DBILOGFP, "    pp_rebind_ph_rset_in: BEGIN\n    
calling OCIBindByName(stmhp=%p, bndhp=%p, errhp=%p, name=%s, csrstmhp=%p, 
ftype=%d)\n", imp_sth->stmhp, phs->bndhp, imp_sth->errhp, phs->name, 
imp_sth_csr->stmhp, phs->ftype);
 
     OCIBindByName_log_stat(imp_sth->stmhp, &phs->bndhp, imp_sth->errhp,
                           (text*)phs->name, (sb4)strlen(phs->name),
@@ -2298,12 +2298,15 @@
                           (ub4)OCI_DEFAULT,
                           status
                           );
-    if (status != OCI_SUCCESS) {
+ 
+       if (status != OCI_SUCCESS) {
       oci_error(sth, imp_sth->errhp, status, "OCIBindByName SQLT_RSET");
       return 0;
     }
-    if (DBIS->debug >= 3 || dbd_verbose >=3)
-       PerlIO_printf(DBILOGFP, "    pp_rebind_ph_rset_in: END\n");
+ 
+       if (DBIS->debug >= 3 || dbd_verbose >=3)
+               PerlIO_printf(DBILOGFP, "    pp_rebind_ph_rset_in: END\n");
+               
     return 2;
 }
 
@@ -2320,7 +2323,8 @@
        sword status;
 
        if (DBIS->debug >= 3 || dbd_verbose >=3)
-           PerlIO_printf(DBILOGFP, "       bind %s - allocating new sth...\n", 
phs->name);
+           PerlIO_printf(DBILOGFP, " pp_exec_rset bind %s - allocating new 
sth...\n", phs->name);
+
 
        /* extproc deallocates everything for us */
        if (is_extproc)
@@ -2334,8 +2338,11 @@
            phs->desc_t = OCI_HTYPE_STMT;
            OCIHandleAlloc_ok(imp_sth->envhp, &phs->desc_h, phs->desc_t, 
status);
        }
+       
+       
        phs->progv = (char*)&phs->desc_h;
        phs->maxlen = 0;
+       
        OCIBindByName_log_stat(imp_sth->stmhp, &phs->bndhp, imp_sth->errhp,
                (text*)phs->name, (sb4)strlen(phs->name),
                phs->progv, 0,
@@ -2362,7 +2369,7 @@
        FREETMPS;
        LEAVE;
        if (DBIS->debug >= 3 || dbd_verbose >=3)
-           PerlIO_printf(DBILOGFP, "       bind %s - allocated %s...\n",
+           PerlIO_printf(DBILOGFP, "   pp_exec_rset   bind %s - allocated 
%s...\n",
                phs->name, neatsvpv(phs->sv, 0));
 
     }
@@ -2375,12 +2382,18 @@
            PerlIO_printf(DBILOGFP, "       bind %s - initialising new %s for 
cursor 0x%lx...\n",
                phs->name, neatsvpv(sth_csr,0), (unsigned long)phs->progv);
 
-       /* copy appropriate handles from parent statement       */
-       imp_sth_csr->envhp = imp_sth->envhp;
-       imp_sth_csr->errhp = imp_sth->errhp;
-       imp_sth_csr->srvhp = imp_sth->srvhp;
-       imp_sth_csr->svchp = imp_sth->svchp;
+       /* copy appropriate handles and atributes from parent statement */
+       imp_sth_csr->envhp      = imp_sth->envhp;
+       imp_sth_csr->errhp      = imp_sth->errhp;
+       imp_sth_csr->srvhp      = imp_sth->srvhp;
+       imp_sth_csr->svchp      = imp_sth->svchp;
+       imp_sth_csr->auto_lob   = imp_sth->auto_lob;
+       imp_sth_csr->pers_lob   = imp_sth->pers_lob;
+       imp_sth_csr->clbk_lob   = imp_sth->clbk_lob;
+       imp_sth_csr->piece_size = imp_sth->piece_size;
+       imp_sth_csr->piece_lob  = imp_sth->piece_lob;
 
+       
        /* assign statement handle from placeholder descriptor  */
        imp_sth_csr->stmhp = (OCIStmt*)phs->desc_h;
        phs->desc_h = NULL;               /* tell phs that we own it now        
*/
@@ -2484,7 +2497,7 @@
     if (trace_level >= 5 || dbd_verbose >= 5 )
                PerlIO_printf(DBILOGFP, "dbd_rebind_ph() (1): rebinding %s as 
%s (%s, ftype %d (%s), csid %d, csform %d, inout %d)\n",
                phs->name, (SvPOK(phs->sv) ? neatsvpv(phs->sv,10) : 
"NULL"),(SvUTF8(phs->sv) ? "is-utf8" : "not-utf8"),
-               phs->ftype,sql_typecode_name(phs->csid), phs->csform, 
phs->is_inout);
+               phs->ftype,sql_typecode_name(phs->ftype), phs->csform, 
phs->is_inout);
 
 
     switch (phs->ftype) {
@@ -2508,13 +2521,16 @@
            done = dbd_rebind_ph_char(imp_sth, phs);
     }
 
-
     if (done == 2) { /* the dbd_rebind_* did the OCI bind call itself 
successfully */
                if (trace_level >= 3 || dbd_verbose >= 3 )
-                   PerlIO_printf(DBILOGFP, "       bind %s done with ftype 
%d\n",
-                           phs->name, phs->ftype);
+                   PerlIO_printf(DBILOGFP, "      rebind %s done with ftype %d 
(%s)\n",
+                           phs->name, 
phs->ftype,sql_typecode_name(phs->ftype));
                return 1;
-    }
+    } 
+    
+    if (trace_level >= 3 || dbd_verbose >= 3 )
+               PerlIO_printf(DBILOGFP, "      bind %s as ftype %d (%s)\n",
+               phs->name, phs->ftype,sql_typecode_name(phs->ftype));
 
     if (done != 1) {
                return 0;        /* the rebind failed   */
@@ -2925,8 +2941,8 @@
                    phs->indp = (SvOK(sv)) ? 0 : -1;
 
                    if (phs->out_prepost_exec) {
-                       if (!phs->out_prepost_exec(sth, imp_sth, phs, 1))
-                           return -2; /* out_prepost_exec already called 
ora_error()   */
+                               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) {
@@ -2977,7 +2993,7 @@
 
 
         if (debug >= 2 || dbd_verbose >= 2)
-                       PerlIO_printf(DBILOGFP,"Statement Execute Mode is 
%d\n",imp_sth->exe_mode);
+                       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,
@@ -3031,31 +3047,33 @@
                    SV *sv = phs->sv;
                    if (debug >= 2 || dbd_verbose >= 2) {
                                PerlIO_printf(DBILOGFP,
-                               "dbd_st_execute(): Analyzing inout parameter 
'%s'\n",
-                               phs->name);
-           }
-           if( phs->ftype == ORA_VARCHAR2_TABLE ){
-                       dbd_phs_ora_varchar2_table_fixup_after_execute(phs);
-                       continue;
-           }
-           if( phs->ftype == ORA_NUMBER_TABLE ){
-                       dbd_phs_ora_number_table_fixup_after_execute(phs);
-                       continue;
-           }
+                               "dbd_st_execute(): Analyzing inout parameter 
'%s of type=%d'\n",
+                               phs->name,phs->ftype);
+                   }
+                   if( phs->ftype == ORA_VARCHAR2_TABLE ){
+                               
dbd_phs_ora_varchar2_table_fixup_after_execute(phs);
+                               continue;
+                   }
+                   if( phs->ftype == ORA_NUMBER_TABLE ){
+                               
dbd_phs_ora_number_table_fixup_after_execute(phs);
+                               continue;
+                   }
 
-           if (phs->out_prepost_exec) {
-                       if (!phs->out_prepost_exec(sth, imp_sth, phs, 0))
-                           return -2; /* out_prepost_exec already called 
ora_error()   */
-           }
-           else
-                   if (SvTYPE(sv) == SVt_RV && SvTYPE(SvRV(sv)) == SVt_PVAV) {
-                               AV *av = (AV*)SvRV(sv);
-                               I32 avlen = AvFILL(av);
-                               if (avlen >= 0)
-                                    dbd_phs_avsv_complete(phs, avlen, debug);
+                   if (phs->out_prepost_exec) {
+                               if (!phs->out_prepost_exec(sth, imp_sth, phs, 
0))
+                                   return -2; /* out_prepost_exec already 
called ora_error()   */
                    }
-                   else
-                           dbd_phs_sv_complete(phs, sv, debug);
+                   else {
+                           if (SvTYPE(sv) == SVt_RV && SvTYPE(SvRV(sv)) == 
SVt_PVAV) {
+                                       AV *av = (AV*)SvRV(sv);
+                                       I32 avlen = AvFILL(av);
+                                       if (avlen >= 0)
+                                            dbd_phs_avsv_complete(phs, avlen, 
debug);
+                           }
+                           else {
+                                   dbd_phs_sv_complete(phs, sv, debug);
+                               }
+                       }
                }
     }
 

Modified: dbd-oracle/trunk/oci8.c
==============================================================================
--- dbd-oracle/trunk/oci8.c     (original)
+++ dbd-oracle/trunk/oci8.c     Fri Jul 18 10:08:29 2008
@@ -57,8 +57,8 @@
                case OCI_BATCH_ERRORS:          return "BATCH_ERRORS";   /* 
batch errors in array dmls */
                case OCI_PARSE_ONLY:            return "PARSE_ONLY";     /* 
only parse the statement */
                case OCI_SHOW_DML_WARNINGS:     return "SHOW_DML_WARNINGS";    
-               case OCI_RESULT_CACHE:          return "RESULT_CACHE";   /* 
hint to use query caching */
-               case OCI_NO_RESULT_CACHE :      return "NO_RESULT_CACHE";   
/*hint to bypass query caching*/
+/*             case OCI_RESULT_CACHE:          return "RESULT_CACHE";   hint 
to use query caching only 11 so wait this one out*/
+/*             case OCI_NO_RESULT_CACHE :      return "NO_RESULT_CACHE";   
hint to bypass query caching*/
        }
        sv = sv_2mortal(newSVpv("",0));
     sv_grow(sv, 50);
@@ -201,7 +201,7 @@
                case OCI_PIECEWISE:     return "PIECEWISE";         /* 
piecewise DMLs or fetch */
                case OCI_BIND_SOFT:     return "BIND_SOFT";               /* 
soft bind or define */
                case OCI_DEFINE_SOFT:   return "DEFINE_SOFT";           /* soft 
bind or define */
-               case OCI_IOV:                   return "";   /* For scatter 
gather bind/define */
+/*             case OCI_IOV:                   return "";   11g only release 
1.23 me thinks For scatter gather bind/define */
                
         }
     sv = sv_2mortal(newSVpv("",0));
@@ -227,42 +227,42 @@
                case OCI_SHARED:        return "SHARED";  /* the application is 
in shared mode */
                /* The following *TWO* are only valid for OCICreateEnvironment 
call */
                case OCI_NO_UCB:        return "NO_UCB "; /* No user callback 
called during ini */
-               case OCI_NO_MUTEX:      return "NO_MUTEX"; /* the environment 
handle will not be */
-                                                   /*  protected by a mutex 
internally */
+               case OCI_NO_MUTEX:      return "NO_MUTEX"; /* the environment 
handle will not be 
+                                                     protected by a mutex 
internally */
                case OCI_SHARED_EXT:     return "SHARED_EXT";              /* 
Used for shared forms */
                case OCI_ALWAYS_BLOCKING:return "ALWAYS_BLOCKING";    /* all 
connections always blocking */
                case OCI_USE_LDAP:       return "USE_LDAP";            /* allow 
 LDAP connections */
                case OCI_REG_LDAPONLY:   return "REG_LDAPONLY";              /* 
only register to LDAP */
                case OCI_UTF16:          return "UTF16";        /* mode for all 
UTF16 metadata */
                case OCI_AFC_PAD_ON:     return "AFC_PAD_ON";  /* turn on AFC 
blank padding when rlenp present */
-               case OCI_NEW_LENGTH_SEMANTICS: return "NEW_LENGTH_SEMANTICS";   
/* adopt new length semantics */
-                                                                               
               /* the new length semantics, always bytes, is used by 
OCIEnvNlsCreate */
+               case OCI_NEW_LENGTH_SEMANTICS: return "NEW_LENGTH_SEMANTICS";   
/* adopt new length semantics 
+                                                                               
               the new length semantics, always bytes, is used by 
OCIEnvNlsCreate */
                case OCI_NO_MUTEX_STMT:  return "NO_MUTEX_STMT";           /* 
Do not mutex stmt handle */
                case OCI_MUTEX_ENV_ONLY: return "MUTEX_ENV_ONLY";  /* Mutex 
only the environment handle */
-               case OCI_SUPPRESS_NLS_VALIDATION:  return 
"SUPPRESS_NLS_VALIDATION";  /* suppress nls validation */
-                                                                               
                                 /* nls validation suppression is on by default;
+               case OCI_SUPPRESS_NLS_VALIDATION:  return 
"SUPPRESS_NLS_VALIDATION";  /* suppress nls validation 
+                                                                               
                                  nls validation suppression is on by default;
                                                                                
                             use OCI_ENABLE_NLS_VALIDATION to disable it */
                case OCI_MUTEX_TRY:                return "MUTEX_TRY";    /* 
try and acquire mutex */
                case OCI_NCHAR_LITERAL_REPLACE_ON: return 
"NCHAR_LITERAL_REPLACE_ON"; /* nchar literal replace on */
                case OCI_NCHAR_LITERAL_REPLACE_OFF:return 
"NCHAR_LITERAL_REPLACE_OFF"; /* nchar literal replace off*/
-               case OCI_ENABLE_NLS_VALIDATION:    return 
"ENABLE_NLS_VALIDATION";    /* enable nls validation */
+/*             case OCI_ENABLE_NLS_VALIDATION:    return 
"ENABLE_NLS_VALIDATION";     enable nls validation */
                /*------------------------OCIConnectionpoolCreate 
Modes----------------------*/
                case OCI_CPOOL_REINITIALIZE:    return "CPOOL_REINITIALIZE";
                /*--------------------------------- OCILogon2 Modes 
-------------------------*/
-/*case OCI_LOGON2_SPOOL:       return "LOGON2_SPOOL";     /* Use session pool 
*/
+/*case OCI_LOGON2_SPOOL:       return "LOGON2_SPOOL";      Use session pool */
                case OCI_LOGON2_CPOOL:          return "LOGON2_CPOOL"; /* Use 
connection pool */
-/*case OCI_LOGON2_STMTCACHE:   return "LOGON2_STMTCACHE";     /* Use Stmt 
Caching */
+/*case OCI_LOGON2_STMTCACHE:   return "LOGON2_STMTCACHE";      Use Stmt 
Caching */
                case OCI_LOGON2_PROXY:          return "LOGON2_PROXY";     /* 
Proxy authentiaction */
                /*------------------------- OCISessionPoolCreate Modes 
----------------------*/
-/*case OCI_SPC_REINITIALIZE:           return "SPC_REINITIALIZE";   /* 
Reinitialize the session pool */
-/*case OCI_SPC_HOMOGENEOUS:            return "SPC_HOMOGENEOUS"; "";   /* 
Session pool is homogeneneous */
-/*case OCI_SPC_STMTCACHE:              return "SPC_STMTCACHE";   /* Session 
pool has stmt cache */
-/*case OCI_SPC_NO_RLB:                 return "SPC_NO_RLB "; /* Do not enable 
Runtime load balancing. */ 
+/*case OCI_SPC_REINITIALIZE:           return "SPC_REINITIALIZE";    
Reinitialize the session pool */
+/*case OCI_SPC_HOMOGENEOUS:            return "SPC_HOMOGENEOUS"; "";    
Session pool is homogeneneous */
+/*case OCI_SPC_STMTCACHE:              return "SPC_STMTCACHE";    Session pool 
has stmt cache */
+/*case OCI_SPC_NO_RLB:                 return "SPC_NO_RLB ";  Do not enable 
Runtime load balancing. */ 
                /*--------------------------- OCISessionGet Modes 
---------------------------*/
-/*case OCI_SESSGET_SPOOL:      return "SESSGET_SPOOL";     /* SessionGet 
called in SPOOL mode */
-/*case OCI_SESSGET_CPOOL:              return "SESSGET_CPOOL";  /* SessionGet 
called in CPOOL mode */
-/*case OCI_SESSGET_STMTCACHE:  return "SESSGET_STMTCACHE";                 /* 
Use statement cache */
-/*case OCI_SESSGET_CREDPROXY:  return "SESSGET_CREDPROXY";     /* SessionGet 
called in proxy mode */
+/*case OCI_SESSGET_SPOOL:      return "SESSGET_SPOOL";      SessionGet called 
in SPOOL mode */
+/*case OCI_SESSGET_CPOOL:              return "SESSGET_CPOOL";   SessionGet 
called in CPOOL mode */
+/*case OCI_SESSGET_STMTCACHE:  return "SESSGET_STMTCACHE";                  
Use statement cache */
+/*case OCI_SESSGET_CREDPROXY:  return "SESSGET_CREDPROXY";      SessionGet 
called in proxy mode */
 /*case OCI_SESSGET_CREDEXT:    return "SESSGET_CREDEXT";     */
                case OCI_SESSGET_SPOOL_MATCHANY:return "SESSGET_SPOOL_MATCHANY";
 /*case OCI_SESSGET_PURITY_NEW:    return "SESSGET_PURITY_NEW"; 
@@ -989,7 +989,7 @@
     int count;
 
     if (DBIS->debug >= 3 || dbd_verbose >=3)
-       PerlIO_printf(DBILOGFP,
+               PerlIO_printf(DBILOGFP,
                "    fetch_func_rset - allocating handle for cursor nested 
within %s ...\n",
                                neatsvpv(sth, 0));
 
@@ -1043,6 +1043,10 @@
 dbd_rebind_ph_rset(SV *sth, imp_sth_t *imp_sth, phs_t *phs)
 {
   dTHX;
+  
+   if (DBIS->debug >= 6 || dbd_verbose >=6)
+        PerlIO_printf(DBILOGFP, "     dbd_rebind_ph_rset 
phs->is_inout=%d\n",phs->is_inout);
+
   /* Only do this part for inout cursor refs because pp_exec_rset only gets 
called for all the output params */
   if (phs->is_inout) {
     phs->out_prepost_exec = pp_exec_rset;
@@ -2524,7 +2528,7 @@
                        PerlIO_printf(DBILOGFP, "    dbd_describe skipped for 
%s\n",
                        oci_stmt_type_name(imp_sth->stmt_type));
        /* imp_sth memory was cleared when created so no setup required here    
*/
-       return 1;
+               return 1;
     }
 
     if (DBIS->debug >= 3 || dbd_verbose >= 3)
@@ -2810,7 +2814,7 @@
                                        }
                                        fbh->fetch_func = fetch_get_piece;
                                } else { /*auto lob fetch with locator by far 
the fastest*/
-                               
+           
                                        fbh->disize = fbh->dbsize *10 ; /* XXX! 
*/
                                        fbh->fetch_func = (imp_sth->auto_lob) ? 
fetch_func_autolob : fetch_func_getrefpv;
                                        fbh->bless  = "OCILobLocatorPtr";
@@ -3389,7 +3393,7 @@
     if (status == OCI_SUCCESS) { /* There is a synonym, get the schema */
        char *syn_schema=NULL, *syn_name=NULL;
        char new_tablename[100];
-       ub4 syn_schema_len = 0, syn_name_len = 0,new_tablename_len=0;
+       ub4 syn_schema_len = 0, syn_name_len = 0;
        OCIAttrGet_log_stat(imp_sth->dschp,  OCI_HTYPE_DESCRIBE,
                                  &parmhp, 0, OCI_ATTR_PARAM, errhp, status);
        OCIAttrGet_log_stat(parmhp, OCI_DTYPE_PARAM,

Reply via email to