db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Pendleton (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails
Date Thu, 05 Jul 2007 14:11:04 GMT

    [ 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()

                        long longvalue = Long.parseLong(longToken.image);
                        if (sign.equals("-"))
                                {if (true) return -longvalue;}
                                {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);
                                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:
>         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.

View raw message