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 ka...@apache.org on 2009/10/28 09:16:56 UTC

svn commit: r830457 - 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/

Author: kahatlen
Date: Wed Oct 28 08:16:55 2009
New Revision: 830457

URL: http://svn.apache.org/viewvc?rev=830457&view=rev
Log:
DERBY-4411: Scalar subquery erroneously rejected for not returning exactly one row

Merged fix from trunk, revision 829022.

Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.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 28 08:16:55 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,822289,823659,824694
+/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,822289,823659,824694,829022

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java?rev=830457&r1=830456&r2=830457&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java Wed Oct 28 08:16:55 2009
@@ -1618,7 +1618,7 @@
 		** This ProjectRestrictNode is not a No-Op if it does any
 		** restriction.
 		*/
-		if ( (restriction != null) ||
+		if ( (restriction != null) || (constantRestriction != null) ||
 			 (restrictionList != null && restrictionList.size() > 0) )
 		{
 			return false;

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=830457&r1=830456&r2=830457&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 28 08:16:55 2009
@@ -1251,4 +1251,18 @@
 4          |0          
 ij> drop table d4391;
 0 rows inserted/updated/deleted
+ij> -- Regression test for DERBY-4411. The predicate 1=0 used to be lost when the
+-- SELECT statement was compiled, and the statement would fail with a message
+-- saying that a scalar sub-query should return exactly one row.
+create table d4411(a int primary key, b int);
+0 rows inserted/updated/deleted
+ij> insert into d4411 values (0, 4), (1, 3), (2, 2), (3, 1), (4, 0);
+5 rows inserted/updated/deleted
+ij> select * from d4411 where a < (values 2 union select b from d4411 where 1=0);
+A          |B          
+-----------------------
+0          |4          
+1          |3          
+ij> drop table d4411;
+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=830457&r1=830456&r2=830457&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 28 08:16:55 2009
@@ -502,3 +502,11 @@
 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;
+
+-- Regression test for DERBY-4411. The predicate 1=0 used to be lost when the
+-- SELECT statement was compiled, and the statement would fail with a message
+-- saying that a scalar sub-query should return exactly one row.
+create table d4411(a int primary key, b int);
+insert into d4411 values (0, 4), (1, 3), (2, 2), (3, 1), (4, 0);
+select * from d4411 where a < (values 2 union select b from d4411 where 1=0);
+drop table d4411;