Author: byterock
Date: Fri Oct 10 13:45:17 2008
New Revision: 11957
Modified:
dbd-oracle/branches/utf8_ea_2/dbdimp.c
dbd-oracle/branches/utf8_ea_2/oci8.c
dbd-oracle/branches/utf8_ea_2/t/26exe_array.t
Log:
working version still have to clean up a little before it goes in trunk
Modified: dbd-oracle/branches/utf8_ea_2/dbdimp.c
==============================================================================
--- dbd-oracle/branches/utf8_ea_2/dbdimp.c (original)
+++ dbd-oracle/branches/utf8_ea_2/dbdimp.c Fri Oct 10 13:45:17 2008
@@ -3093,18 +3093,20 @@
}
static int
-do_bind_array_exec(sth, imp_sth, phs,utf8)
+do_bind_array_exec(sth, imp_sth,
phs,utf8,parma_index,tuples_utf8_av,tuples_status_av)
SV *sth;
imp_sth_t *imp_sth;
phs_t *phs;
int utf8;
-{
+ AV *tuples_utf8_av,*tuples_status_av;
+ int parma_index;
+ {
dTHX;
sword status;
ub1 csform;
ub2 csid;
int trace_level = DBIS->debug;
-
+ int i;
OCIBindByName_log_stat(imp_sth->stmhp, &phs->bndhp, imp_sth->errhp,
(text*)phs->name, (sb4)strlen(phs->name),
0,
@@ -3170,7 +3172,27 @@
* mixed utf8 and native (non-utf8) data, then it's a fatal problem
* utf8 _compatible_ means, can be upgraded to utf8, ie. utf8 or
ascii */
if ((utf8 & ARRAY_BIND_NATIVE) && CS_IS_NOT_UTF8(csid)) {
- croak("Can't mix utf8 and non-utf8 in array bind");
+ warn("what is my one=%d",av_len(tuples_utf8_av));
+ if (av_len(tuples_utf8_av+1)){
+ oratext charsetname[OCI_NLS_MAXBUFSZ];
+
OCINlsCharSetIdToName(imp_sth->envhp,charsetname, sizeof(charsetname),csid );
+
+ for(i=0;i<av_len(tuples_utf8_av)+1;i++){
+ SV *err_svs[2];
+ SV *item;
+ item=*(av_fetch(tuples_utf8_av,i,0));
+ warn("what is my one=%d
=%d\n",av_len(tuples_utf8_av),SvIV(item));
+ err_svs[0] = newSViv((IV)0);
+ err_svs[1] = newSVpvf("DBD Oracle Warning: You
have mixed utf8 and non-utf8 in an array bind in parameter#%d. This may result
in corrupt data. The Query charset id=%d,
name=%s",parma_index+1,csid,charsetname);
+ av_store(tuples_status_av,SvIV(item),
+ newRV_noinc((SV *)(av_make(2, err_svs))));
+ warn("what is my one=%d\n",av_len(tuples_utf8_av));
+ }
+ /*av_store(tuples_status_av,tuple_index,
+ newRV_noinc((SV *)(av_make(2, err_svs))));
+*/
+ }
+
}
csid = utf8_csid; /* not al32utf8_csid here on purpose */
}
@@ -3231,7 +3253,7 @@
D_imp_dbh_from_sth;
sword status, exe_status;
int is_select = (imp_sth->stmt_type == OCI_STMT_SELECT);
- AV *tuples_av, *tuples_status_av, *columns_av;
+ AV *tuples_av, *tuples_status_av, *columns_av,*tuples_utf8_av;
ub4 oci_mode;
ub4 num_errs;
int i,j;
@@ -3245,6 +3267,7 @@
STRLEN len;
int outparams = (imp_sth->out_params_av) ?
AvFILL(imp_sth->out_params_av)+1 : 0;
int *utf8_flgs;
+ tuples_utf8_av=newAV();
if (debug >= 2 || dbd_verbose >=2)
PerlIO_printf(DBILOGFP, " ora_st_execute_array %s count=%d (%s
%s %s)...\n",
@@ -3285,11 +3308,7 @@
}
tuples_status_av = (AV*)SvRV(tuples_status);
av_fill(tuples_status_av, exe_count - 1);
- /* Fill in 'unknown' exe count in every element (know not how to get
- individual execute row counts from OCI). */
- for(i = 0; (unsigned int) i < exe_count; i++) {
- av_store(tuples_status_av, i, newSViv((IV)-1));
- }
+
} else {
tuples_status_av = NULL;
}
@@ -3313,7 +3332,14 @@
memset(utf8_flgs, 0, param_count*sizeof(int));
for(j = 0; (unsigned int) j < exe_count; j++) {
+ /* Fill in 'unknown' exe count in every element (know not how
to get
+ individual execute row counts from OCI).
+ Moved it here as there is no need to iterate twice over it
+ this should speed it up somewhat for large binds*/
+ if (SvTRUE(tuples_status)){
+ av_store(tuples_status_av, j, newSViv((IV)-1));
+ }
sv_p = av_fetch(tuples_av, j, 0);
if(sv_p == NULL) {
Safefree(phs);
@@ -3376,16 +3402,24 @@
/* update the utf8_flgs for this value */
if (SvUTF8(sv)) {
utf8_flgs[i] |= ARRAY_BIND_UTF8;
+ if (SvTRUE(tuples_status)){
+ av_push(tuples_utf8_av,newSViv(j));
+
+ }
+
+
}
else {
utf8_flgs[i] |= ARRAY_BIND_NATIVE;
+ warn("I may be i=%d,j=%d",i,j);
}
/* Do OCI bind calls on last iteration. */
if( ((unsigned int) j ) == exe_count - 1 ) {
- if(!do_bind_array_exec(sth, imp_sth, phs[i],
utf8_flgs[i])) {
- Safefree(phs);
- Safefree(utf8_flgs);
- }
+
+ if(!do_bind_array_exec(sth, imp_sth, phs[i],
utf8_flgs[i],i,tuples_utf8_av,tuples_status_av)) {
+ Safefree(phs);
+ Safefree(utf8_flgs);
+ }
}
}
}
Modified: dbd-oracle/branches/utf8_ea_2/oci8.c
==============================================================================
--- dbd-oracle/branches/utf8_ea_2/oci8.c (original)
+++ dbd-oracle/branches/utf8_ea_2/oci8.c Fri Oct 10 13:45:17 2008
@@ -658,50 +658,51 @@
if( bindp ) { /* For GCC not to warn on unused parameter*/ }
/* Check for bind values supplied by tuple array. */
- tuples_av = phs->imp_sth->bind_tuples;
- if(tuples_av) {
- /* NOTE: we already checked the validity in
ora_st_bind_for_array_exec(). */
- sv_p = av_fetch(tuples_av, phs->imp_sth->rowwise ?
(int)iter : phs->idx, 0);
- av = (AV*)SvRV(*sv_p);
- sv_p = av_fetch(av, phs->imp_sth->rowwise ? phs->idx :
(int)iter, 0);
- sv = *sv_p;
- if(SvOK(sv)) {
- *bufpp = SvPV(sv, phs_len);
- phs->alen = (phs->alen_incnull) ? phs_len+1 : phs_len;
- phs->indp = 0;
- } else {
- *bufpp = SvPVX(sv);
- phs->alen = 0;
- phs->indp = -1;
- }
- }
- else
- if (phs->desc_h) {
- *bufpp = phs->desc_h;
- phs->alen = 0;
- phs->indp = 0;
- }
- else
- if (SvOK(phs->sv)) {
- *bufpp = SvPV(phs->sv, phs_len);
+ tuples_av = phs->imp_sth->bind_tuples;
+ if(tuples_av) {
+ /* NOTE: we already checked the validity in
ora_st_bind_for_array_exec(). */
+ sv_p = av_fetch(tuples_av, phs->imp_sth->rowwise ? (int)iter :
phs->idx, 0);
+ av = (AV*)SvRV(*sv_p);
+ sv_p = av_fetch(av, phs->imp_sth->rowwise ? phs->idx :
(int)iter, 0);
+ sv = *sv_p;
+ if(SvOK(sv)) {
+ *bufpp = SvPV(sv, phs_len);
+ phs->alen = (phs->alen_incnull) ? phs_len+1 : phs_len;
+ phs->indp = 0;
+ } else {
+ *bufpp = SvPVX(sv);
+ phs->alen = 0;
+ phs->indp = -1;
+ }
+ }
+ else
+ if (phs->desc_h) {
+ *bufpp = phs->desc_h;
+ phs->alen = 0;
+ phs->indp = 0;
+ }
+ else
+ if (SvOK(phs->sv)) {
+ *bufpp = SvPV(phs->sv, phs_len);
phs->alen = (phs->alen_incnull) ? phs_len+1 : phs_len;;
phs->indp = 0;
- }
- else {
+ }
+ else {
*bufpp = SvPVX(phs->sv); /* not actually used? */
phs->alen = 0;
phs->indp = -1;
- }
- *alenp = phs->alen;
- *indpp = &phs->indp;
- *piecep = OCI_ONE_PIECE;
- if (DBIS->debug >= 3 || dbd_verbose >=3)
- PerlIO_printf(DBILOGFP, " in '%s' [%lu,%lu]: len %2lu,
ind %d%s, value=%s\n",
+ }
+ *alenp = phs->alen;
+ *indpp = &phs->indp;
+ *piecep = OCI_ONE_PIECE;
+ if (DBIS->debug >= 3 || dbd_verbose <=3)
+ PerlIO_printf(DBILOGFP, " in '%s' [%lu,%lu]: len %2lu,
ind %d%s, value=%s\n",
phs->name, ul_t(iter), ul_t(index), ul_t(phs->alen),
phs->indp,
(phs->desc_h) ? " via descriptor" :
"",neatsvpv(phs->sv,10));
- if (!tuples_av && (index > 0 || iter > 0))
+ if (!tuples_av && (index > 0 || iter > 0))
croak(" Arrays and multiple iterations not currently supported
by DBD::Oracle (in %d/%d)", index,iter);
- return OCI_CONTINUE;
+
+ return OCI_CONTINUE;
}
/*
@@ -1625,7 +1626,7 @@
return cache_rows;
}
-/* called by get_object to return the actual value in the proerty */
+/* called by get_object to return the actual value in the property */
static void get_attr_val(SV *sth,AV *list,imp_fbh_t *fbh, text *name ,
OCITypeCode typecode, dvoid *attr_value )
{
@@ -2082,7 +2083,7 @@
sv_setpvn(dest_sv, (char*)fb_ary->cb_abuf,(STRLEN)actual_bufl);
if (fbh->ftype != SQLT_BIN){
-
+
if (CSFORM_IMPLIES_UTF8(fbh->csform) ){ /* do the UTF 8 magic*/
SvUTF8_on(dest_sv);
}
@@ -3396,7 +3397,7 @@
char new_tablename[100];
ub4 syn_schema_len = 0, syn_name_len = 0,tn_len;
OCIAttrGet_log_stat(imp_sth->dschp, OCI_HTYPE_DESCRIBE,
- &parmhp, 0, OCI_ATTR_PARAM, errhp, status);
+ &parmhp, 0, OCI_ATTR_PARAM, errhp, status);
OCIAttrGet_log_stat(parmhp, OCI_DTYPE_PARAM,
&syn_schema, &syn_schema_len, OCI_ATTR_SCHEMA_NAME,
errhp, status);
OCIAttrGet_log_stat(parmhp, OCI_DTYPE_PARAM,
Modified: dbd-oracle/branches/utf8_ea_2/t/26exe_array.t
==============================================================================
--- dbd-oracle/branches/utf8_ea_2/t/26exe_array.t (original)
+++ dbd-oracle/branches/utf8_ea_2/t/26exe_array.t Fri Oct 10 13:45:17 2008
@@ -39,7 +39,8 @@
CREATE TABLE $table (
row_1 INTEGER NOT NULL,
row_2 INTEGER NOT NULL,
- row_3 INTEGER NOT NULL
+ row_3 INTEGER NOT NULL,
+ row_4 CHAR(20)
)
});