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 da...@apache.org on 2012/11/06 19:03:30 UTC
svn commit: r1406254 - in /db/derby/code/branches/10.8: ./
java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java
Author: dag
Date: Tue Nov 6 18:03:30 2012
New Revision: 1406254
URL: http://svn.apache.org/viewvc?rev=1406254&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.8/ (props changed)
db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java
Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1406240
Modified: db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=1406254&r1=1406253&r2=1406254&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java (original)
+++ db/derby/code/branches/10.8/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java Tue Nov 6 18:03:30 2012
@@ -175,11 +175,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.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java?rev=1406254&r1=1406253&r2=1406254&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java (original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/OLAPTest.java Tue Nov 6 18:03:30 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