Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 20A3D976A for ; Tue, 6 Nov 2012 18:03:52 +0000 (UTC) Received: (qmail 42771 invoked by uid 500); 6 Nov 2012 18:03:52 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 42744 invoked by uid 500); 6 Nov 2012 18:03:52 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 42737 invoked by uid 99); 6 Nov 2012 18:03:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 18:03:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2012 18:03:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C265723888CD; Tue, 6 Nov 2012 18:03:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Tue, 06 Nov 2012 18:03:30 -0000 To: derby-commits@db.apache.org From: dag@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121106180330.C265723888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 . 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 s. + // Collect simply contained window functions (note: *not* + // any inside nested SELECTs) used in result columns, and + // check them for any 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