db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r825312 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/compile/ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Wed, 14 Oct 2009 22:23:30 GMT
Author: kahatlen
Date: Wed Oct 14 22:23:30 2009
New Revision: 825312

URL: http://svn.apache.org/viewvc?rev=825312&view=rev
Log:
DERBY-4391: NullPointerException when comparing indexed column with result from a set operation

Merged fix from trunk (revision 824694).

Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/union.out
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/union.sql

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 14 22:23:30 2009
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,823659
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,823659,824694

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java?rev=825312&r1=825311&r2=825312&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
Wed Oct 14 22:23:30 2009
@@ -1661,7 +1661,16 @@
 		for (Enumeration e = colRefs.elements(); e.hasMoreElements(); )
 		{
 			ColumnReference ref = (ColumnReference)e.nextElement();
-			ref.getSource().markAllRCsInChainReferenced();
+			ResultColumn source = ref.getSource();
+
+            // DERBY-4391: Don't try to call markAllRCsInChainReferenced() if
+            // source is null. This can happen if the ColumnReference is
+            // pointing to a column that is not from a base table. For instance
+            // if we have a VALUES clause like (VALUES (1, 2), (3, 4)) V1(I, J)
+            // then a column reference to V1.I won't have a source.
+			if (source != null) {
+				source.markAllRCsInChainReferenced();
+			}
 		}
 	}
 

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/union.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/union.out?rev=825312&r1=825311&r2=825312&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/union.out
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/master/union.out
Wed Oct 14 22:23:30 2009
@@ -1217,4 +1217,38 @@
 0 rows inserted/updated/deleted
 ij> drop table t2;
 0 rows inserted/updated/deleted
+ij> -- Regression test for DERBY-4391. These UNION queries used to throw a
+-- NullPointerException during compilation. Now all of them should compile
+-- successfully, but some of them fail during execution if their subqueries
+-- return more than one row.
+create table d4391(a int not null primary key, b int);
+0 rows inserted/updated/deleted
+ij> insert into d4391 values (0, 4), (1, 3), (2, 2), (3, 1), (4, 0);
+5 rows inserted/updated/deleted
+ij> select * from d4391 where a < (values 2 union values 2);
+A          |B          
+-----------------------
+0          |4          
+1          |3          
+ij> select * from d4391 where a < (select 4 from d4391 union select b from d4391);
+ERROR 21000: Scalar subquery is only allowed to return a single row.
+ij> select * from d4391 where a < (select a+b from d4391 union select 4 from d4391);
+A          |B          
+-----------------------
+0          |4          
+1          |3          
+2          |2          
+3          |1          
+ij> select * from d4391 where a < (select a+b from d4391 union select a from d4391);
+ERROR 21000: Scalar subquery is only allowed to return a single row.
+ij> select * from d4391 where a < (select sum(a) from d4391 union select sum(b) from
d4391);
+A          |B          
+-----------------------
+0          |4          
+1          |3          
+2          |2          
+3          |1          
+4          |0          
+ij> drop table d4391;
+0 rows inserted/updated/deleted
 ij> 
\ No newline at end of file

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/union.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/union.sql?rev=825312&r1=825311&r2=825312&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/union.sql
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/union.sql
Wed Oct 14 22:23:30 2009
@@ -489,3 +489,16 @@
 -- cleanup.
 drop table t1;
 drop table t2;
+
+-- Regression test for DERBY-4391. These UNION queries used to throw a
+-- NullPointerException during compilation. Now all of them should compile
+-- successfully, but some of them fail during execution if their subqueries
+-- return more than one row.
+create table d4391(a int not null primary key, b int);
+insert into d4391 values (0, 4), (1, 3), (2, 2), (3, 1), (4, 0);
+select * from d4391 where a < (values 2 union values 2);
+select * from d4391 where a < (select 4 from d4391 union select b from d4391);
+select * from d4391 where a < (select a+b from d4391 union select 4 from d4391);
+select * from d4391 where a < (select a+b from d4391 union select a from d4391);
+select * from d4391 where a < (select sum(a) from d4391 union select sum(b) from d4391);
+drop table d4391;



Mime
View raw message