From c547837a8d42247eeb86a829088b94aa9e0eec85 Mon Sep 17 00:00:00 2001 From: mjevans Date: Sat, 22 Oct 2011 11:07:35 +0000 Subject: [PATCH 1/2] Fix problems with bind_col where TYPE is specified but no attributes Add warning if TYPE to bind_col is not supported in sql_type_cast Add note to bind_col pod re use of TYPE git-svn-id: http://svn.perl.org/modules/dbd-oracle/trunk@14958 50811bd7-b8ce-0310-adc1-d9db26280581 --- Changes | 16 ++++++++++++++++ Oracle.pm | 6 ++++++ oci8.c | 12 +++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 9b4ddb96..dfba757f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,21 @@ Revision history for DBD::Oracle +Changes in DBD-Oracle 1.33_01 (xx-xx-xxxx) + + [BUG FIXES] + - if bind_col is called with a TYPE but no bind attributes like + StrictlyTyped or DiscardString are set DBD::Oracle still attempts + to call sql_type_cast which is pointless (Martin J. Evans) + - if bind_col is called with a TYPE other than SQL_NUMERIC, + SQL_INTEGER or SQL_DOUBLE and bind attributes like StrictlyTyped or + DiscardString a warning was not issued that the type is unsupported + and no data was returned (Martin J. Evans) + + [DOCUMENTATION] + - Added notes to bind_col documenting the fact that setting a TYPE + does not affect how the column is bound in Oracle, only what + happens after the column data is retrieved (Martin J. Evans) + Changes in DBD-Oracle 1.33_00 (18-10-2011) [BUG FIXES] diff --git a/Oracle.pm b/Oracle.pm index 8cbe4a77..da516eac 100644 --- a/Oracle.pm +++ b/Oracle.pm @@ -4148,6 +4148,12 @@ Returns the number of rows affected for updates, deletes and inserts and -1 for Binds a Perl variable and/or some attributes to an output column of a SELECT statement. Column numbers count up from 1. You do not need to bind output columns in order to fetch data. +NOTE: DBD::Oracle does not use the C<$bind_type> to determine how to +bind the column; it uses what Oracle says the data type is. You can +however set a numeric bind type with the bind attributes +StrictlyTyped/DiscardString as these attributes are applied after the +column is retrieved. + See the DBI documentation for a discussion of the optional parameters C<\%attr> and C<$bind_type> =head3 B diff --git a/oci8.c b/oci8.c index 2c906c77..19be2418 100644 --- a/oci8.c +++ b/oci8.c @@ -3738,6 +3738,7 @@ dbd_describe(SV *h, imp_sth_t *imp_sth) AV * dbd_st_fetch(SV *sth, imp_sth_t *imp_sth){ dTHX; + D_imp_xxh(sth); sword status; D_imp_dbh_from_sth; int num_fields = DBIc_NUM_FIELDS(imp_sth); @@ -3927,12 +3928,13 @@ dbd_st_fetch(SV *sth, imp_sth_t *imp_sth){ #if 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) { + if ((fbh->req_type != 0) && (fbh->bind_flags != 0)) { int sts; 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 %"IVdf"", @@ -3945,7 +3947,11 @@ dbd_st_fetch(SV *sth, imp_sth_t *imp_sth){ sprintf(errstr, "unsupported bind type %"IVdf" for column %d", fbh->req_type, i+1); - return Nullav; + /* issue warning */ + DBIh_SET_ERR_CHAR(sth, imp_xxh, "0", 1, errstr, Nullch, Nullch); + if (CSFORM_IMPLIES_UTF8(fbh->csform) ){ + SvUTF8_on(sv); + } } } else @@ -4669,4 +4675,4 @@ ora_db_version(SV *dbh, imp_dbh_t *imp_dbh) } imp_dbh->server_version = vernum; return vernum; -} \ No newline at end of file +} From 25ca4def5be0f5f945984126afa56e315926e80d Mon Sep 17 00:00:00 2001 From: mjevans Date: Sat, 22 Oct 2011 11:51:19 +0000 Subject: [PATCH 2/2] Commented out unused code git-svn-id: http://svn.perl.org/modules/dbd-oracle/trunk@14959 50811bd7-b8ce-0310-adc1-d9db26280581 --- Changes | 4 ++++ dbdimp.h | 4 ++-- oci8.c | 9 +++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index dfba757f..8530fcf1 100644 --- a/Changes +++ b/Changes @@ -16,6 +16,10 @@ Changes in DBD-Oracle 1.33_01 (xx-xx-xxxx) does not affect how the column is bound in Oracle, only what happens after the column data is retrieved (Martin J. Evans) + [OTHER] + - Commented out some functions in oci8.c which were not used to + reduce the size of the driver a little (Martin J. Evans) + Changes in DBD-Oracle 1.33_00 (18-10-2011) [BUG FIXES] diff --git a/dbdimp.h b/dbdimp.h index 1007b3e1..632e2814 100644 --- a/dbdimp.h +++ b/dbdimp.h @@ -352,8 +352,8 @@ char *oci_exe_mode _((ub4 mode)); char *dbd_yes_no _((int yes_no)); char *oci_col_return_codes _((int rc)); char *oci_csform_name _((ub4 attr)); -char *oci_sql_function_code_name _((int sqlfncode)); -char *oci_ptype_name _((int ptype)); +/*char *oci_sql_function_code_name _((int sqlfncode)); + char *oci_ptype_name _((int ptype));*/ int dbd_rebind_ph_lob _((SV *sth, imp_sth_t *imp_sth, phs_t *phs)); diff --git a/oci8.c b/oci8.c index 19be2418..351410ba 100644 --- a/oci8.c +++ b/oci8.c @@ -23,7 +23,7 @@ int describe_obj_by_tdo(SV *sth,imp_sth_t *imp_sth,fbh_obj_t *obj,ub2 level ); int dump_struct(imp_sth_t *imp_sth,fbh_obj_t *obj,int level); - +/* char * dbd_yes_no(int yes_no) { @@ -33,6 +33,7 @@ dbd_yes_no(int yes_no) } return "No"; } +*/ void dbd_init_oci(dbistate_t *dbistate) @@ -52,6 +53,7 @@ dbd_init_oci_drh(imp_drh_t * imp_drh) } +/* char * oci_sql_function_code_name(int sqlfncode) { @@ -71,7 +73,9 @@ oci_sql_function_code_name(int sqlfncode) sprintf(SvPVX(sv),"(UNKNOWN SQL FN Code %d)", sqlfncode); return SvPVX(sv); } +*/ + /* char * oci_ptype_name(int ptype) { @@ -104,7 +108,8 @@ oci_ptype_name(int ptype) sprintf(SvPVX(sv),"(UNKNOWN PTYPE Code %d)", ptype); return SvPVX(sv); } - + */ + char * oci_exe_mode(ub4 mode) {