Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#633 Displaying unsigned INT as signed INT in column?

2.6.5
closed-fixed
Rob Manning
Core (461)
5
2008-05-21
2008-05-20
Anonymous
No

My attached screen grab illustrates the problem. Running a sql query brings back columns (called 'start') that show negative numbers, but look in the highlighed metadata portion of the screen grab and you'll see that the 'start' column is defined as UNSIGNED INT. How?

The same query is displayed correctly in Toad for MySQL, the MySQL command line client and the MySQL Query Browser gui tools, so I suggest that this is a real issue with SQuirrel.

If you also do a query to select all the values of the 'start' column that are < 0, nothing is returned, suggesting that the database and sql side of this are working correctly. The problem seems to be with the actual display and rendering of the column's data values.

I'm running MySQL 5.0, java 1.6 and a version 5.x jdbc connector, with SQuirrel 2.6.5a. Hope this helps...

Paul Uszak
paul@klickngo.com

Discussion

  • Screen grab illustrating INT display bug

     
    Attachments
  • Rob Manning
    Rob Manning
    2008-05-20

    • milestone: --> 2.6.5
    • assigned_to: colbell --> manningr
     
  • Rob Manning
    Rob Manning
    2008-05-20

    Logged In: YES
    user_id=1287991
    Originator: NO

    I believe the problem has to do with Java's lack of unsigned int. So, the maximum value that Java can store is an integer equal to 2^31 -1 (2147483647). An unsigned int in MySQL has a range of 0 to 4294967295. So we overflow the integer storage in Java when values are greater than 2147483647. We should detect large values and switch to longs when large values are detected. Here is my script that reproduces the problem:

    drop table testu;

    create table testu ( pkid int primary key, myu int unsigned );

    -- yields 2147483647.
    insert into testu values (1, 2147483647);

    -- yields -2147483648.
    insert into testu values (2, 2147483648);

    -- yields -2 (2^32 - 2)
    insert into testu values (3, 4294967294);

    -- yields -1 (2^32 - 1)
    insert into testu values (4, 4294967295);

    -- fails with data truncation error (2^32)
    insert into testu values (5, 4294967296);

    SELECT * FROM testu;

    Rob

     
  • Rob Manning
    Rob Manning
    2008-05-21

    Logged In: YES
    user_id=1287991
    Originator: NO

    Fixed in CVS.

    Java's Integer type doesn't support unsigned 32-bit integer values. When we detect that the value is larger than Java's Integer can handle, we now use a Long type.

    Files modified were:

    net.sourceforge.squirrel_sql.fw.sql.ResultSetReader
    net.sourceforge.squirrel_sql.fw.sql.ResultSetReaderTest

    and

    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeInteger

    Rob

     
  • Rob Manning
    Rob Manning
    2008-05-21

    • status: open --> closed-fixed
     
  • Rob Manning
    Rob Manning
    2008-05-22

    Logged In: YES
    user_id=1287991
    Originator: NO

    Fixed in CVS.

    Java's Integer type doesn't support unsigned 32-bit integer values. When we detect that the value is larger than Java's Integer can handle, we now use a Long type.

    Files modified were:

    net.sourceforge.squirrel_sql.fw.sql.ResultSetReader
    net.sourceforge.squirrel_sql.fw.sql.ResultSetReaderTest

    and

    net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeInteger

    Rob