Author: byterock
Date: Sun Dec  9 10:00:00 2007
New Revision: 10395

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

Log:
well working kind of

Modified: dbd-oracle/trunk/dbdimp.c
==============================================================================
--- dbd-oracle/trunk/dbdimp.c   (original)
+++ dbd-oracle/trunk/dbdimp.c   Sun Dec  9 10:00:00 2007
@@ -256,7 +256,7 @@
     case 113:  /* SQLT_BLOB / long     */
     case 116:  /* SQLT_RSET    OCI 8 cursor variable   */
        case ORA_VARCHAR2_TABLE: /* 201 */
-    case ORA_NUMBER_TABLE: /* 202 */   
+    case ORA_NUMBER_TABLE: /* 202 */
        return 1;
     }
     return 0;
@@ -290,22 +290,7 @@
     Safefree(fb_ary);
 }
 
-void
-fb_obj_free(fbh_obj_t *fb_obj)
-{
-    if (fb_obj->parmdp)
-           Safefree(fb_obj->parmdp);            
-       if (fb_obj->parmap)
-               Safefree(fb_obj->parmap);            
-       if (fb_obj->obj_ref)
-               Safefree(fb_obj->obj_ref);                      
-       if (fb_obj->obj_type)
-               Safefree(fb_obj->obj_type);         
-    if (fb_obj->fields)
-       Safefree(fb_obj->fields);
-    Safefree(fb_obj);
-       
-}
+
 /* ================================================================== */
 
 
@@ -1160,10 +1145,10 @@
 }
 
 
- 
+
 /* ############### Array bind ######################################### */
 /* Added by Alexander V Alekseev. [EMAIL PROTECTED]                       */
-/* 
+/*
  *
  * Realloc temporary array buffer to match required number of entries
  * and buffer size.
@@ -1176,7 +1161,7 @@
     dTHR;
     int i; /* Loop variable */
     unsigned short *newal;
-    
+
     if( newbufsize < 0 ){
        newbufsize=0;
     }
@@ -1270,7 +1255,7 @@
     {
        unsigned int maxlen=0;
        int i;
-       
+
        for(i=0;i<av_len(arr)+1;i++){
            SV *item;
            item=*(av_fetch(arr,i,0));
@@ -1350,7 +1335,7 @@
     }
 
     need_allocate_rows=phs->ora_maxarray_numentries;
-    
+
     if( need_allocate_rows< phs->array_numstruct ){
        need_allocate_rows=phs->array_numstruct;
     }
@@ -1366,7 +1351,7 @@
        }
     }
     /* If maximum allowed bind numentries is less than allowed,
-     * do not bind full array 
+     * do not bind full array
      */
     if( phs->array_numstruct > phs->ora_maxarray_numentries ){
        phs->array_numstruct = phs->ora_maxarray_numentries;
@@ -1534,7 +1519,7 @@
     /* Extend array, if needed. */
     if( av_len(arr)+1 < phs->array_numstruct ){
        av_extend(arr,phs->array_numstruct-1);
-    } 
+    }
     /* Fill array with buffer data */
     {
        /* phs_t */
@@ -1617,7 +1602,7 @@
     int need_allocate_rows;
     int buflen;
     int flag_data_is_utf8=0;
-   
+
     if( ( ! SvROK(phs->sv) )  || (SvTYPE(SvRV(phs->sv))!=SVt_PVAV) ) { /* 
Allow only array binds */
        croak("dbd_rebind_ph_number_table(): bad bind variable. ARRAY reference 
required, but got %s for '%s'.",
                    neatsvpv(phs->sv,0), phs->name);
@@ -1690,7 +1675,7 @@
     }
 
     need_allocate_rows=phs->ora_maxarray_numentries;
-    
+
     if( need_allocate_rows< phs->array_numstruct ){
        need_allocate_rows=phs->array_numstruct;
     }
@@ -1707,7 +1692,7 @@
        }
     }
     /* If maximum allowed bind numentries is less than allowed,
-     * do not bind full array 
+     * do not bind full array
      */
     if( phs->array_numstruct > phs->ora_maxarray_numentries ){
        phs->array_numstruct = phs->ora_maxarray_numentries;
@@ -1739,7 +1724,7 @@
                            }
                            if( SvIOK( item ) || val_found ){
                                if( ! val_found ){
-                                   ival=SvIV( item ); 
+                                   ival=SvIV( item );
                                }
                                /* as phs->array_buf=malloc(), proper alignment 
is guaranteed */
                                *(int*)(phs->array_buf+phs->maxlen*i)=ival;
@@ -1772,7 +1757,7 @@
                                SvNVx( item );
                            }
                            if( SvNOK( item ) ){
-                               double val=SvNVx( item ); 
+                               double val=SvNVx( item );
                                /* as phs->array_buf=malloc(), proper alignment 
is guaranteed */
                                *(double*)(phs->array_buf+phs->maxlen*i)=val;
                                phs->array_indicators[i]=0;
@@ -1905,7 +1890,7 @@
     /* Extend array, if needed. */
     if( av_len(arr)+1 < phs->array_numstruct ){
        av_extend(arr,phs->array_numstruct-1);
-    } 
+    }
     /* Fill array with buffer data */
     {
        /* phs_t */
@@ -2416,7 +2401,7 @@
                && !IS_DBI_HANDLE(newvalue)     /* dbi handle allowed for 
cursor variables */
                && !SvAMAGIC(newvalue)          /* overload magic allowed 
(untested) */
                && !sv_derived_from(newvalue, "OCILobLocatorPtr" )  /* input 
LOB locator*/
-               && !(SvTYPE(SvRV(newvalue))==SVt_PVAV) /* Allow array binds */  
+               && !(SvTYPE(SvRV(newvalue))==SVt_PVAV) /* Allow array binds */
                )
                croak("Can't bind a reference (%s)", neatsvpv(newvalue,0));
        if (SvTYPE(newvalue) > SVt_PVAV) /* Array binding supported */
@@ -2462,7 +2447,7 @@
         * the same as scalar(@array) bound (see dbd_rebind_ph_varchar2_table() 
).
         */
        phs->array_numstruct=0;
-       
+
        if (attribs) {  /* only look for ora_type on first bind of var  */
            SV **svp;
            /* Setup / Clear attributes as defined by attribs.          */
@@ -2493,7 +2478,7 @@
            }
            if ( (svp=hv_fetch((HV*)SvRV(attribs), "ora_internal_type", 17, 0)) 
!= NULL) {
                        phs->ora_internal_type=SvUV(*svp);
-           }       
+           }
        }
        if (sql_type)
            phs->ftype = ora_sql_type(imp_sth, phs->name, (int)sql_type);
@@ -3184,7 +3169,8 @@
     if (fbh->desc_h)
        OCIDescriptorFree_log(fbh->desc_h, fbh->desc_t);
        if (fbh->obj)
-       fb_obj_free(fbh->obj);
+               Safefree(fbh->obj);
+
 }
 
 void

Modified: dbd-oracle/trunk/oci8.c
==============================================================================
--- dbd-oracle/trunk/oci8.c     (original)
+++ dbd-oracle/trunk/oci8.c     Sun Dec  9 10:00:00 2007
@@ -1372,19 +1372,20 @@
        sword           status;
        OCIIter         *itr = (OCIIter *) 0;
        dvoid           *element = (dvoid *) 0;
-       dvoid           *null_element = (dvoid *) 0;
+       OCIInd          *null_element;
        dvoid           *attr_value = (dvoid *) 0;
-               dvoid           **null_struct = (dvoid *) 0;
-
+       dvoid           **null_struct = (dvoid *) 0;
        boolean         eoc,exist;
        ub2             pos;
-       OCIInd          *attr_null_ind= (dvoid *) 0;
+       OCIInd          *attr_null_ind= (OCIInd *) 0;
        dvoid           *attr_null_struct= (dvoid *) 0;
        OCIType         *attr_tdo;
        sb4             index;
        fbh_obj_t       *fld;
 
-       if (DBIS->debug >= 5) {
+
+
+       if (DBIS->debug <= 5) {
                PerlIO_printf(DBILOGFP, " getting attributes of object named  
%s with typecode=%d\n",obj->type_name,obj->typecode);
        }
 
@@ -1393,11 +1394,7 @@
 
                case OCI_TYPECODE_OBJECT :                            /* 
embedded ADT */
 
-                       status = OCIObjectGetInd ( fbh->imp_sth->envhp,
-                        fbh->imp_sth->errhp,
-                        value,
-                        null_struct );
-PerlIO_printf(DBILOGFP, "status =%d",status);
+
                        for (pos = 0; pos < obj->field_count; pos++){
                                fld = &obj->fields[pos]; /*get the field */
                                status = OCIObjectGetAttr(fbh->imp_sth->envhp, 
fbh->imp_sth->errhp, value,
@@ -1405,7 +1402,7 @@
                                                                                
&fld->type_name, &fld->type_namel, 1,
                                                                                
(ub4 *)0, 0, attr_null_ind, attr_null_struct,
                                                                                
(dvoid *) &attr_value, &attr_tdo);
-PerlIO_printf(DBILOGFP, "OCI_IND_BADNULL= %d,OCI_IND_NULL= %d,OCI_IND_NOTNULL= 
%d attr_null_ind= %d, attr_null_struct= 
2%d\n",OCI_IND_BADNULL,OCI_IND_NULL,OCI_IND_NOTNULL,attr_null_ind, 
attr_null_struct);
+
                                if (status != OCI_SUCCESS) {
                                        oci_error(sth, fbh->imp_sth->errhp, 
status, "OCIObjectGetAttr");
                                        return 0;
@@ -1441,12 +1438,22 @@
 
                        switch (obj->col_typecode) {
 
-               case OCI_TYPECODE_VARRAY :                    /* variable array 
*/
+                               case OCI_TYPECODE_TABLE :                       
/* nested table */
+                               case OCI_TYPECODE_VARRAY :                    
/* variable array */
                                fld = &obj->fields[0]; /*get the field */
+
+                               PerlIO_printf(DBILOGFP, " ping 1\n");
+
                        OCIIterCreate_log_stat(fbh->imp_sth->envhp, 
fbh->imp_sth->errhp,
                        (CONST OCIColl*) value, &itr,status);
 
+                       status =OCIIterInit ( fbh->imp_sth->envhp,
+                                                             
fbh->imp_sth->errhp,
+                                                             (CONST OCIColl*) 
value,              itr );
+PerlIO_printf(DBILOGFP, " ping 2%d\n",status);
                                        if (status != OCI_SUCCESS) {
+                                               PerlIO_printf(DBILOGFP, " ping 
3%d\n",status);
+
                                                /*not really an error just no 
data
                                                oci_error(sth, 
fbh->imp_sth->errhp, status, "OCIIterCreate");*/
                                                status = OCI_SUCCESS;
@@ -1455,9 +1462,9 @@
 
                                        for(eoc = 
FALSE;!OCIIterNext(fbh->imp_sth->envhp, fbh->imp_sth->errhp, itr,
                                (dvoid **) &element,
-                               (dvoid **)&null_element, &eoc) && !eoc;)
+                               &null_element, &eoc) && !eoc;)
                        {
-
+PerlIO_printf(DBILOGFP, " ping 4 %d,%d\n",null_element,OCI_IND_BADNULL);
                                                if (obj->element_typecode == 
OCI_TYPECODE_OBJECT){
                                                        fld->value = newAV();
                                        get_object (sth,fld->value, fbh, 
fld,element);
@@ -1467,12 +1474,31 @@
 
                                }
                                }
+
+                               status=OCIIterDelete( fbh->imp_sth->envhp,
+                                                             
fbh->imp_sth->errhp, &itr );
+                    if (status != OCI_SUCCESS) {
+                                               /*not really an error just no 
data*/
+                                               oci_error(sth, 
fbh->imp_sth->errhp, status, "OCIIterDelete");
+                                               status = OCI_SUCCESS;
+                                               return 0;
+                               }
                                break;
 
-               case OCI_TYPECODE_TABLE :                       /* nested table 
*/
+               case OCI_TYPECODE_REF :                       /* nested table */
 
                                fld = &obj->fields[0]; /*get the field */
-                               PerlIO_printf(DBILOGFP, " bug #1\n %d",value);
+
+                                       
OCIIterCreate_log_stat(fbh->imp_sth->envhp, fbh->imp_sth->errhp,
+                                                              (CONST OCIColl*) 
value, &itr,status);
+                                                       PerlIO_printf(DBILOGFP, 
"status=%d\n",status);
+
+                                       if (status != OCI_SUCCESS) {
+                                                                               
        /*not really an error just no data
+                                                                               
        oci_error(sth, fbh->imp_sth->errhp, status, "OCIIterCreate");*/
+                                                                               
        status = OCI_SUCCESS;
+                                                                               
        return 0;
+                               }
 
                                        
OCITableFirst_log_stat(fbh->imp_sth->envhp, fbh->imp_sth->errhp,(CONST 
OCITable*) value, &index,status);
 
@@ -1480,7 +1506,6 @@
                                                /*oci_error(sth, 
fbh->imp_sth->errhp, status, "OCITableFirst");*/
                                                /*not really an error just no 
data */
                                                status = OCI_SUCCESS;
-                                               PerlIO_printf(DBILOGFP, " bug 
#2\n");
 
                                                return 0;
                                }
@@ -1492,7 +1517,6 @@
 
                                        if (status != OCI_SUCCESS) {
                                                oci_error(sth, 
fbh->imp_sth->errhp, status, "OCICollGetElem");
-                                               PerlIO_printf(DBILOGFP, " bug 
#2\n");
 
                                                return 0;
                                }
@@ -1503,7 +1527,6 @@
                                                av_push(list, newRV_noinc((SV 
*) fld->value));
 
                                        }else{
-                                           PerlIO_printf(DBILOGFP, " bug 
#3\n");
                                get_attr_val(list, fbh, obj->type_name, 
obj->element_typecode, element);
                        }
 
@@ -1512,7 +1535,6 @@
                               (CONST OCITable *) value,
                               &index, &exist) && exist;)
                        {
- PerlIO_printf(DBILOGFP, " bug #4\n");
                                OCICollGetElem_log_stat(fbh->imp_sth->envhp, 
fbh->imp_sth->errhp,
                                           (CONST OCIColl *)  value, index,
                                           &exist, (dvoid **) &element,
@@ -1531,7 +1553,6 @@
                                        get_attr_val(list, fbh, obj->type_name, 
obj->element_typecode, element);
                            }
                        }
-                        PerlIO_printf(DBILOGFP, " bug #5\n");
 
                        break;
                default:
@@ -1539,11 +1560,15 @@
                }
                break;
        default:
+
            if (value  ) {
+
                get_attr_val(list, fbh, obj->type_name, obj->typecode, value);
            }
-           else
-              return 1;
+           else {
+                      return 1;
+
+                       }
            break;
        }
        return 1;

Reply via email to