You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Bryan Pendleton (JIRA)" <ji...@apache.org> on 2007/07/05 16:11:04 UTC
[jira] Commented: (DERBY-2902) AS IDENTITY (START WITH
-9223372036854775808) fails
[ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12510368 ]
Bryan Pendleton commented on DERBY-2902:
----------------------------------------
I think the problem is indeed in the parser. It appears that the minus sign is
treated as a separate token in the tokenization of the expression, and the
value is converted to a Long, then the minus sign is applied to convert the long
to a negative number. There is the following code in SQLParser's exactNumber()
method:
long longvalue = Long.parseLong(longToken.image);
if (sign.equals("-"))
{
{if (true) return -longvalue;}
}
else
{
{if (true) return longvalue;}
}
Since Long.MAX_VALUE is 9223372036854775807, while
Long.MIN_VALUE is -9223372036854775808, we cannot successfully
parse Long.MIN_VALUE because we try to do it by first computing
Long.parseLong(9223372036854775808), which exceeds Long.MAX_VALUE
and hence throws the exception.
One approach might be to try replacing the above code in exactNumber()
by something like:
if (sign.equals("-"))
{
return Long.parseLong("-" + longToken.image);
}
else
{
return Long.parseLong(longToken.image);
}
If I get some spare time this weekend I'll give that a try.
> AS IDENTITY (START WITH -9223372036854775808) fails
> ---------------------------------------------------
>
> Key: DERBY-2902
> URL: https://issues.apache.org/jira/browse/DERBY-2902
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.2.2.0
> Environment: MacTel 10.4.10 JVM 1.6.0-dp
> Reporter: James Alan Shepherd
> Priority: Minor
>
> When creating a table
> AS IDENTITY (START WITH -9223372036854775808)
> fails but
> AS IDENTITY (START WITH -9223372036854775807)
> succeeds.
> Guess this is a parsing SQL problem as the absolute value appears to be held in a long, which is not quite long enough at the positive end.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.