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 "James Alan Shepherd (JIRA)" <ji...@apache.org> on 2007/07/05 15:45:04 UTC

[jira] Created: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

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.


[jira] Updated: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-2902:
-----------------------------------

    Affects Version/s: 10.0.2.0
                       10.0.2.1
                       10.1.1.0
                       10.1.2.1
                       10.1.3.1
                       10.2.1.6
                       10.3.1.4
        Fix Version/s: 10.3.2.0

> 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.0.2.0, 10.0.2.1, 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.1.4
>         Environment: MacTel 10.4.10 JVM 1.6.0-dp
>            Reporter: James Alan Shepherd
>            Assignee: Bryan Pendleton
>            Priority: Minor
>             Fix For: 10.3.2.0, 10.4.0.0
>
>         Attachments: parseLong.diff, parseLong_with_comment.diff
>
>
> 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.


[jira] Commented: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12511379 ] 

Knut Anders Hatlen commented on DERBY-2902:
-------------------------------------------

Thanks Bryan, that makes sense. +1 to commit.

> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: parseLong.diff, parseLong_with_comment.diff
>
>
> 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.


[jira] Commented: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12511118 ] 

Knut Anders Hatlen commented on DERBY-2902:
-------------------------------------------

Hi Bryan,
The patch looks good to me, but wouldn't the code be more readable if we replaced the if/else with
  return Long.parseLong(sign + longToken.image);
?

> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: parseLong.diff
>
>
> 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.


[jira] Assigned: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton reassigned DERBY-2902:
--------------------------------------

    Assignee: Bryan Pendleton

> 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
>            Assignee: Bryan Pendleton
>            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.


[jira] Updated: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-2902:
-----------------------------------

    Fix Version/s: 10.3.1.5

> 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.0.2.0, 10.0.2.1, 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.1.4
>         Environment: MacTel 10.4.10 JVM 1.6.0-dp
>            Reporter: James Alan Shepherd
>            Assignee: Bryan Pendleton
>            Priority: Minor
>             Fix For: 10.3.1.5, 10.3.2.0, 10.4.0.0
>
>         Attachments: parseLong.diff, parseLong_with_comment.diff
>
>
> 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.


[jira] Resolved: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton resolved DERBY-2902.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.4.0.0

Merged the change to the 10.3 branch and committed as revision 565078.

I'll ask the JIRA admin to add a new 10.3 tag to the Fix Versions, and set the 10.3 fix version then.


> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>             Fix For: 10.4.0.0
>
>         Attachments: parseLong.diff, parseLong_with_comment.diff
>
>
> 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.


[jira] Updated: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-2902:
-----------------------------------

    Attachment: parseLong_with_comment.diff

Attached is parseLong_with_comment.diff, with a comment
describing why we re-concatenate the "-" sign into the
Long.parseLong() call, and why we have to do this
conditionally, so that we don't try to call parseLong() with
a value with a leading "+" sign.

> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: parseLong.diff, parseLong_with_comment.diff
>
>
> 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.


[jira] Updated: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-2902:
-----------------------------------

    Derby Info: [Patch Available]

> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: parseLong.diff
>
>
> 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.


[jira] Commented: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12511289 ] 

Bryan Pendleton commented on DERBY-2902:
----------------------------------------

Hi Knut Anders, thanks for the suggestion. That would indeed be clearer, but
unfortunately Long.parseLong() doesn't support a leading "+" sign in its
allowable formats, only a leading "-" sign. So unfortunately if we always
pass the sign to Long.parseLong, the following statement is rejected:

  create table t (a2 int generated always as identity (start with  +0));

I'll add a comment to the code indicating this.

> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: parseLong.diff
>
>
> 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.


[jira] Commented: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12511485 ] 

Bryan Pendleton commented on DERBY-2902:
----------------------------------------

Committed parseLong_with_comment to the trunk as revision 554996.

I think this change is worth merging back to the 10.3 branch, but I don't want to do that immediately because the 10.3 branch is being stabilized for its release. So I'll leave this issue open for now, and when the 10.3 branch is in a good state for accepting non-critical bug fixes I'll merge this change back to the 10.3 branch.


> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: parseLong.diff, parseLong_with_comment.diff
>
>
> 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.


[jira] Updated: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-2902:
-----------------------------------

    Attachment: parseLong.diff

Attached is parseLong.diff,  a patch proposal. It includes the code 
change that I proposed in the previous comment on this issue, and 
a simple set of test cases to be included in autoincrement.sql.

derbyall and suites.All passed. If there are any review comments,
please let me know.


> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: parseLong.diff
>
>
> 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.


[jira] Updated: (DERBY-2902) AS IDENTITY (START WITH -9223372036854775808) fails

Posted by "Bryan Pendleton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-2902:
-----------------------------------

    Derby Info:   (was: [Patch Available])

> 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
>            Assignee: Bryan Pendleton
>            Priority: Minor
>         Attachments: parseLong.diff, parseLong_with_comment.diff
>
>
> 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.