Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5094

JdbcAdapter will "NumberOutOfRange" when iterating over the int(10) unsigned column of mysql

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.30.0
    • None
    • core, jdbc-adapter

    Description

       

      When I have a mysql table, the example is as follows:

      aid:long gettime:datetime xip: int(10) unsigned
      1 2021-08-11 14:38:01.0 3729727635

       

      it will be OK:

      select gettime from table

       

      it will occor some error:

      select substring_index(cast(gettime as varchar),'.',1) from table 
      Caused by: com.mysql.cj.exceptions.NumberOutOfRange: Value '3729727635' is outside of valid range for type java.lang.Integer at com.mysql.cj.result.IntegerValueFactory.createFromLong(IntegerValueFactory.java:62) at com.mysql.cj.result.IntegerValueFactory.createFromLong(IntegerValueFactory.java:44) at com.mysql.cj.protocol.a.MysqlTextValueDecoder.decodeUInt4(MysqlTextValueDecoder.java:99) at com.mysql.cj.protocol.result.AbstractResultsetRow.decodeAndCreateReturnValue(AbstractResultsetRow.java:105) at com.mysql.cj.protocol.result.AbstractResultsetRow.getValueFromBytes(AbstractResultsetRow.java:241) at com.mysql.cj.protocol.a.result.TextBufferRow.getValue(TextBufferRow.java:132) at com.mysql.cj.jdbc.result.ResultSetImpl.getObject(ResultSetImpl.java:1285) ... 34 more 

       

      It seems that  org.apache.calcite.linq4j.tree.Primitive.jdbcGet  

      // code placeholder
      public @Nullable Object jdbcGet(ResultSet resultSet, int i) throws SQLException {
        switch (this) {
        case BOOLEAN:
          return resultSet.getBoolean(i);
        case BYTE:
          return resultSet.getByte(i);
        case CHAR:
          return (char) resultSet.getShort(i);
        case DOUBLE:
          return resultSet.getDouble(i);
        case FLOAT:
          return resultSet.getFloat(i);
        case INT:
          return resultSet.getInt(i);
        case LONG:
          return resultSet.getLong(i);
        case SHORT:
          return resultSet.getShort(i);
        default:
          return resultSet.getObject(i);
        }
      } 

       

      resultSet.getObject  Triggered errors like Integer.parse(Long)

      Attachments

        Activity

          People

            Unassigned Unassigned
            itxiangkui itxiangkui
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: