Author: byterock
Date: Thu Dec 24 05:23:17 2009
New Revision: 13706
Modified:
dbd-oracle/trunk/Changes
dbd-oracle/trunk/Oracle.h
dbd-oracle/trunk/dbdimp.c
dbd-oracle/trunk/dbdimp.h
dbd-oracle/trunk/oci8.c
Log:
finally in a state where I can add some patches
first one from Martin Evans for Ivs and one from Jan Mach for extended nvarchar
support
Modified: dbd-oracle/trunk/Changes
==============================================================================
--- dbd-oracle/trunk/Changes (original)
+++ dbd-oracle/trunk/Changes Thu Dec 24 05:23:17 2009
@@ -1,4 +1,6 @@
=head1 Changes in DBD-Oracle 1.24(svn rev???)
+ Added extened nvarchar support from Jan Mach
+ Added support for the TYPE attribute on bind_col and the new DBI bind_col
attributes StrictlyTyped and DiscardString from Martin J. Evans
Added ora_ncs_buff_mtpl and enviornment var ORA_DBD_NCS_BUFFER so we can
control the size of the buffer when doing nclob reads
Fix for bug in for changes to row fetch buffer mostly lobs and object
fetches
Fix for rt.cpan.org Ticket #=49741 Oracle.h has commented out params in
OCIXMLTypeCreateFromSrc from Kartik Thakore
Modified: dbd-oracle/trunk/Oracle.h
==============================================================================
--- dbd-oracle/trunk/Oracle.h (original)
+++ dbd-oracle/trunk/Oracle.h Thu Dec 24 05:23:17 2009
@@ -67,6 +67,7 @@
int dbd_db_do _((SV *sv, char *statement));
int dbd_db_commit _((SV *dbh, imp_dbh_t *imp_dbh));
int dbd_db_rollback _((SV *dbh, imp_dbh_t *imp_dbh));
+int dbd_st_bind_col(SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV type, SV
*attribs);
int dbd_db_disconnect _((SV *dbh, imp_dbh_t *imp_dbh));
void dbd_db_destroy _((SV *dbh, imp_dbh_t *imp_dbh));
int dbd_db_STORE_attrib _((SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV
*valuesv));
Modified: dbd-oracle/trunk/dbdimp.c
==============================================================================
--- dbd-oracle/trunk/dbdimp.c (original)
+++ dbd-oracle/trunk/dbdimp.c Thu Dec 24 05:23:17 2009
@@ -874,6 +874,50 @@
return 1;
}
+int dbd_st_bind_col(SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV type, SV
*attribs) {
+ dTHX;
+ int field;
+
+ if (!SvIOK(col)) {
+ croak ("Invalid column number") ;
+ }
+
+ field = SvIV(col);
+
+ if ((field < 1) || (field > DBIc_NUM_FIELDS(imp_sth))) {
+ croak("cannot bind to non-existent field %d", field);
+ }
+
+ imp_sth->fbh[field-1].req_type = type;
+ imp_sth->fbh[field-1].bind_flags = 0; /* default to none */
+
+#if DBIXS_REVISION >= 13590
+ /* DBIXS 13590 added StrictlyTyped and DiscardString attributes */
+ if (attribs) {
+ HV *attr_hash;
+ SV **attr;
+
+ if (!SvROK(attribs)) {
+ croak ("attributes is not a reference");
+ }
+ else if (SvTYPE(SvRV(attribs)) != SVt_PVHV) {
+ croak ("attributes not a hash reference");
+ }
+ attr_hash = (HV *)SvRV(attribs);
+
+ attr = hv_fetch(attr_hash, "StrictlyTyped", (U32)13, 0);
+ if (attr && SvTRUE(*attr)) {
+ imp_sth->fbh[field-1].bind_flags |= DBIstcf_STRICT;
+ }
+
+ attr = hv_fetch(attr_hash, "DiscardString", (U32)13, 0);
+ if (attr && SvTRUE(*attr)) {
+ imp_sth->fbh[field-1].bind_flags |=
DBIstcf_DISCARD_STRING;
+ }
+ }
+#endif /* DBIXS_REVISION >= 13590 */
+ return 1;
+}
int
dbd_db_disconnect(SV *dbh, imp_dbh_t *imp_dbh)
@@ -3932,6 +3976,12 @@
retsv = newRV(sv_2mortal((SV*)av));
while(--i >= 0)
av_store(av, i, boolSV(imp_sth->fbh[i].nullok));
+ }
+ else if (kl==13 && strEQ(key, "len_char_size")) {
+ AV *av = newAV();
+ retsv = newRV(sv_2mortal((SV*)av));
+ while(--i >= 0)
+ av_store(av, i, newSViv(imp_sth->fbh[i].len_char_size));
}
else {
return Nullsv;
Modified: dbd-oracle/trunk/dbdimp.h
==============================================================================
--- dbd-oracle/trunk/dbdimp.h (original)
+++ dbd-oracle/trunk/dbdimp.h Thu Dec 24 05:23:17 2009
@@ -113,7 +113,7 @@
int fetch_offset;
int fetch_position;
int prefetch_memory; /* OCI_PREFETCH_MEMORY*/
- int prefetch_rows; /*
OCI_PREFETCH_ROWS
+ int prefetch_rows; /*
OCI_PREFETCH_ROWS */
/* array fetch: state variables */
int row_cache_off;
int rs_fetch_count; /*fetch count*/
@@ -184,16 +184,20 @@
ub1 len_char_used; /* OCI_ATTR_CHAR_USED
*/
ub2 len_char_size; /* OCI_ATTR_CHAR_SIZE
*/
ub2 csid; /* OCI_ATTR_CHARSET_ID
*/
- ub1 csform; /* OCI_ATTR_CHARSET_FORM
*/
- ub4 disize; /* max display/buffer size
*/
+ ub1 csform; /* OCI_ATTR_CHARSET_FORM
*/
+ ub4 disize; /* max display/buffer size
*/
ub4 piece_size; /*used in callback to set the size
of the piece to get*/
- char *bless; /* for Oracle::OCI style handle data */
+ char *bless; /* for Oracle::OCI style handle data
*/
void *special; /* hook for special purposes (LOBs etc)
*/
int pers_lob; /*for persistant lobs 10g Release
2. or later*/
int clbk_lob; /*for persistant lobs 10g Release
2. or later*/
int piece_lob; /*use piecewise fetch for lobs*/
+
/* Our storage space for the field data as it's fetched */
- sword ftype; /* external datatype we wish to get */
+
+ sword ftype; /* external datatype we wish to get
*/
+ IV req_type; /* type passed to bind_col */
+ UV bind_flags; /* flags passed to bind_col */
fb_ary_t *fb_ary ; /* field buffer array
*/
/* if this is an embedded object we use this */
fbh_obj_t *obj;
@@ -378,6 +382,7 @@
#define dbd_st_FETCH_attrib ora_st_FETCH_attrib
#define dbd_describe ora_describe
#define dbd_bind_ph ora_bind_ph
+#define dbd_st_bind_col ora_st_bind_col
#include "ocitrace.h"
/* end */
Modified: dbd-oracle/trunk/oci8.c
==============================================================================
--- dbd-oracle/trunk/oci8.c (original)
+++ dbd-oracle/trunk/oci8.c Thu Dec 24 05:23:17 2009
@@ -427,8 +427,8 @@
case OCI_ATTR_NESTED_PREFETCH_MEMORY:return
"OCI_ATTR_NESTED_PREFETCH_MEMORY"; /* memory limit for nested rows */
case OCI_ATTR_CHAR_COUNT: return
"OCI_ATTR_CHAR_COUNT";
/* this specifies the bind and define size in
characters */
- case OCI_ATTR_PDSCL: return
"OCI_ATTR_PDSCL"; /* packed decimal scale
- case OCI_ATTR_FSPRECISION OCI_ATTR_PDSCL:return "";*/
+ case OCI_ATTR_PDSCL: return
"OCI_ATTR_PDSCL"; /* packed decimal scale/*
+ /*case OCI_ATTR_FSPRECISION OCI_ATTR_PDSCL:return "";*/
/* fs prec for datetime data
types */
case OCI_ATTR_PDPRC: return
"OCI_ATTR_PDPRC"; /* packed decimal format
case OCI_ATTR_LFPRECISION OCI_ATTR_PDPRC: return "";
@@ -993,9 +993,11 @@
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]*/
+/* else {
+ /* set initial cache size by memory
+ [I'm not now sure why this is here - from a patch sometime
ago - Tim]
+ you are right Tim thre is no need to have this here so out
it goes
+ a very useless call to the server
ub4 cache_mem;
IV cache_mem_iv;
D_imp_dbh_from_sth ;
@@ -1014,7 +1016,7 @@
return 0;
}
}
-
+*/
return 1;
}
@@ -2696,7 +2698,7 @@
-/*static int /* --- Setup the row cache for this sth --- */
+static int /* --- Setup the row cache for this sth --- */
sth_set_row_cache(SV *h, imp_sth_t *imp_sth, int max_cache_rows, int
num_fields, int has_longs)
{
dTHX;
@@ -3787,8 +3789,38 @@
--datalen;
}
sv_setpvn(sv, p, (STRLEN)datalen);
- if (CSFORM_IMPLIES_UTF8(fbh->csform) ){
- SvUTF8_on(sv);
+ #if DBISTATE_VERSION > 94
+ /* DBIXS_REVISION > 13590 */
+ /* If a bind type was specified we use DBI's sql_type_cast
+ to cast it - currently only number types are handled */
+ if (fbh->req_type != 0) {
+ int sts;
+ D_imp_xxh(sth);
+ char errstr[256];
+
+ sts =
DBIc_DBISTATE(imp_sth)->sql_type_cast_svpv(
+ aTHX_ sv, fbh->req_type,
fbh->bind_flags, NULL);
+ if (sts == 0) {
+ sprintf(errstr,
+ "over/under
flow converting column %d to type %ld",
+ i+1,
fbh->req_type);
+ oci_error(sth,
imp_sth->errhp, OCI_ERROR, errstr);
+ return Nullav;
+
+ }
+ else if (sts == -2) {
+ sprintf(errstr,
+ "unsupported
bind type %ld for column %d",
+ fbh->req_type,
i+1);
+ return Nullav;
+ }
+ }
+ else
+ #endif /* DBISTATE_VERSION > 94 */
+ {
+ if
(CSFORM_IMPLIES_UTF8(fbh->csform) ){
+ SvUTF8_on(sv);
+ }
}
}
}