db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abr...@apache.org
Subject svn commit: r498004 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/SubqueryNode.java testing/org/apache/derbyTesting/functionTests/master/subquery.out testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql
Date Fri, 19 Jan 2007 23:26:38 GMT
Author: abrown
Date: Fri Jan 19 15:26:37 2007
New Revision: 498004

URL: http://svn.apache.org/viewvc?view=rev&rev=498004
Log:
DERBY-2218: Patch to catch untyped null in SubqueryNode at bind phase.

Contributed by Yip Ng (yipng168@gmail.com) 

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?view=diff&rev=498004&r1=498003&r2=498004
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java Fri
Jan 19 15:26:37 2007
@@ -489,6 +489,14 @@
 			/* Bind the expression in the SELECT list */
 			resultSet.bindTargetExpressions(fromList);
 
+			resultSet.bindResultColumns(fromList);
+
+			/* 
+			 * reject any untyped nulls in the EXISTS subquery before 
+			 * SELECT TRUE transformation. 
+			 */
+			resultSet.bindUntypedNullsToResultColumns(null);
+	        
 			/* Transform the ResultColumn into true.
 			 * NOTE: This may be a 2nd instance of the same transformation for
 			 * an EXISTS (select * ...), since we had to transform the 
@@ -510,6 +518,9 @@
 
 		resultSet.bindResultColumns(fromList);
 
+		/* reject any untyped nulls in the subquery */
+		resultSet.bindUntypedNullsToResultColumns(null);
+        
 		/* We need to reset resultColumns since the underlying resultSet may
 		 * be a UNION (and UnionNode.bindResultColumns() regens a new RCL).
 		 */

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out?view=diff&rev=498004&r1=498003&r2=498004
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
Fri Jan 19 15:26:37 2007
@@ -1685,4 +1685,31 @@
 0 rows inserted/updated/deleted
 ij> drop table t2;
 0 rows inserted/updated/deleted
+ij> -- DERBY-2218
+create table t1 (i int);
+0 rows inserted/updated/deleted
+ij> -- ok
+select * from t1 where i in (1, 2, (values cast(null as integer)));
+I          
+-----------
+ij> -- expect error, this used to throw NPE
+select * from t1 where i in (1, 2, (values null));
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> select * from t1 where i in (select i from t1 where i in (1, 2, (values null)));
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> -- expect error
+select * from t1 where exists (values null);
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> select * from t1 where exists (select * from t1 where exists(values null));
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> select i from t1 where exists (select i from t1 where exists(values null));
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> select * from (values null) as t2;
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> select * from t1 where exists (select 1 from (values null) as t2);
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> select * from t1 where exists (select * from (values null) as t2);
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> drop table t1;
+0 rows inserted/updated/deleted
 ij> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql?view=diff&rev=498004&r1=498003&r2=498004
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql
Fri Jan 19 15:26:37 2007
@@ -556,3 +556,18 @@
 drop table t1;
 drop table t2;
 
+-- DERBY-2218
+create table t1 (i int);
+-- ok
+select * from t1 where i in (1, 2, (values cast(null as integer)));
+-- expect error, this used to throw NPE
+select * from t1 where i in (1, 2, (values null));
+select * from t1 where i in (select i from t1 where i in (1, 2, (values null)));
+-- expect error
+select * from t1 where exists (values null);
+select * from t1 where exists (select * from t1 where exists(values null));
+select i from t1 where exists (select i from t1 where exists(values null));
+select * from (values null) as t2;
+select * from t1 where exists (select 1 from (values null) as t2);
+select * from t1 where exists (select * from (values null) as t2);
+drop table t1;



Mime
View raw message