You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Dag H. Wanvik (Created) (JIRA)" <ji...@apache.org> on 2011/12/16 19:08:30 UTC

[jira] [Created] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

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
    Affects Versions: 10.8.2.2
            Reporter: Dag H. Wanvik
            Priority: Minor


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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Knut Anders Hatlen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13173249#comment-13173249 ] 

Knut Anders Hatlen commented on DERBY-5546:
-------------------------------------------

I think the suggested changes are fine. Could the underflow check be factored out to a shared helper method?

I haven't tested, but I suspect the API comment about loss of precision in BigDecimal.floatValue() also refers to numbers like 1.00000(...)00001 being truncated to 1. Does/should updateBigDecimal() fail in that case 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Issue & fix info: Repro attached
    
> 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: 10.8.2.2
>            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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Attachment: derby-5546.stat
                derby-5546.diff
    
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13192182#comment-13192182 ] 

Dag H. Wanvik commented on DERBY-5546:
--------------------------------------

I have asked the JDBC expert group advice on this one. I'll put this issue on hold until I hear back, unmarking "patch available".
                
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13175668#comment-13175668 ] 

Dag H. Wanvik commented on DERBY-5546:
--------------------------------------

Yes, I would agree  that the converting -0.1 to -1 looks weird. 
                
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13173321#comment-13173321 ] 

Dag H. Wanvik commented on DERBY-5546:
--------------------------------------

Regressions passed.
                
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ 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:

   setValue(bigDecimal.floatValue());

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

  setValue(bigDecimal.doubleValue())

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: 10.8.2.2
>            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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Attachment:     (was: derby-5546.diff)
    
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Mamta A. Satoor (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mamta A. Satoor updated DERBY-5546:
-----------------------------------

    Urgency: Normal
     Labels: derby_triage10_9  (was: )
    
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>              Labels: derby_triage10_9
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Issue & fix info: Repro attached  (was: Repro attached,Patch Available)
    
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Knut Anders Hatlen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174681#comment-13174681 ] 

Knut Anders Hatlen commented on DERBY-5546:
-------------------------------------------

Thanks for running these experiments, Dag. It's an interesting find that embedded uses Math.floor() for the conversion in updateDouble(). That means -0.1 gets converted to -1 on embedded, whereas it's converted to 0 on the client. The conversion on the client sounds more intuitive to me in this case.

When using PreparedStatement.setDouble() on an INT column, both drivers agree that -0.1 should be converted to -1 (probably because the client sends it as a floating point value across the wire and lets the server do the conversion).

However, when invoking ResultSet.getInt() on a REAL column, both drivers convert -0.1 to 0. And CAST(-0.1 AS INT) also evaluates to 0.
                
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Attachment:     (was: derby-5546.stat)
    
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Knut Anders Hatlen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174155#comment-13174155 ] 

Knut Anders Hatlen commented on DERBY-5546:
-------------------------------------------

I guess we could see what happens when updateDouble() is used on an INTEGER column and use that for guidance. For example, what happens when trying to update to:

*  1.1 (does it fail or set the value to 1?

* 0.1 - analogous to the underflow case

And also, what happens with updateLong(1, Long.MAX_VALUE) on a REAL column? (I think it loses precision, but does it fail?)
                
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Attachment: derby-5546.stat
                derby-5546.diff

Uploading DERBY-5546 which adds underflow checking to SQLReal and SQLDouble's setBigDecimal methods.

It also uncomments the tests in ParameterMappingTest#testDerby5533UpdateXXX that had to be disabled due to this error. Or more precisely: the tests are uncommented for the embedded case. DERBY-5534 still makes it necessary to skip them for the client driver case.

Running regressions.
                
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Attachment: MissingUnderflowCheck.java
    
> 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: 10.8.2.2
>            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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13173316#comment-13173316 ] 

Dag H. Wanvik commented on DERBY-5546:
--------------------------------------

I agree about your interpretation of the API comment about precision loss. I took my cues from the current way this is current handled, cf. the code in SQLReal#setDouble:

   float fv = (float) theValue;
   
   // detect rounding taking place at cast time
   if (fv == 0.0f && theValue != 0.0d) {
      throw StandardException.newException(
          SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, TypeId.REAL_NAME);
   }

This is indeed (only) a special case of precision loss. I haven't found any definitions about what should happen in the JDBC standard, so I guess it's implementation defined. With my patch the behavior is more consistent. We could also signal other forms of precision loss, like the one you show, or we could stop throwing on the above also. What do you think?

                
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Issue & fix info: Patch Available,Repro attached  (was: Repro attached)
    
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Commented] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174212#comment-13174212 ] 

Dag H. Wanvik commented on DERBY-5546:
--------------------------------------

Embedded uses Math.floor on the double/float value supplied to updateDouble, no error is given in either 1.1 or 0.1 case.
In the case of updateLong(1, Long.MAX_VALUE) on a REAL column, Derby also loses precision with no error. Embedded just
assigns the long directly to a float value. So it seems we mostly ignore precision loss. 

On the other hand, for SQL REAL/DOUBLE "*" and "/", we do give error under underflow to zero, e.g in SQLDouble#times, so the picture is mixed..
                
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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

        

[jira] [Updated] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik updated DERBY-5546:
---------------------------------

    Component/s: JDBC
    
> 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: 10.8.2.2
>            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

        

[jira] [Assigned] (DERBY-5546) ResultSet#updateBigDecimal on a REAL column does not do underflow checking

Posted by "Dag H. Wanvik (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-5546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dag H. Wanvik reassigned DERBY-5546:
------------------------------------

    Assignee: Dag H. Wanvik
    
> 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: 10.8.2.2
>            Reporter: Dag H. Wanvik
>            Assignee: Dag H. Wanvik
>            Priority: Minor
>         Attachments: MissingUnderflowCheck.java, derby-5546.diff, derby-5546.stat
>
>
> 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