Author: byterock
Date: Tue Jul 14 11:12:54 2009
New Revision: 13057
Modified:
dbd-oracle/branches/rs_array/dbdimp.c
dbd-oracle/branches/rs_array/dbdimp.h
dbd-oracle/branches/rs_array/oci8.c
dbd-oracle/branches/rs_array/ocitrace.h
Log:
working on it copy
Modified: dbd-oracle/branches/rs_array/dbdimp.c
==============================================================================
--- dbd-oracle/branches/rs_array/dbdimp.c (original)
+++ dbd-oracle/branches/rs_array/dbdimp.c Tue Jul 14 11:12:54 2009
@@ -1647,12 +1647,12 @@
if (trace_level >= 3 || dbd_verbose >= 3 )
PerlIO_printf(DBILOGFP, "dbd_rebind_ph_varchar2_table(): bind
%s <== %s "
- "(%s, %s, csid %d->%d->%d, ftype %d, csform %d->%d,
maxlen %lu, maxdata_size %lu)\n",
+ "(%s, %s, csid %d->%d->%d, ftype %d, csform %d (%s)->%d
(%s), maxlen %lu, maxdata_size %lu)\n",
phs->name, neatsvpv(phs->sv,0),
(phs->is_inout) ? "inout" : "in",
flag_data_is_utf8 ? "is-utf8" : "not-utf8",
phs->csid_orig, phs->csid, csid,
- phs->ftype, phs->csform, csform,
+ phs->ftype, phs->csform,oci_csform_name(phs->csform),
csform,oci_csform_name(csform),
(unsigned long)phs->maxlen, (unsigned
long)phs->maxdata_size);
@@ -2546,9 +2546,9 @@
ub2 csid;
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",
+ PerlIO_printf(DBILOGFP, "dbd_rebind_ph() (1): rebinding %s as
%s (%s, ftype %d (%s), csid %d, csform %d(%s), 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->ftype),phs->csid,
phs->csform, phs->is_inout);
+ phs->ftype,sql_typecode_name(phs->ftype),phs->csid,
phs->csform,oci_csform_name(phs->csform), phs->is_inout);
switch (phs->ftype) {
case ORA_VARCHAR2_TABLE:
@@ -2657,12 +2657,12 @@
if (trace_level >= 3 || dbd_verbose >= 3 )
PerlIO_printf(DBILOGFP, "dbd_rebind_ph(): bind %s <== %s "
- "(%s, %s, csid %d->%d->%d, ftype %d (%s), csform %d->%d, maxlen
%lu, maxdata_size %lu)\n",
+ "(%s, %s, csid %d->%d->%d, ftype %d (%s), csform
%d(%s)->%d(%s), maxlen %lu, maxdata_size %lu)\n",
phs->name, neatsvpv(phs->sv,10),
(phs->is_inout) ? "inout" : "in",
(SvUTF8(phs->sv) ? "is-utf8" : "not-utf8"),
phs->csid_orig, phs->csid, csid,
- phs->ftype,sql_typecode_name(phs->ftype), phs->csform, csform,
+ phs->ftype,sql_typecode_name(phs->ftype), phs->csform,
oci_csform_name(phs->csform), csform, oci_csform_name(csform),
(unsigned long)phs->maxlen, (unsigned long)phs->maxdata_size);
@@ -3230,12 +3230,12 @@
if (trace_level >= 3 || dbd_verbose >= 3 )
PerlIO_printf(DBILOGFP, "do_bind_array_exec(): bind %s <==
[array of values] "
- "(%s, %s, csid %d->%d->%d, ftype %d (%s), csform
%d->%d, maxlen %lu, maxdata_size %lu)\n",
+ "(%s, %s, csid %d->%d->%d, ftype %d (%s), csform %d
(%s)->%d (%s), maxlen %lu, maxdata_size %lu)\n",
phs->name,
(phs->is_inout) ? "inout" : "in",
(utf8 ? "is-utf8" : "not-utf8"),
phs->csid_orig, phs->csid, csid,
- phs->ftype,sql_typecode_name(phs->ftype), phs->csform,
csform,
+ phs->ftype,sql_typecode_name(phs->ftype),
phs->csform,oci_csform_name(phs->csform), csform,oci_csform_name(csform),
(unsigned long)phs->maxlen, (unsigned
long)phs->maxdata_size);
Modified: dbd-oracle/branches/rs_array/dbdimp.h
==============================================================================
--- dbd-oracle/branches/rs_array/dbdimp.h (original)
+++ dbd-oracle/branches/rs_array/dbdimp.h Tue Jul 14 11:12:54 2009
@@ -312,6 +312,7 @@
char *oci_attr_name _((ub4 attr));
char *oci_exe_mode _((ub4 mode));
char *oci_col_return_codes _((int rc));
+char *oci_csform_name _((ub4 attr));
int dbd_rebind_ph_lob _((SV *sth, imp_sth_t *imp_sth, phs_t *phs));
int dbd_rebind_ph_nty _((SV *sth, imp_sth_t *imp_sth, phs_t *phs));
Modified: dbd-oracle/branches/rs_array/oci8.c
==============================================================================
--- dbd-oracle/branches/rs_array/oci8.c (original)
+++ dbd-oracle/branches/rs_array/oci8.c Tue Jul 14 11:12:54 2009
@@ -347,33 +347,77 @@
return SvPV(sv,na);
}
-/*used to look up the name of a Attribute Types
+/*used to look up the name of a a csform value
used only for debugging */
char *
-oci_attr_name(ub4 attr)
+oci_csform_name(ub4 attr)
{
dTHX;
SV *sv;
switch (attr) {
- /*=============================Attribute
Types===============================*/
- /*
- Note: All attributes are global. New attibutes should be added to
the end
- of the list. Before you add an attribute see if an existing one can
be
- used for your handle.
- If you see any holes please use the holes first.
+/* CHAR/NCHAR/VARCHAR2/NVARCHAR2/CLOB/NCLOB char set "form" information */
+ case SQLCS_IMPLICIT: return "SQLCS_IMPLICIT";/* for
CHAR, VARCHAR2, CLOB w/o a specified set */
+ case SQLCS_NCHAR: return "SQLCS_NCHAR";/*
for NCHAR, NCHAR VARYING, NCLOB */
+ case SQLCS_EXPLICIT: return "SQLCS_EXPLICIT";/* for
CHAR, etc, with "CHARACTER SET ..." syntax */
+ case SQLCS_FLEXIBLE: return "SQLCS_FLEXIBLE";/* for
PL/SQL "flexible" parameters */
+ case SQLCS_LIT_NULL: return "SQLCS_LIT_NULL";/* for
typecheck of NULL and empty_clob() lits */
+ }
- */
-
/*===========================================================================*/
+ sv = sv_2mortal(newSViv((IV)attr));
+ return SvPV(sv,na);
+}
+/*used to look up the name of a OCI_DTYPE_PARAM Attribute Types
+ used only for debugging */
+char *
+oci_dtype_attr_name(ub4 attr)
+{
+ dTHX;
+ SV *sv;
+ switch (attr) {
+/*=======================Describe Handle Parameter Attributes ===============*/
+ case OCI_ATTR_DATA_SIZE: return
"OCI_ATTR_DATA_SIZE"; /* maximum size of the data */
+ case OCI_ATTR_DATA_TYPE: return
"OCI_ATTR_DATA_TYPE"; /* the SQL type of the column/argument */
+ case OCI_ATTR_DISP_SIZE: return
"OCI_ATTR_DISP_SIZE"; /* the display size */
+ case OCI_ATTR_NAME: return
"OCI_ATTR_NAME"; /* the name of the column/argument */
+ case OCI_ATTR_PRECISION: return
"OCI_ATTR_PRECISION"; /* precision if number type */
+ case OCI_ATTR_SCALE: return
"OCI_ATTR_SCALE"; /* scale if number type */
+ case OCI_ATTR_IS_NULL: return
"OCI_ATTR_IS_NULL"; /* is it null ? */
+ case OCI_ATTR_TYPE_NAME: return
"OCI_ATTR_TYPE_NAME";
+ /* name of the named data type or a package name for package private types */
+ case OCI_ATTR_SCHEMA_NAME: return
"OCI_ATTR_SCHEMA_NAME"; /* the schema name */
+ case OCI_ATTR_SUB_NAME: return
"OCI_ATTR_SUB_NAME"; /* type name if package private type */
+ case OCI_ATTR_POSITION: return
"OCI_ATTR_POSITION";
+ case OCI_ATTR_CHAR_USED: return "OCI_ATTR_CHAR_USED";
/* char length semantics */
+ case OCI_ATTR_CHAR_SIZE: return "OCI_ATTR_CHAR_SIZE";
/* char length */
+ case OCI_ATTR_CHARSET_ID: return
"OCI_ATTR_CHARSET_ID"; /* Character Set ID */
+ case OCI_ATTR_CHARSET_FORM: return
"OCI_ATTR_CHARSET_FORM"; /* Character Set Form */
+ }
+
+ sv = sv_2mortal(newSViv((IV)attr));
+ return SvPV(sv,na);
+
+}
+/*used to look up the name of non a OCI_DTYPE_PARAM Attribute Types
+ used only for debugging */
+char *
+oci_attr_name(ub4 attr)
+{
+ dTHX;
+ SV *sv;
+ switch (attr) {
+ /*=============================Attribute
Types===============================*/
+
+
case OCI_ATTR_FNCODE: return
"OCI_ATTR_FNCODE"; /* the OCI function code */
case OCI_ATTR_OBJECT: return
"OCI_ATTR_OBJECT"; /* is the environment initialized in object mode */
case OCI_ATTR_NONBLOCKING_MODE: return
"OCI_ATTR_NONBLOCKING_MODE"; /* non blocking mode */
case OCI_ATTR_SQLCODE: return
"OCI_ATTR_SQLCODE"; /* the SQL verb */
case OCI_ATTR_ENV: return
"OCI_ATTR_ENV"; /* the environment handle */
- case OCI_ATTR_SERVER: return
"OCI_ATTR_SERVER"; /* the server handle */
- case OCI_ATTR_SESSION: return
"OCI_ATTR_SESSION"; /* the user session handle */
+ case OCI_ATTR_SERVER: return
"OCI_ATTR_SERVER"; /* the server handle*/
+ case OCI_ATTR_SESSION: return
"OCI_ATTR_SESSION"; /* the user session handle*/
case OCI_ATTR_TRANS: return
"OCI_ATTR_TRANS"; /* the transaction handle */
case OCI_ATTR_ROW_COUNT: return
"OCI_ATTR_ROW_COUNT"; /* the rows processed so far */
case OCI_ATTR_SQLFNCODE: return
"OCI_ATTR_SQLFNCODE"; /* the SQL verb of the statement */
@@ -402,7 +446,6 @@
case OCI_ATTR_TRANS_LOCK: return
"OCI_ATTR_TRANS_LOCK"; /* */
case OCI_ATTR_TRANS_NAME: return
"OCI_ATTR_TRANS_NAME"; /* string to identify a global transaction */
case OCI_ATTR_HEAPALLOC: return
"OCI_ATTR_HEAPALLOC"; /* memory allocated on the heap */
- case OCI_ATTR_CHARSET_ID: return
"OCI_ATTR_CHARSET_ID"; /* Character Set ID */
case OCI_ATTR_CHARSET_FORM: return
"OCI_ATTR_CHARSET_FORM"; /* Character Set Form */
case OCI_ATTR_MAXDATA_SIZE: return
"OCI_ATTR_MAXDATA_SIZE"; /* Maximumsize of data on the server */
case OCI_ATTR_CACHE_OPT_SIZE: return
"OCI_ATTR_CACHE_OPT_SIZE"; /* object cache optimal size */
@@ -850,7 +893,6 @@
/* negative value. OCI_ATTR_PREFETCH_MEMORY */
-
if (!DBIc_ACTIVE(imp_dbh)) {
oci_error(sth, NULL, OCI_ERROR, "Database disconnected");
return 0;
@@ -947,8 +989,8 @@
DBIc_IMPSET_on(imp_sth);
if (ora_check_sql) {
- if (!dbd_describe(sth, imp_sth))
- return 0;
+ if (!dbd_describe(sth, imp_sth))
+ return 0;
}
else {
/* set initial cache size by memory */
@@ -1831,8 +1873,8 @@
0, 0, (ub2)0, csform, status);
if (DBIS->debug >= 3 || dbd_verbose >= 3 )
PerlIO_printf(DBILOGFP,
- " OCILobRead %s %s: csform %d, LOBlen
%luc, LongReadLen %luc, BufLen %lub, Got %luc\n",
- name, oci_status_name(status), csform,
ul_t(loblen),
+ " OCILobRead %s %s: csform %d (%s),
LOBlen %luc, LongReadLen %luc, BufLen %lub, Got %luc\n",
+ name, oci_status_name(status),
csform,oci_csform_name(csform), ul_t(loblen),
ul_t(imp_sth->long_readlen), ul_t(buflen),
ul_t(amtp));
if (ftype == 114) {
@@ -1932,14 +1974,19 @@
/* Oracle packets on ethernet have max size of around 1460.
*/
/* We'll aim to fill our row cache with around 10 per go.
*/
/* Using 10 means any 'runt' packets will have less impact.
*/
- int txfr_size = 10 * 1460; /* desired transfer/cache size
*/
+ /* orginally set up as above but playing around with newer
versions*/
+ /* I found that 500 was much faster*/
+ int txfr_size = 500 * 1460; /* desired transfer/cache size
*/
cache_rows = txfr_size / est_width; /* (maybe 1
or 0) */
/* To ensure good performance with large rows (near or larger
*/
/* than our target transfer size) we set a minimum cache size.
*/
- if (cache_rows < 6) /* is cache a 'useful' size? */
- cache_rows = (cache_rows > 0) ? 6 : 4;
+ /* I made them all at least 10* what they were before this */
+ /* main reasoning this old value reprewneted a norm in the
oralce 7~8 */
+ /* 9 to 11 can handel much much more */
+ if (cache_rows < 60) /* is cache a 'useful' size? */
+ cache_rows = (cache_rows > 0) ? 60 : 40;
}
}
if (cache_rows > 10000000) /* keep within Oracle's limits */
@@ -2741,7 +2788,7 @@
*/
- if (DBIS->debug >= 3 || dbd_verbose >= 3 || oci_warn) /*will also
display if oci_want is on*/
+ /*if (DBIS->debug >= 3 || dbd_verbose >= 3 || oci_warn) /*will also
display if oci_want is on*/
PerlIO_printf(DBILOGFP,
" cache settings RowCacheSize=%d,
OCI_ATTR_PREFETCH_ROWS=%lu, OCI_ATTR_PREFETCH_MEMORY=%lu, Rows per Fetch=%d,
Multiple Row Fetch=%s\n",
imp_dbh->RowCacheSize,(unsigned long) (prefetch_rows),
(unsigned long) (prefetch_mem),cache_rows,(imp_sth->row_cache_off)?"Off":"On");
@@ -3031,6 +3078,8 @@
/* set long_readlen for SELECT or PL/SQL with output placeholders */
imp_sth->long_readlen = long_readlen;
+PerlIO_printf(DBILOGFP, "\n\n SQL=%s\n\n",imp_sth->statement);
+
if (imp_sth->stmt_type != OCI_STMT_SELECT) { /* XXX DISABLED, see
num_fields test below */
if (DBIS->debug >= 3 || dbd_verbose >= 3 )
PerlIO_printf(DBILOGFP, " dbd_describe skipped
for %s\n",
@@ -3125,8 +3174,8 @@
fbh->name = SvPVX(fbh->name_sv);
fbh->ftype = 5; /* default: return as null terminated
string */
- if (DBIS->debug >= 4 || dbd_verbose >= 4 )
- PerlIO_printf(DBILOGFP, "Describe col #%d
type=%d(%s)\n",i,fbh->dbtype,sql_typecode_name(fbh->dbtype));
+ if (DBIS->debug >= 4 || dbd_verbose <= 4 )
+ PerlIO_printf(DBILOGFP, "Describe col #%d
type=%d(%s),%d\n",i,fbh->dbtype,sql_typecode_name(fbh->dbtype),ORA_DATE);
switch (fbh->dbtype) {
/* the simple types */
@@ -3270,8 +3319,8 @@
}
}
break;
- case ORA_CLOB: /* CLOB
& NCLOB */
- case ORA_BLOB: /* BLOB
*/
+ case ORA_CLOB: /* CLOB & NCLOB
*/
+ case ORA_BLOB: /* BLOB
*/
case 114: /* BFILE
*/
fbh->ftype = fbh->dbtype;
imp_sth->ret_lobs = 1;
@@ -3279,7 +3328,12 @@
if (imp_sth->pers_lob){ /*get as one peice
fasted but limited to how big you can get.*/
fbh->pers_lob = 1;
- fbh->disize =
fbh->disize+long_readlen; /*user set max value for the fetch*/
+ if (long_readlen){
+ fbh->disize =
fbh->disize*10; /*default size*/
+ }
+ else {
+ fbh->disize =
long_readlen;/*user set max value for the fetch*/
+ }
if (fbh->dbtype == ORA_CLOB){
fbh->ftype = SQLT_CHR;
}
@@ -3302,6 +3356,7 @@
fbh->ftype = SQLT_BIN; /*other
Binary*/
}
fbh->fetch_func = fetch_clbk_lob;
+ imp_sth->row_cache_off=1;
}
else if (imp_sth->piece_lob){ /*get by peice
with polling slowest*/
fbh->piece_lob = 1;
@@ -3319,6 +3374,7 @@
fbh->ftype = SQLT_BIN; /*other
Binary */
}
fbh->fetch_func = fetch_get_piece;
+ imp_sth->row_cache_off=1;
}
else { /*auto lob fetch with locator by far the
fastest*/
fbh->disize = fbh->dbsize *10 ; /* XXX!
*/
@@ -3326,8 +3382,12 @@
fbh->bless = "OCILobLocatorPtr";
fbh->desc_t = OCI_DTYPE_LOB;
OCIDescriptorAlloc_ok(imp_sth->envhp,
&fbh->desc_h, fbh->desc_t);
+ imp_sth->row_cache_off=1;
}
+ if (fbh->csform == SQLCS_NCHAR){
+ imp_sth->row_cache_off=1;
+ }
break;
#ifdef OCI_DTYPE_REF
@@ -3366,12 +3426,12 @@
break;
}
- if (DBIS->debug >= 3 || dbd_verbose >= 3 )
+ if (DBIS->debug >= 3 || dbd_verbose <= 3 )
PerlIO_printf(DBILOGFP,
"Described col %2d: dbtype %d(%s), scale %d,
prec %d, nullok %d, name %s\n"
- " : dbsize %d, char_used %d,
char_size %d, csid %d, csform %d, disize %d\n",
+ " : dbsize %d, char_used %d,
char_size %d, csid %d, csform %d(%s), disize %d\n",
i, fbh->dbtype,
sql_typecode_name(fbh->dbtype),fbh->scale, fbh->prec, fbh->nullok, fbh->name,
- fbh->dbsize, fbh->len_char_used,
fbh->len_char_size, fbh->csid, fbh->csform, fbh->disize);
+ fbh->dbsize, fbh->len_char_used,
fbh->len_char_size, fbh->csid,fbh->csform,oci_csform_name(fbh->csform),
fbh->disize);
if (fbh->ftype == 5) /* XXX need to handle wide chars
somehow */
fbh->disize += 1; /* allow for null terminator */
@@ -3409,6 +3469,7 @@
/* add space for STRING null term, or VAR len prefix */
sb4 define_len = (ftype==94||ftype==95) ? fbh->disize+4 :
fbh->disize;
fb_ary_t *fb_ary;
+
if (fbh->clbk_lob || fbh->piece_lob ){/*init the cb_abuf with
this call*/
fbh->fb_ary =
fb_ary_cb_alloc(imp_sth->piece_size,define_len, imp_sth->rs_array_size);
@@ -3479,8 +3540,8 @@
#ifdef OCI_ATTR_CHARSET_FORM
if ( (fbh->dbtype == 1) && fbh->csform ) {
/* csform may be 0 when talking to Oracle 8.0 database*/
- if (DBIS->debug >= 3 || dbd_verbose >= 3 )
- PerlIO_printf(DBILOGFP, " calling
OCIAttrSet OCI_ATTR_CHARSET_FORM with csform=%d\n", fbh->csform );
+ if (DBIS->debug >= 3 || dbd_verbose <= 3 )
+ PerlIO_printf(DBILOGFP, " calling
OCIAttrSet OCI_ATTR_CHARSET_FORM with csform=%d (%s)\n",
fbh->csform,oci_csform_name(fbh->csform) );
OCIAttrSet_log_stat( fbh->defnp, (ub4)
OCI_HTYPE_DEFINE, (dvoid *) &fbh->csform,
(ub4) 0, (ub4)
OCI_ATTR_CHARSET_FORM, imp_sth->errhp, status );
if (status != OCI_SUCCESS) {
Modified: dbd-oracle/branches/rs_array/ocitrace.h
==============================================================================
--- dbd-oracle/branches/rs_array/ocitrace.h (original)
+++ dbd-oracle/branches/rs_array/ocitrace.h Tue Jul 14 11:12:54 2009
@@ -243,13 +243,20 @@
OciTp,
(void*)th,oci_hdtype_name(ht),(void*)ah,pul_t(sp),oci_attr_name(at),(void*)eh,\
oci_status_name(stat)),stat : stat
+#define OCIAttrGet_d_log_stat(th,ht,ah,sp,at,eh,stat)
\
+ stat = OCIAttrGet(th,ht,ah,sp,at,eh); \
+ (DBD_OCI_TRACEON) ? PerlIO_printf(DBD_OCI_TRACEFP,
\
+ "%sAttrGet(%p,%s,%p,%p,%s,%p)=%s\n", \
+ OciTp,
(void*)th,oci_hdtype_name(ht),(void*)ah,pul_t(sp),oci_dtype_attr_name(at),(void*)eh,\
+ oci_status_name(stat)),stat : stat
+
#define OCIAttrGet_parmap(imp_sth,dh, ht, p1, l, stat)
\
OCIAttrGet_log_stat(dh, ht,
\
(void*)(p1), (l), OCI_ATTR_PARAM, imp_sth->errhp, stat)
#define OCIAttrGet_parmdp(imp_sth, parmdp, p1, l, a, stat)
\
- OCIAttrGet_log_stat(parmdp, OCI_DTYPE_PARAM, \
+ OCIAttrGet_d_log_stat(parmdp, OCI_DTYPE_PARAM, \
(void*)(p1), (l), (a), imp_sth->errhp, stat)
#define OCIAttrGet_stmhp_stat(imp_sth, p1, l, a, stat)
\
@@ -456,9 +463,9 @@
#define OCIParamGet_log_stat(hp,ht,eh,pp,ps,stat)
\
stat=OCIParamGet(hp,ht,eh,pp,ps); \
(DBD_OCI_TRACEON) ? PerlIO_printf(DBD_OCI_TRACEFP,
\
- "%sParamGet(%p,%lu,%p,%p,%lu)=%s\n",
\
+ "%sParamGet(%p,%lu,%p,%p,%lu,%s)=%s\n",
\
OciTp, (void*)hp,ul_t((ht)),(void*)eh,(void*)pp,ul_t(ps),
\
- oci_status_name(stat)),stat : stat
+ oci_hdtype_name(ht),oci_status_name(stat)),stat : stat
#define OCIServerAttach_log_stat(imp_dbh, dbname,md,stat)
\
stat=OCIServerAttach( imp_dbh->srvhp, imp_dbh->errhp, \