Skip to content

Bug: unsigned tinyint/smallint/int/bigint issue #150

@enix223

Description

@enix223

Senario:

When we declare table with unsigned tinyint, and store value larger than max value of corresponding SIGNED type, negative number is return.

Reproduce

CREATE TABLE t1 (ts TIMESTAMP, f1 TINYINT UNSINGED, f2 SMALLINT UNSIGNED, f3 INT UNSIGNED, f4 BIGINT UNSIGNED);
INSERT INTO t1 (ts, f1, f2, f3, f4) VALUES (NOW, 255, 65535, 4294967295, POW(2, 64) - 1);

Solution:

Just like the mysql-connector-j way, map TINY_UNSIGNED to Integer, SMALLINT_UNSIGNED to Integer, INT_UNSIGNED to Long, BIGINT_UNSIGNED to BigInteger.

  1. UTINYINT should use Short instead of Byte.
  2. USMALLINT should use Integer instead of Short.
  3. UINT should use Long instead of Integer.
  4. UBIGINT should use BigInteger instead of Long

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions