db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dag H. Wanvik (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking
Date Fri, 16 Dec 2011 18:24:31 GMT

    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13171116#comment-13171116

Dag H. Wanvik commented on DERBY-5546:

In SQLReal, the method setBigDecimal has this line:


The method BigDecimal.floatValue has this caveat in the Javadoc:
" Note that even when the return value is finite, this conversion can lose information about
the precision of the BigDecimal value. "

So, if the actual value is Double.MIN_VALUE, the value here is set to 0.0 without any error.
In contrast, when we try to update a DOUBLE column, the method used is


This will not underflow, but subsequently gets caught by the range check in NumberDataType#normalizeDouble()
where the value is checked against Limits.DB2_SMALLEST_DOUBLE.

However, if the value represented in the BigDecimal is even smaller than Double.MIN_VALUE,
the call "bigDecimal.doubleValue()" would yield 0.0 and we would have the same behavior for
DOUBLE, too.

> ResultSet#updateBigDecimal on a REAL column does not do underflow checking
> --------------------------------------------------------------------------
>                 Key: DERBY-5546
>                 URL: https://issues.apache.org/jira/browse/DERBY-5546
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions:
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java
> In contrast, ResultSet#updateBigDecimal on a FLOAT or DOUBLE column gives the expected
error on underflow. Cf. the attached repro program MissingUnderflowCheck.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message