In Connector/J, ResultSetMetaData.isSigned() is incorrect for TINYINT and BIGINT data types.
am 19.09.2002 17:03:35 von Kathy Van Stone[I am not certain this went to the general list]
Description:
In all versions of the MySQL connector I have found, the
method ResultSetMetaData.isSigned() may produce incorrect results for
TINYINT and BIGINT data types. In particular, it will always return
false. An examination of the code shows that those two types are
being treated as non-numeric.
How-To-Repeat:
Create a table containing a column with either signed TINYINT
or signed BIGINT type.
From Java, create a ResultSet containing that column.
Get the ResultSetMetaData for that result set
The return value of isSigned(i) (where 'i' is the column) will
be false, even though it should be true.
Fix:
The code for the method is as follows:
public boolean isSigned(int column) throws java.sql.SQLException
{
Field F = getField(column);
int sql_type = F.getSQLType();
switch (sql_type) {
case Types.SMALLINT:
case Types.INTEGER:
case Types.FLOAT:
case Types.REAL:
case Types.DOUBLE:
case Types.NUMERIC:
case Types.DECIMAL:
return !F.isUnsigned();
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
return false; // I guess
default:
return false;
}
}
It is clear that the cases for BIGINT and TINYINT should be in
with the other numeric types.
Synopsis: ResultSetMetaData
Originator: Kathy Van Stone
Organization: Productsoft Inc.
MySQL support: none
Category: mm.mysql or Connector/J
Class: sw-bug
Release: mysql-3.23.38 (n/a)
Exectutable: n/a
Environment: n/a
System: Win2000
------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail bugs-thread12560@lists.mysql.com
To unsubscribe, e-mail