Skip to content

Commit

Permalink
Fix problems with bind_col where TYPE is specified but no attributes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mjevans committed Oct 22, 2011
1 parent 4f36619 commit c547837
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
16 changes: 16 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
6 changes: 6 additions & 0 deletions Oracle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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<bind_columns>
Expand Down
12 changes: 9 additions & 3 deletions oci8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"",
Expand All @@ -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
Expand Down Expand Up @@ -4669,4 +4675,4 @@ ora_db_version(SV *dbh, imp_dbh_t *imp_dbh)
}
imp_dbh->server_version = vernum;
return vernum;
}
}

0 comments on commit c547837

Please sign in to comment.