db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r565078 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Sun, 12 Aug 2007 15:07:28 GMT
Author: bpendleton
Date: Sun Aug 12 08:07:27 2007
New Revision: 565078

URL: http://svn.apache.org/viewvc?view=rev&rev=565078
Log:
DERBY-2902: Can't use Long.MIN_VALUE as start value for identity column.

Merged the fix from the trunk by svn merge -r 554995:554996 

This change ensures that the "-" sign, if present, is passed to the
Long.parseLong call.


Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?view=diff&rev=565078&r1=565077&r2=565078
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
Sun Aug 12 08:07:27 2007
@@ -4373,14 +4373,25 @@
 	{
 		try 
 		{
-			long longvalue = Long.parseLong(longToken.image);
+			/*
+			 * Note that it's important to re-concatenate
+			 * the - sign (if present) into the number
+			 * before converting it to a long value so
+			 * that we can successfully handle any value
+			 * in the range Long.MIN_VALUE ... Long.MAX_VALUE.
+			 * Unfortunately, we can't simply do:
+			 *     return Long.parseLong(sign+longToken.image);
+			 * because Long.parseLong() doesn't accept a
+			 * leading + sign.
+			 */
+
 			if (sign.equals("-"))
 			{
-				return -longvalue;
+				return Long.parseLong("-"+longToken.image);
 			}
 			else
 			{
-				return longvalue;
+				return Long.parseLong(longToken.image);
 			}
 		}
 		catch (NumberFormatException nfe)

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out?view=diff&rev=565078&r1=565077&r2=565078
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out
Sun Aug 12 08:07:27 2007
@@ -2040,4 +2040,29 @@
 10         
 2          
 10         
+ij(CONN2)> -- Derby-2902: can't use LONG.MIN_VALUE as the start value for
+-- an identity column. These tests verify that values less than MIN_VALUE
+-- or greater than MAX_VALUE are rejected, but MIN_VALUE and MAX_VALUE
+-- themeselves are accepted.
+create table t2902_a (c1 bigint generated always as identity
+(start with -9223372036854775807));
+0 rows inserted/updated/deleted
+ij(CONN2)> create table t2902_b (c1 bigint generated always as identity
+(start with +9223372036854775807));
+0 rows inserted/updated/deleted
+ij(CONN2)> create table t2902_c (c1 bigint generated always as identity
+(start with -9223372036854775808));
+0 rows inserted/updated/deleted
+ij(CONN2)> create table t2902_d (c1 bigint generated always as identity
+(start with 9223372036854775808));
+ERROR 42X49: Value '9223372036854775808' is not a valid integer literal.
+ij(CONN2)> create table t2902_e (c1 bigint generated always as identity
+(start with -9223372036854775809));
+ERROR 42X49: Value '9223372036854775809' is not a valid integer literal.
+ij(CONN2)> drop table t2902_a;
+0 rows inserted/updated/deleted
+ij(CONN2)> drop table t2902_b;
+0 rows inserted/updated/deleted
+ij(CONN2)> drop table t2902_c;
+0 rows inserted/updated/deleted
 ij(CONN2)> 

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql?view=diff&rev=565078&r1=565077&r2=565078
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql
Sun Aug 12 08:07:27 2007
@@ -1077,3 +1077,21 @@
 insert into D1644_B values default, 10;
 select * from D1644_B;
 
+-- Derby-2902: can't use LONG.MIN_VALUE as the start value for
+-- an identity column. These tests verify that values less than MIN_VALUE
+-- or greater than MAX_VALUE are rejected, but MIN_VALUE and MAX_VALUE
+-- themeselves are accepted.
+create table t2902_a (c1 bigint generated always as identity
+(start with -9223372036854775807));
+create table t2902_b (c1 bigint generated always as identity
+(start with +9223372036854775807));
+create table t2902_c (c1 bigint generated always as identity
+(start with -9223372036854775808));
+create table t2902_d (c1 bigint generated always as identity
+(start with 9223372036854775808));
+create table t2902_e (c1 bigint generated always as identity
+(start with -9223372036854775809));
+drop table t2902_a;
+drop table t2902_b;
+drop table t2902_c;
+



Mime
View raw message