Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with data type "INT UNSIGNED" #3231

Closed
AndreyUS opened this issue Oct 11, 2019 · 3 comments · Fixed by #3288
Closed

Issue with data type "INT UNSIGNED" #3231

AndreyUS opened this issue Oct 11, 2019 · 3 comments · Fixed by #3288
Assignees
Milestone

Comments

@AndreyUS
Copy link
Contributor

Bug Report

  1. Create the table

CREATE TABLE IF NOT EXISTS table_name (
my_id int(11) unsigned NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

  1. I'm trying to extract value:

resultSet.getLong("my_id")

Exception occurs:

java.sql.SQLDataException: Value '4294967295' is outside of valid range for type java.lang.Integer
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:114)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:92)
at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:805)
at com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java)
at org.apache.shardingsphere.core.execute.sql.execute.result.QueryResultUtil.getValueByColumnType(QueryResultUtil.java:59)
at org.apache.shardingsphere.core.execute.sql.execute.result.QueryResultUtil.getValue(QueryResultUtil.java:45)
at org.apache.shardingsphere.core.execute.sql.execute.result.StreamQueryResult.getValue(StreamQueryResult.java:75)
at org.apache.shardingsphere.core.merge.dql.common.StreamMergedResult.getValue(StreamMergedResult.java:56)
at org.apache.shardingsphere.shardingjdbc.jdbc.core.resultset.ShardingResultSet.getLong(ShardingResultSet.java:112)

Version: Sharding-JDBC 4.0.0RC2

It should extract value as Long.

Mysql jdbc driver in MysqlType.java contains such declaration for it:

INT_UNSIGNED("INT UNSIGNED", Types.INTEGER, Long.class, MysqlType.FIELD_FLAG_UNSIGNED | MysqlType.FIELD_FLAG_ZEROFILL, MysqlType.IS_DECIMAL, 10L,
"[(M)] [UNSIGNED] [ZEROFILL]"),

@dongzl
Copy link
Contributor

dongzl commented Oct 14, 2019

Hi @AndreyUS , I debug the program, the program return value according to the column type.

Types.INTEGER -> return resultSet.getInt(columnIndex);
but if the column is unsigned int type, it should be return Long value.

@AndreyUS
Copy link
Contributor Author

AndreyUS commented Oct 15, 2019

@dongzl What value do you use for test? When value in int range it works well.
Could you try with value: 4294967295 ?

@dongzl
Copy link
Contributor

dongzl commented Oct 15, 2019

7295

Hi @AndreyUS , yes When value in the valid range, it works well.

But if it beyond the range, should be resultSet.getLong(columnIndex);

I am fixing this problem.

terrymanu pushed a commit that referenced this issue Oct 17, 2019
…rn value. (#3288)

* fixes unsigned int & bigint return value (#3231)

* add unsigned int & bigint return value test case (#3231)

* fixes test case failure (#3231)

* fixes code review problem (#3231)

* fixes code format (#3231)
@terrymanu terrymanu added this to the 4.0.0-RC3 milestone Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants