Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-496

Driver not dealing with non zero decimal values

    Details

      Description

      We have an environment where we are upgrading the driver from v1.1.8 to 1.6.1 where we are running into issues where a decimal value coming back on the result set does not get parsed as an integer on v1.6.1 (getInt). The previous behavior on 1.x was that the value would get rounded and be a valid integer.

      For instance:

      mysql> select 100/3 as test;
      ---------

      test

      ---------

      33.3333

      ---------
      1 row in set (0.00 sec)

      When run through the Driver v1.6.1:
      Exception in thread "main" java.lang.RuntimeException: java.sql.SQLException: Out of range value for column 'test' : value 33.3333 is not in Integer range
      at ::
      Caused by: java.sql.SQLException: Out of range value for column 'test' : value 33.3333 is not in Integer range
      at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.parseInt(SelectResultSet.java:3440)
      at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getInternalInt(SelectResultSet.java:1075)
      at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getInt(SelectResultSet.java:1054)
      at org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet.getInt(SelectResultSet.java:1061)

      When run on Driver 1.x:
      Results: 33.

      Tested this on multiple versions > 1.x and it seems to be consistent with 1.6.1. The workaround i figured is to parse as Double or Float. However we have a lot of code to refactor if thats what is desired moving forward.

      Note: This also affects getByte, getShort and getInt behavior. For instance a getByte against 1.0 = 1, whereas a getByte against 1.1 will be a similar out of range Exception for the byte range.

        Attachments

          Activity

            People

            • Assignee:
              diego dupin Diego Dupin
              Reporter:
              krisiyer Kris Iyer
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: