You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ba...@apache.org on 2006/04/02 17:47:57 UTC

svn commit: r390838 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/SQLBinary.java testing/org/apache/derbyTesting/functionTests/master/bit.out testing/org/apache/derbyTesting/functionTests/tests/lang/bit.sql

Author: bandaram
Date: Sun Apr  2 08:47:56 2006
New Revision: 390838

URL: http://svn.apache.org/viewcvs?rev=390838&view=rev
Log:
DERBY-1085: Fix NullPointerException in SQLBinary.java that causes exception for all FOR BIT DATA types while getting length for NULL values.

Submitted by Satheesh Bandaram (satheesh@sourcery.org)

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/bit.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/bit.sql

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java?rev=390838&r1=390837&r2=390838&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java Sun Apr  2 08:47:56 2006
@@ -227,8 +227,7 @@
 				return streamLength;
 		}
 
-		return getBytes().length;
-
+		return (getBytes() == null) ? 0 : getBytes().length;
 	}
 
 	/*

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/bit.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/bit.out?rev=390838&r1=390837&r2=390838&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/bit.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/bit.out Sun Apr  2 08:47:56 2006
@@ -807,4 +807,32 @@
 ------------------------------------------------------------------------------------------------------------------------------------------------------
 ij> values cast(X'00680069' as char(30)), cast(X'00680069' as varchar(30)), cast(X'00680069' as long varchar);
 ERROR 42846: Cannot convert types 'CHAR () FOR BIT DATA' to 'CHAR'.
+ij> -- DERBY-1085
+create table npetest1 (col1 varchar(36) for bit data not null, constraint pknpe1 primary key (col1));
+0 rows inserted/updated/deleted
+ij> create table npetest2 (col2 varchar(36) for bit data, constraint fknpe1 foreign key (col2) references npetest1(col1) on delete cascade);
+0 rows inserted/updated/deleted
+ij> insert into npetest1 (col1) values (X'0000000001');
+1 row inserted/updated/deleted
+ij> insert into npetest1 (col1) values (X'0000000002');
+1 row inserted/updated/deleted
+ij> insert into npetest1 (col1) values (X'0000000003');
+1 row inserted/updated/deleted
+ij> insert into npetest2 (col2) values (X'0000000001');
+1 row inserted/updated/deleted
+ij> insert into npetest2 (col2) values (NULL);
+1 row inserted/updated/deleted
+ij> insert into npetest2 (col2) values (X'0000000002');
+1 row inserted/updated/deleted
+ij> select col1 from npetest1 where col1 not in (select col2 from npetest2);
+COL1                                                                    
+------------------------------------------------------------------------
+ij> select col1 from npetest1 where col1 not in (select col2 from npetest2 where col2 is not null);
+COL1                                                                    
+------------------------------------------------------------------------
+0000000003                                                              
+ij> drop table npetest2;
+0 rows inserted/updated/deleted
+ij> drop table npetest1;
+0 rows inserted/updated/deleted
 ij> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/bit.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/bit.sql?rev=390838&r1=390837&r2=390838&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/bit.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/bit.sql Sun Apr  2 08:47:56 2006
@@ -413,3 +413,19 @@
 insert into t5612 values (X'00680069', X'00680069', X'00680069');
 select * from t5612;
 values cast(X'00680069' as char(30)), cast(X'00680069' as varchar(30)), cast(X'00680069' as long varchar);
+
+-- DERBY-1085
+
+create table npetest1 (col1 varchar(36) for bit data not null, constraint pknpe1 primary key (col1));
+create table npetest2 (col2 varchar(36) for bit data, constraint fknpe1 foreign key (col2) references npetest1(col1) on delete cascade);
+insert into npetest1 (col1) values (X'0000000001');
+insert into npetest1 (col1) values (X'0000000002');
+insert into npetest1 (col1) values (X'0000000003');
+insert into npetest2 (col2) values (X'0000000001');
+insert into npetest2 (col2) values (NULL);
+insert into npetest2 (col2) values (X'0000000002');
+select col1 from npetest1 where col1 not in (select col2 from npetest2);
+select col1 from npetest1 where col1 not in (select col2 from npetest2 where col2 is not null);
+
+drop table npetest2;
+drop table npetest1;