db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1406247 - in /db/derby/code/branches/10.9: ./ java/engine/org/apache/derby/impl/sql/compile/SelectNode.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java
Date Tue, 06 Nov 2012 17:52:27 GMT
Author: dag
Date: Tue Nov  6 17:52:26 2012
New Revision: 1406247

URL: http://svn.apache.org/viewvc?rev=1406247&view=rev
Log:
DERBY-5954 NPE in SELECT involving subselects and windows functions

Patch "derby-5954-with-test-2" makes the code only look for in-lined
window specification in simply contained select lists. Adds a new test
case to OLAPTest which would fail with an NPE before this patch,
cf. original JIRA problem.

Backported from trunk cleanly as svn merge -c 1406240 <trunk repo>.


Modified:
    db/derby/code/branches/10.9/   (props changed)
    db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
    db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java

Propchange: db/derby/code/branches/10.9/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1406240

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=1406247&r1=1406246&r2=1406247&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
(original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
Tue Nov  6 17:52:26 2012
@@ -176,11 +176,13 @@ public class SelectNode extends ResultSe
 
 		if (resultColumns != null) {
 
-			// Collect window functions used in result columns, and check them
-			// for any <in-line window specification>s.
+            // Collect simply contained window functions (note: *not*
+            // any inside nested SELECTs) used in result columns, and
+            // check them for any <in-line window specification>s.
 
 			CollectNodesVisitor cnvw =
-				new CollectNodesVisitor(WindowFunctionNode.class);
+                new CollectNodesVisitor(WindowFunctionNode.class,
+                                        SelectNode.class);
 			resultColumns.accept(cnvw);
 			windowFuncCalls = cnvw.getList();
 

Modified: db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java?rev=1406247&r1=1406246&r2=1406247&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java
(original)
+++ db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java
Tue Nov  6 17:52:26 2012
@@ -305,6 +305,23 @@ public class OLAPTest extends BaseJDBCTe
 									  {"4", "4"}};
 		JDBC.assertFullResultSet(rs, expectedRows);
 
+        // Subquery in SELECT list. DERBY-5954
+        rs = s.executeQuery(
+            "SELECT rn_t1, (" +
+            "     SELECT rn_t2 FROM (" +
+            "         SELECT row_number() over() as rn_t2 FROM t2) " +
+            "         as T_2" +
+            "         where T_2.rn_t2 = T_1.rn_t1 + 1  ) " +
+            "     as rn_outer" +
+            "     FROM (SELECT row_number() over() as rn_t1 from t2) as T_1");
+
+        expectedRows = new String[][]{{"1", "2"},
+                                      {"2", "3"},
+                                      {"3", "4"},
+                                      {"4", "5"},
+                                      {"5", null}};
+        JDBC.assertFullResultSet(rs, expectedRows);
+
 
 		/*
 		 * Group by and having



Mime
View raw message