db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abr...@apache.org
Subject svn commit: r510562 - in /db/derby/code/branches/10.2/java: engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Thu, 22 Feb 2007 15:57:44 GMT
Author: abrown
Date: Thu Feb 22 07:57:43 2007
New Revision: 510562

URL: http://svn.apache.org/viewvc?view=rev&rev=510562
Log:

Manual merge of svn #498004 and svn #498689 to 10.2 trunk.

Contributed by: Yip Ng (yipng168@gmail.com) 

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

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?view=diff&rev=510562&r1=510561&r2=510562
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
Thu Feb 22 07:57:43 2007
@@ -489,6 +489,12 @@
 			/* Bind the expression in the SELECT list */
 			resultSet.bindTargetExpressions(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 +516,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/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out?view=diff&rev=510562&r1=510561&r2=510562
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
Thu Feb 22 07:57:43 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/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out?view=diff&rev=510562&r1=510561&r2=510562
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out
Thu Feb 22 07:57:43 2007
@@ -551,4 +551,27 @@
 1          
 -----------
 1          
+ij> -- DERBY-2218
+drop table t3;
+ERROR 42Y55: 'DROP TABLE' cannot be performed on 'T3' because it does not exist.
+ij> create table t3 (i int);
+0 rows inserted/updated/deleted
+ij> -- expect errors
+-- where clause
+select * from t3 where (values null);
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> -- order by clause
+select * from t3 order by (values null);
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> -- result column
+select (values null) from t3;
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> -- group by clause
+select * from t3 group by (values null);
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> -- having clause
+select * from t3 group by i having (values null);
+ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT statement.
+ij> drop table t3;
+0 rows inserted/updated/deleted
 ij> 

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql?view=diff&rev=510562&r1=510561&r2=510562
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery.sql
Thu Feb 22 07:57:43 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;

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql?view=diff&rev=510562&r1=510561&r2=510562
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql
Thu Feb 22 07:57:43 2007
@@ -326,3 +326,24 @@
 -- DERBY-1587
 VALUES INTEGER(1.5);
 VALUES INT(1.5);
+
+-- DERBY-2218
+drop table t3;
+create table t3 (i int);
+-- expect errors
+-- where clause
+select * from t3 where (values null);
+
+-- order by clause
+select * from t3 order by (values null);
+
+-- result column
+select (values null) from t3;
+
+-- group by clause
+select * from t3 group by (values null);
+
+-- having clause
+select * from t3 group by i having (values null); 
+
+drop table t3;



Mime
View raw message